本文整理汇总了C++中GraphCopy::reverseEdge方法的典型用法代码示例。如果您正苦于以下问题:C++ GraphCopy::reverseEdge方法的具体用法?C++ GraphCopy::reverseEdge怎么用?C++ GraphCopy::reverseEdge使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GraphCopy
的用法示例。
在下文中一共展示了GraphCopy::reverseEdge方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: doCall
void OptimalRanking::doCall(
const Graph& G,
NodeArray<int> &rank,
EdgeArray<bool> &reversed,
const EdgeArray<int> &length,
const EdgeArray<int> &costOrig)
{
MinCostFlowReinelt<int> mcf;
// construct min-cost flow problem
GraphCopy GC;
GC.createEmpty(G);
// compute connected component of G
NodeArray<int> component(G);
int numCC = connectedComponents(G,component);
// intialize the array of lists of nodes contained in a CC
Array<List<node> > nodesInCC(numCC);
for(node v : G.nodes)
nodesInCC[component[v]].pushBack(v);
EdgeArray<edge> auxCopy(G);
rank.init(G);
for(int i = 0; i < numCC; ++i)
{
GC.initByNodes(nodesInCC[i], auxCopy);
makeLoopFree(GC);
for(edge e : GC.edges)
if(reversed[GC.original(e)])
GC.reverseEdge(e);
// special cases:
if(GC.numberOfNodes() == 1) {
rank[GC.original(GC.firstNode())] = 0;
continue;
} else if(GC.numberOfEdges() == 1) {
edge e = GC.original(GC.firstEdge());
rank[e->source()] = 0;
rank[e->target()] = length[e];
continue;
}
EdgeArray<int> lowerBound(GC,0);
EdgeArray<int> upperBound(GC,mcf.infinity());
EdgeArray<int> cost(GC);
NodeArray<int> supply(GC);
for(edge e : GC.edges)
cost[e] = -length[GC.original(e)];
for(node v : GC.nodes) {
int s = 0;
edge e;
forall_adj_edges(e,v) {
if(v == e->source())
s += costOrig[GC.original(e)];
else
s -= costOrig[GC.original(e)];
}
supply[v] = s;
}
OGDF_ASSERT(isAcyclic(GC) == true);
// find min-cost flow
EdgeArray<int> flow(GC);
NodeArray<int> dual(GC);
#ifdef OGDF_DEBUG
bool feasible =
#endif
mcf.call(GC, lowerBound, upperBound, cost, supply, flow, dual);
OGDF_ASSERT(feasible);
for(node v : GC.nodes)
rank[GC.original(v)] = dual[v];
}
}