File tree Expand file tree Collapse file tree 2 files changed +19
-0
lines changed Expand file tree Collapse file tree 2 files changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -36,6 +36,10 @@ public function createGraph()
36
36
// initial flow of edges
37
37
$ edges = $ resultGraph ->getEdges ();
38
38
foreach ($ edges as $ edge ) {
39
+ if (!($ edge instanceof EdgeDirected)) {
40
+ throw new UnexpectedValueException ('Undirected edges are not supported for SuccessiveShortestPath ' );
41
+ }
42
+
39
43
// 0 if weight of edge is positive
40
44
$ flow = 0 ;
41
45
Original file line number Diff line number Diff line change @@ -163,4 +163,19 @@ public function testUndirectedFails()
163
163
$ alg = $ this ->createAlgorithm ($ graph );
164
164
$ alg ->getWeightFlow ();
165
165
}
166
+
167
+ /**
168
+ * @expectedException UnexpectedValueException
169
+ */
170
+ public function testUndirectedNegativeCycleFails ()
171
+ {
172
+ // 1(+2) -[0/2/-1]- 2(-2)
173
+ $ graph = new Graph ();
174
+ $ v1 = $ graph ->createVertex (1 )->setBalance (2 );
175
+ $ v2 = $ graph ->createVertex (2 )->setBalance (-2 );
176
+ $ v1 ->createEdge ($ v2 )->setCapacity (2 )->setWeight (-1 );
177
+
178
+ $ alg = $ this ->createAlgorithm ($ graph );
179
+ $ alg ->getWeightFlow ();
180
+ }
166
181
}
You can’t perform that action at this time.
0 commit comments