本文整理汇总了C++中Digraph::read方法的典型用法代码示例。如果您正苦于以下问题:C++ Digraph::read方法的具体用法?C++ Digraph::read怎么用?C++ Digraph::read使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Digraph
的用法示例。
在下文中一共展示了Digraph::read方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: if
main(int argc, char *argv[]) {
if (argc != 2) fatal("usage: cgraph type");
string s;
if (strcmp(argv[1],"graph") == 0) {
Graph g; g.read(cin); Graph g1(1,1);
g1.copyFrom(g); cout << g1.toString(s);
} else if (strcmp(argv[1],"wgraph") == 0) {
Wgraph wg; wg.read(cin); Wgraph wg1(1,1);
wg1.copyFrom(wg); cout << wg1.toString(s);
} else if (strcmp(argv[1],"digraph") == 0) {
Digraph dig; dig.read(cin); Digraph dig1(1,1);
dig1.copyFrom(dig); cout << dig1.toString(s);
} else if (strcmp(argv[1],"wdigraph") == 0) {
Wdigraph wdig; wdig.read(cin); Wdigraph wdig1(1,1);
wdig1.copyFrom(wdig); cout << wdig1.toString(s);
} else if (strcmp(argv[1],"flograph") == 0) {
Flograph fg; fg.read(cin); Flograph fg1(2,1);
fg1.copyFrom(fg); cout << fg1.toString(s);
} else if (strcmp(argv[1],"wflograph") == 0) {
Wflograph wfg; wfg.read(cin); Wflograph wfg1(2,1);
wfg1.copyFrom(wfg); cout << wfg1.toString(s);
} else {
fatal("usage: cgraph type");
}
}
示例2: inOrder
main() {
int i; vertex u,v; edge e; string s;
Digraph dg; dg.read(cin);
int *pos = new int[dg.n()+1];
vertex *vert = new vertex[dg.n()+1];
toposort(dg,pos,vert);
Digraph inOrder(dg.n(),dg.m());
cout << "# ";
for (i = 1; i <= dg.n(); i++) {
u = vert[i];
cout << Util::node2string(u,dg.n(),s) << "->";
cout << Util::node2string(pos[u],dg.n(),s) << " ";
if ((i%10) == 0) cout << "\n# ";
for (e = dg.firstOut(u); e != 0; e=dg.nextOut(u,e)) {
v = dg.head(e);
inOrder.join(pos[u],pos[v]);
}
}
inOrder.sortAdjLists();
cout << endl << inOrder.toString(s);
}