File tree 3 files changed +17
-1
lines changed
3 files changed +17
-1
lines changed Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ public class TestDijkstraSP {
10
10
11
11
public static void main (String [] args ) {
12
12
_EdgeWeightedDigraph G = new _EdgeWeightedDigraph (new In ("algdata/tinyEWD.txt" ));
13
+ StdOut .println (G );
13
14
int s = 0 ;
14
15
_DijkstraSP sp = new _DijkstraSP (G , s );
15
16
for (int t = 0 ; t < G .V (); t ++) {
Original file line number Diff line number Diff line change @@ -59,4 +59,17 @@ public Iterable<_DirectedEdge> edges() {
59
59
}
60
60
return bag ;
61
61
}
62
+
63
+ @ Override
64
+ public String toString () {
65
+ StringBuilder s = new StringBuilder (V + " vertices, " + E + " edges\n " );
66
+ for (int v = 0 ; v < V ; v ++) {
67
+ s .append (v ).append (": " );
68
+ for (_DirectedEdge e : adj (v )) {
69
+ s .append (e .toString ()).append (" " );
70
+ }
71
+ s .append ("\n " );
72
+ }
73
+ return s .toString ();
74
+ }
62
75
}
Original file line number Diff line number Diff line change @@ -13,9 +13,11 @@ edge relaxation
13
13
if the length to w is larger than the sum of length to ` v ` plus weight of ` v ` to ` w ` ,
14
14
then ` relax ` : change ` distTo[w] = distTo[v] + e.weight() ` and ` edgeTo[w] = e ` .
15
15
16
+ ![ 2020-05-12_003.jpg] ( https://gitee.com/gdhu/testtingop/raw/master/2020-05-12_003.jpg )
16
17
18
+ ![ 2020-05-12_004.jpg] ( https://gitee.com/gdhu/testtingop/raw/master/2020-05-12_004.jpg )
17
19
18
-
20
+ ![ 2020-05-12_006.jpg ] ( https://gitee.com/gdhu/testtingop/raw/master/2020-05-12_006.jpg )
19
21
20
22
21
23
You can’t perform that action at this time.
0 commit comments