本文整理汇总了C++中Digraph::addEdge方法的典型用法代码示例。如果您正苦于以下问题:C++ Digraph::addEdge方法的具体用法?C++ Digraph::addEdge怎么用?C++ Digraph::addEdge使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Digraph
的用法示例。
在下文中一共展示了Digraph::addEdge方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: createTinyDigraph
Digraph< int > createTinyDigraph( void )
{
Array< int > edges = {
0, 1,
0, 5,
0, 6,
2, 0,
2, 3,
3, 5,
5, 4,
6, 4,
6, 9,
7, 6,
8, 7,
9, 10,
9, 11,
9, 12,
11, 12,
};
Digraph< int > d;
for ( int i = 0; i < edges.size() / 2; i++ ) {
d.addEdge( edges[ i * 2 ], edges[ i * 2 + 1 ] );
}
return d;
}
示例2: reverse
Digraph* Digraph::reverse() {
Digraph* dg = new Digraph(n(), e());
for (int v = 0; v < n(); v++)
for (int w = first(v); w < n(); w = next(v, w))
dg->addEdge(w, v, getWeight(v, w));
return dg;
}
示例3: main
int main()
{
int V = 4;
Digraph *G = new Digraph(V);
BasicBlock a, b, c, d;
a.i = 0;
b.i = 1;
c.i = 2;
d.i = 3;
G->addEdge(&a, &b);
G->addEdge(&a, &c);
G->addEdge(&c, &b);
G->addEdge(&a, &d);
DirectedDFS DD(G, &c);
printf("%d,%d,%d,%d\n", DD.marked(&a), DD.marked(&b), DD.marked(&c), DD.marked(&d));
TransitiveClosure TC(G);
for (Digraph::GraphIteratorTy I = G->begin(), E = G->end(); I != E; ++I) {
BasicBlock *A = I->first;
for (Digraph::GraphIteratorTy J = G->begin(), F = G->end(); J!= F; ++J) {
BasicBlock *B = J->first;
if (TC.reachable(A, B)) {
std::cout << A->i << " reaches " << B->i << std::endl;
}
}
}
delete G;
return 0;
}
示例4: reverseGraph
Digraph* reverseGraph()
{
Digraph *R = new Digraph(V);
for (GraphIteratorTy I = begin(), E = end(); I != E; ++I) {
BasicBlock *A = I->first;
std::vector<BasicBlock *> B = I->second;
for (AdjIteratorTy II = B.begin(), EE = B.end(); II != EE; ++I) {
R->addEdge(*II, A);
}
}
return R;
}