本文整理汇总了C++中Arc类的典型用法代码示例。如果您正苦于以下问题:C++ Arc类的具体用法?C++ Arc怎么用?C++ Arc使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Arc类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: stringToHypergraph
Position stringToHypergraph(Strings const& inputTokens, IMutableHypergraph<Arc>* pHgResult,
StringToHypergraphOptions const& opts = StringToHypergraphOptions(),
TokenWeights const& inputWeights = TokenWeights()) {
IVocabularyPtr const& pVoc = pHgResult->getVocabulary();
if (!pVoc) SDL_THROW_LOG(Hypergraph, InvalidInputException, "pHgResult hypergraph must contain vocabulary");
for (std::size_t i = 0, numNonlexicalStates = inputTokens.size() + 1; i < numNonlexicalStates; ++i)
pHgResult->addState();
pHgResult->setStart(0);
StateId prevState = 0;
typedef typename Arc::Weight Weight;
typedef FeatureInsertFct<Weight> FI;
Position i = 0, n = inputTokens.size();
for (; i != n; ++i) {
std::string const& token = inputTokens[i];
SDL_TRACE(Hypergraph.StringToHypergraph, i << ": " << token);
const Sym sym = opts.terminalMaybeUnk(pVoc.get(), token);
const StateId nextState = prevState + 1;
Arc* pArc = new Arc(nextState, Tails(prevState, pHgResult->addState(sym)));
Weight& weight = pArc->weight();
assert(opts.inputFeatures != NULL);
for (FeatureId featureId : opts.inputFeatures->getFeaturesForInputPosition(i)) {
FI::insertNew(&weight, featureId, 1);
if (opts.tokens) opts.tokens->insert(sym, featureId);
}
inputWeights.reweight(i, weight);
pHgResult->addArc(pArc);
prevState = nextState;
}
pHgResult->setFinal(prevState);
return n;
}
示例2: getFirstArc
State Dubins::getState(myFloat len) const {
Arc path1 = getFirstArc();
myFloat l1 = path1.getLength();
if (len < l1) {
return path1.getState(len);
}
myFloat l2;
if (isCCC) {
Arc ca = getCenterArc();
l2 = ca.getLength();
if (len < l1 + l2) {
return ca.getState(len - l1);
}
} else {
Line cl = getCenter();
l2 = cl.getLength();
if (len < l1 + l2) {
return cl.getState(len - l1);
}
}
Arc path3 = getSecondArc();
return path3.getState(len - l1 - l2);
}
示例3: printAllProbs
void printAllProbs(std::ostream& resStream) {
Arc arc; arc.setFirst();
do {
double p = calcProb(arc);
resStream << arc << " " << p << std::endl;
} while (arc.next(pof_.n));
}
示例4: rotation
void rotation (Arc& A)
{
int b = A.angle_begin(), e = A.angle_end();
if (e<360) { b+=90; e+=90; }
else { b=0; e=90; }
A.set_angle(b,e);
}
示例5: while
void Magnusson::backtrack(Node* start, TrackingAlgorithm::Path& p, TrackingAlgorithm::VisitorFunction nodeVisitor)
{
p.clear();
Node* current = start;
while(current != &(graph_->getSourceNode()))
{
nodeVisitor(current);
Arc* bestArc = nullptr;
if(current == start)
bestArc = selectorFunction_(current);
else
bestArc = current->getBestInArc();
assert(bestArc != nullptr);
assert(bestArc->isEnabled());
if(bestArc->getType() != Arc::Dummy)
bestArc->markUsed();
p.push_back(bestArc);
current = bestArc->getSourceNode();
}
nodeVisitor(current);
std::reverse(p.begin(), p.end());
}
示例6:
void MinCost<FlowType, CostType>::TestOptimality()
{
Node* i;
Arc* a;
for (i=nodes; i<nodes+nodeNum; i++)
{
if (i->excess != 0)
{
assert(0);
}
for (a=i->firstSaturated; a; a=a->next)
{
if (a->r_cap != 0)
{
assert(0);
}
}
for (a=i->firstNonsaturated; a; a=a->next)
{
CostType c = a->GetRCost();
if (a->r_cap <= 0 || a->GetRCost() < -1e-5)
{
assert(0);
}
}
}
}
示例7: new
void
Subdivider::addArc( int npts, TrimVertex *pts, long _nuid )
{
Arc *jarc = new(arcpool) Arc( arc_none, _nuid );
jarc->pwlArc = new(pwlarcpool) PwlArc( npts, pts );
initialbin.addarc( jarc );
pjarc = jarc->append( pjarc );
}
示例8: w
int Flow::createVarW()
{
int nvars = 0;
double coeff = 0.0;
double lb = 0.;
double ub = 1e20;
VariableHash::iterator vit;
Variable::VARTYPE varType = Variable::V_W;
Column::COLTYPE colType = Column::COLTYPE::CONTINUOUS;
for (int sIt = 0; sIt < g->nTerminals; ++sIt)
{
Vertex s = g->terminals[sIt];
for (int i = 1; i <= g->nVertices; ++i)
{
for (int j = 0; j < g->adjList[i].size(); ++j)
{
Arc arc = g->adjList[i][j];
Variable w(colType, coeff, lb, ub);
w.setType(varType);
w.setCategory('p');
w.setVertex1(s);
w.setArc(arc.toEdge());
vit = vHash[varType].find(w);
if (vit != vHash[varType].end())
continue;
bool isInserted = addCol(&w);
if (isInserted)
{
w.setColIdx(getNCols() - 1);
vHash[varType][w] = w.getColIdx();
++nvars;
}
w.setCategory('m');
vit = vHash[varType].find(w);
if (vit != vHash[varType].end())
continue;
isInserted = addCol(&w);
if (isInserted)
{
w.setColIdx(getNCols() - 1);
vHash[varType][w] = w.getColIdx();
++nvars;
}
}
}
}
return nvars;
}
示例9: while
Kcore::Kcore(GrapheNonOriente* graphe, int k){
std::vector<int> degresCumulatifs;
std::vector<int> tabdegre;//tableau de degrés des sommets
for(unsigned int i=0;i<graphe->size();i++){
tabdegre.push_back(graphe->getDegre(i));
}
while(!supK(tabdegre,k)){//tant qu'il reste des degrés inférieurs à k et différents de 0
for(unsigned int i=0;i<graphe->size();i++){
if(tabdegre[i]<k && tabdegre[i]!=0){
tabdegre[i] = 0;//on passe le degré du sommet à 0 vu qu'il n'appartient pas au kcore
std::vector<Arc> arcs = graphe->getArcs(i);
for (unsigned int j=0;j<arcs.size();j++){
//on récupère les voisins et on diminuent leur degré de 1
Arc a = arcs[j];
if(tabdegre[a.getNumeroSommet()] != 0)
tabdegre[a.getNumeroSommet()]--;
}
}
}
}
//calcul degrés cumultatifs
for(unsigned int i=0;i<graphe->size();i++){
if(i == 0){
degresCumulatifs.push_back(tabdegre[i]);
}else{
degresCumulatifs.push_back(tabdegre[i] + degresCumulatifs[i-1]);
}
}
//construction de graphe
std::vector<Arc> arcsG;
std::vector<double> poids;
unsigned int nbArcs = graphe->nbArcs();
for(unsigned int numeroSommet=0; numeroSommet<graphe->size();numeroSommet++){
if(tabdegre[numeroSommet] == 0){
//On dérément le nombre d'arcs car ce sommet n'a plus d'arcs
vector<Arc> voisins = graphe->getArcs(numeroSommet);
for(unsigned int indiceVoisin=0; indiceVoisin < voisins.size(); indiceVoisin++){
if(tabdegre[(voisins[indiceVoisin]).getNumeroSommet()] != 0){
nbArcs--;
}else if(voisins[indiceVoisin].getNumeroSommet() < numeroSommet){
nbArcs--;
}
}
}else{
vector<Arc> voisins = graphe->getArcs(numeroSommet);
for(unsigned int indiceVoisin=0; indiceVoisin < voisins.size(); indiceVoisin++){
if(tabdegre[(voisins[indiceVoisin]).getNumeroSommet()] != 0){
//Si le voisin a toujours des arcs, alors on ajoute l'arc
arcsG.push_back(voisins[indiceVoisin]);
}
}
}
}
m_grapheKcore = new GrapheNonOriente(degresCumulatifs, arcsG, poids, nbArcs);
m_tabDegre = tabdegre;
}
示例10: GetClosingArcIfGoodOneSidedCurve
/* DONE */ FoliationRP2::GoodOneSidedCurve FoliationRP2::GetGoodOneSidedCurve(const SeparatrixSegment& SegmentShiftedToLeft,
const SeparatrixSegment& SegmentShiftedToRight){
if (AreDepthsGoodForOneSidedCurve(SegmentShiftedToRight.m_Depth, SegmentShiftedToLeft.m_Depth)) {
Arc myArc = GetClosingArcIfGoodOneSidedCurve(SegmentShiftedToRight, SegmentShiftedToLeft);
if (myArc.GetLeftEndpoint().GetSide() == LEFT) {
return GoodOneSidedCurve(SegmentShiftedToLeft, SegmentShiftedToRight, myArc);
}
}
throw ExceptionNoObjectFound();
}
示例11: assert
void MinCost<FlowType, CostType>::Dijkstra(Node* start)
{
assert(start->excess > 0);
Node* i;
Node* j;
Arc* a;
CostType d;
Node* permanentNodes;
int FLAG0 = ++ counter; // permanently labeled nodes
int FLAG1 = ++ counter; // temporarily labeled nodes
start->parent = NULL;
start->flag = FLAG1;
queue.Reset();
queue.Add(start, 0);
permanentNodes = NULL;
while ( (i=queue.RemoveMin(d)) )
{
if (i->excess < 0)
{
FlowType delta = Augment(start, i);
cost += delta*(d - i->pi + start->pi);
for (i=permanentNodes; i; i=i->next_permanent) i->pi += d;
break;
}
i->pi -= d;
i->flag = FLAG0;
i->next_permanent = permanentNodes;
permanentNodes = i;
for (a=i->firstNonsaturated; a; a=a->next)
{
j = a->head;
if (j->flag == FLAG0) continue;
d = a->GetRCost();
if (j->flag == FLAG1)
{
if (d >= queue.GetKey(j)) continue;
queue.DecreaseKey(j, d);
}
else
{
queue.Add(j, d);
j->flag = FLAG1;
}
j->parent = a;
}
}
}
示例12: main
int main()
{
Simple_window win {Point{100, 100}, 600, 600, "Exercise 1"};
Arc a {Point{200, 200}, 50, 40, 0, 70};
a.set_color(Color::red);
a.set_fill_color(Color::white);
win.attach(a);
win.wait_for_button();
}
示例13:
Node *Arcs::target_node( Label l )
{
Arc *arc;
for( arc=first_arcp; arc; arc=arc->next)
if (arc->label() == l)
return arc->target_node();
return NULL;
}
示例14: ContainsArcQ
bool ArcsAroundDivPoints::ContainsArcQ(const Arc& arc) const{
for (int i = 0; i < m_DivPoints.size(); i++) {
if (arc.ContainsQ(m_Arcs[i].GetLeftEndpoint()) || arc.ContainsQ(m_Arcs[i].GetRightEndpoint())) {
return false;
}
}
for (int i = 0; i < m_DivPoints.size(); i++) {
if (m_Arcs[i].ContainsQ(arc.GetRightEndpoint())) {
return true;
}
}
return false;
}
示例15: floydWarshallInit
void floydWarshallInit(IHypergraph<Arc> const& hg, Util::Matrix<typename ArcWtFn::Weight>* pdistances,
ArcWtFn arcWtFn) {
typedef typename ArcWtFn::Weight Weight;
Util::Matrix<Weight>& dist = *pdistances;
dist.setDiagonal(Weight::one(), Weight::zero());
for (StateId tail = 0, numStates = (StateId)dist.getNumRows(); tail < numStates; ++tail) {
Weight* rowTail = dist.row(tail);
for (ArcId aid : hg.outArcIds(tail)) {
Arc* arc = hg.outArc(tail, aid);
StateId head = arc->head();
Hypergraph::plusBy(arcWtFn(arc), rowTail[head]);
}
}
}