@@ -54,13 +54,52 @@ public function getOutput(Graph $graph)
54
54
55
55
protected function getVertexLabel (Vertex $ vertex )
56
56
{
57
- // TODO: dump additional vertex attributes, such as group, balance, etc.
58
- return $ vertex ->getId ();
57
+ // label defaults to the vertex ID
58
+ $ label = $ vertex ->getId ();
59
+
60
+ // add balance to label if set
61
+ $ balance = $ vertex ->getBalance ();
62
+ if ($ balance !== NULL ){
63
+ if ($ balance > 0 ){
64
+ $ balance = '+ ' . $ balance ;
65
+ }
66
+ $ label .= ' ( ' . $ balance . ') ' ;
67
+ }
68
+
69
+ // add group to label if set
70
+ // TODO: what does 'if set' mean? groups should not be shown when vertex never had any group assigned (but it defaults to 0)
71
+ // $group = $vertex->getGroup();
72
+ // if ($group !== 0) {
73
+ // $label .= ' [' . $group .']';
74
+ // }
75
+
76
+ return $ label ;
59
77
}
60
78
61
79
protected function getEdgeLabel (Edge $ edge )
62
80
{
63
- // TODO: dump additional edge attributes, such as flow, capacity, weight, etc.
64
- return '' ;
81
+ $ label = '' ;
82
+
83
+ $ flow = $ edge ->getFlow ();
84
+ $ capacity = $ edge ->getCapacity ();
85
+ // flow is set
86
+ if ($ flow !== NULL ) {
87
+ // NULL capacity = infinite capacity
88
+ $ label = $ flow . '/ ' . ($ capacity === NULL ? '∞ ' : $ capacity );
89
+ // capacity set, but not flow (assume zero flow)
90
+ } elseif ($ capacity !== NULL ) {
91
+ $ label = '0/ ' . $ capacity ;
92
+ }
93
+
94
+ $ weight = $ edge ->getWeight ();
95
+ // weight is set
96
+ if ($ weight !== NULL ) {
97
+ if ($ label === '' ) {
98
+ $ label = $ weight ;
99
+ } else {
100
+ $ label .= '/ ' . $ weight ;
101
+ }
102
+ }
103
+ return $ label ;
65
104
}
66
105
}
0 commit comments