本文整理汇总了C++中GraphCopy::newNode方法的典型用法代码示例。如果您正苦于以下问题:C++ GraphCopy::newNode方法的具体用法?C++ GraphCopy::newNode怎么用?C++ GraphCopy::newNode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GraphCopy
的用法示例。
在下文中一共展示了GraphCopy::newNode方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: constructComponentGraphs
void SubgraphUpwardPlanarizer::constructComponentGraphs(BCTree &BC, NodeArray<GraphCopy> &biComps)
{
NodeArray<int> constructed(BC.originalGraph(), -1);
const Graph &bcTree = BC.bcTree();
int i = 0; // comp. number
for(node v : bcTree.nodes) {
if (BC.typeOfBNode(v) == BCTree::CComp)
continue;
const SList<edge> &edges_comp = BC.hEdges(v); //bicomp edges
List<edge> edges_orig;
for(edge e : edges_comp)
edges_orig.pushBack(BC.original(e));
GraphCopy GC;
GC.createEmpty(BC.originalGraph());
// construct i-th component graph
for(edge eOrig : edges_orig) {
node srcOrig = eOrig->source();
node tgtOrig = eOrig->target();
if (constructed[srcOrig] != i) {
constructed[srcOrig] = i;
GC.newNode(srcOrig);
}
if (constructed[tgtOrig] != i) {
constructed[tgtOrig] = i;
GC.newNode(tgtOrig);
}
GC.newEdge(eOrig);
}
biComps[v] = GC;
i++;
}
}
示例2: call
void UpwardPlanarSubgraphSimple::call(GraphCopy &GC, List<edge> &delEdges)
{
const Graph &G = GC.original();
delEdges.clear();
// We construct an auxiliary graph H which represents the current upward
// planar subgraph.
Graph H;
NodeArray<node> mapToH(G,nullptr);
NodeArray<node> mapToG(H,nullptr);
for(node v : G.nodes)
mapToG[ mapToH[v] = H.newNode() ] = v;
// We currently support only single-source acyclic digraphs ...
node s;
hasSingleSource(G,s);
OGDF_ASSERT(s != 0);
OGDF_ASSERT(isAcyclic(G));
// We start with a spanning tree of G rooted at the single source.
NodeArray<bool> visitedNode(G,false);
SListPure<edge> treeEdges;
dfsBuildSpanningTree(s,treeEdges,visitedNode);
// Mark all edges in the spanning tree so they can be skipped in the
// loop below and add (copies of) them to H.
EdgeArray<bool> visitedEdge(G,false);
SListConstIterator<edge> it;
for(it = treeEdges.begin(); it.valid(); ++it) {
edge eG = *it;
visitedEdge[eG] = true;
H.newEdge(mapToH[eG->source()],mapToH[eG->target()]);
}
// Add subsequently the remaining edges to H and test if the resulting
// graph is still upward planar. If not, remove the edge again from H
// and add it to delEdges.
SList<Tuple2<node,node> > augmented;
GraphCopySimple graphAcyclicTest(G);
for(edge eG : G.edges)
{
// already treated ?
if(visitedEdge[eG] == true)
continue;
// insert edge into H
edge eH = H.newEdge(mapToH[eG->source()],mapToH[eG->target()]);
node superSink;
SList<edge> augmentedEdges;
if (UpwardPlanarity::upwardPlanarAugment_singleSource(H,superSink,augmentedEdges) == false) {
// if H is no longer upward planar, remove eG from subgraph
H.delEdge(eH);
delEdges.pushBack(eG);
} else {
// add augmented edges as node-pair to tmpAugmented and remove
// all augmented edges from H again
SList<Tuple2<node,node> > tmpAugmented;
SListConstIterator<edge> it;
for(it = augmentedEdges.begin(); it.valid(); ++it) {
node v = mapToG[(*it)->source()];
node w = mapToG[(*it)->target()];
if (v && w)
tmpAugmented.pushBack(Tuple2<node,node>(v,w));
H.delEdge(*it);
}
if (mapToG[superSink] == nullptr)
H.delNode(superSink);
//****************************************************************
// The following is a simple workaround to assure the following
// property of the upward planar subgraph:
// The st-augmented upward planar subgraph plus the edges not
// in the subgraph must be acyclic. (This is a special property
// of the embedding, not the augmentation.)
// The upward-planar embedding function gives us ANY upward-planar
// embedding. We check if the property above holds with this
// embedding. If it doesn't, we have actually no idea if another
// embedding would do.
// The better solution would be to incorporate the acyclicity
// property into the upward-planarity test, but this is compicated.
//****************************************************************
// test if original graph plus augmented edges is still acyclic
if(checkAcyclic(graphAcyclicTest,tmpAugmented) == true) {
augmented = tmpAugmented;
} else {
// if not, remove eG from subgraph
//.........这里部分代码省略.........