title | date | draft | tags | categories | |||
---|---|---|---|---|---|---|---|
Algorithm4 Java Solution 4.2.02 |
2020-02-21 06:16:20 +0800 |
false |
|
|
Draw, in the style of the figure in the text (page 524), the adjacency lists built by Digraph’s input stream constructor for the file tinyDGex2.txt depicted at left.
code:
String filePath = "algdata/tinyGex2.txt";
_AdjListDigraph G = new _AdjListDigraph(new In(filePath));
StdOut.println(G);
// 12 vertices, 16 edges
// 0->6
// 1->11
// 2->0->3
// 3->6
// 4->1
// 5->0->10->2
// 6->2
// 7->8->11
// 8->1->4
// 9
// 10->3
// 11->8
}