当前位置: 首页>>代码示例>>C++>>正文


C++ Arc::getTargetNode方法代码示例

本文整理汇总了C++中Arc::getTargetNode方法的典型用法代码示例。如果您正苦于以下问题:C++ Arc::getTargetNode方法的具体用法?C++ Arc::getTargetNode怎么用?C++ Arc::getTargetNode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Arc的用法示例。


在下文中一共展示了Arc::getTargetNode方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: cleanUpUsedSwapArcs

void Magnusson::cleanUpUsedSwapArcs(TrackingAlgorithm::Path &p, std::vector<Path>& paths)
{
    std::vector<Arc*> usedSwapArcs;

    // if a swap arc was used, we can find the path that was affected by this and create the two paths after swapping
    bool foundSwapArc = true;
    while(foundSwapArc)
    {
        foundSwapArc = false;
        for(std::vector<Arc*>::reverse_iterator p_it = p.rbegin(); p_it != p.rend(); ++p_it)
        {
            // FIXME: sometimes points to free'd memory location?
            Arc* arc = *p_it;
            if(arc->getType() == Arc::Swap)
            {
                assert(arc->getUserData());
                Arc* arcToRemove = std::static_pointer_cast<MagnussonSwapArcUserData>(arc->getUserData())->getCutArc();
                Arc* replacementP = std::static_pointer_cast<MagnussonSwapArcUserData>(arc->getUserData())->getReplacementAArc();
                Arc* replacementPath = std::static_pointer_cast<MagnussonSwapArcUserData>(arc->getUserData())->getReplacementBArc();
                assert(arcToRemove != nullptr);
                assert(replacementP != nullptr);
                assert(replacementPath != nullptr);

                DEBUG_MSG("Trying to remove swap arc between " << arc->getSourceNode()->getUserData()->toString() << " and " << arc->getTargetNode()->getUserData()->toString());

                for(Path& path : paths)
                {
                    for(Node::ArcIt path_it = path.begin(); path_it != path.end(); ++path_it)
                    {
                        Arc* a = *path_it;

                        if(a == arcToRemove)
                        {
                            // found candidate. store part of original path that will be used by new path
                            Path temp(path_it+1, path.end());

                            for(Node::ArcIt temp_it = temp.begin(); temp_it != temp.end(); ++temp_it)
                            {
                                assert((*temp_it)->getType() != Arc::Swap);
                            }

                            // update original path by appending the replacement arc and the remainder of path P
                            path.erase(path_it, path.end());
                            path.push_back(replacementPath);
                            path.insert(path.end(), p_it.base(), p.end());

                            // update path p
                            p.erase(p_it.base()-1, p.end());
                            p.push_back(replacementP);
                            p.insert(p.end(), temp.begin(), temp.end());

                            if(usedArcsScoreZero_)
                            {
                                replacementPath->markUsed();
                                replacementP->markUsed();
                                // "unuse" the arc that was previously used
                                arcToRemove->markUsed(false);
                            }

                            // remove all this swap arc
                            usedSwapArcs.push_back(arc);
 
#if DEBUG_LOG
                            DEBUG_MSG("updated two paths. removed swap arc between " << arc->getSourceNode()->getUserData()->toString() << " and " << arc->getTargetNode()->getUserData()->toString());
                            graph_->print();
#endif

                            foundSwapArc = true;
                            break;
                        }
                    }

                    if(foundSwapArc)
                        break;
                }

                assert(foundSwapArc);
                break;
            }
        }
    }

    for(Arc* a: usedSwapArcs)
    {
        removeSwapArc(a);
    }

#ifdef DEBUG_LOG
    DEBUG_MSG("Paths after removing swaps:");
    printPath(p);
    for(Path& path : paths)
        printPath(path);

    for(Node::ArcIt p_it = p.begin(); p_it != p.end(); ++p_it)
    {
        assert((*p_it)->getType() != Arc::Swap);
    }
#endif
}
开发者ID:chaubold,项目名称:dpct,代码行数:99,代码来源:magnusson.cpp


注:本文中的Arc::getTargetNode方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。