File tree Expand file tree Collapse file tree
lib/Fhaculty/Graph/Algorithm/MinimumCostFlow
tests/Fhaculty/Graph/Algorithm/MinimumCostFlow Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -36,6 +36,10 @@ public function createGraph()
3636 // initial flow of edges
3737 $ edges = $ resultGraph ->getEdges ();
3838 foreach ($ edges as $ edge ) {
39+ if (!($ edge instanceof EdgeDirected)) {
40+ throw new UnexpectedValueException ('Undirected edges are not supported for SuccessiveShortestPath ' );
41+ }
42+
3943 // 0 if weight of edge is positive
4044 $ flow = 0 ;
4145
Original file line number Diff line number Diff line change @@ -163,4 +163,19 @@ public function testUndirectedFails()
163163 $ alg = $ this ->createAlgorithm ($ graph );
164164 $ alg ->getWeightFlow ();
165165 }
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+ }
166181}
You can’t perform that action at this time.
0 commit comments