@@ -76,7 +76,7 @@ public function testIntermediaryVertices()
76
76
77
77
public function testEdgeCapacities ()
78
78
{
79
- // 1(+2) -[0/3/4]-> 2 -[0/4/5]-> 3 ->[0/6/-2]-> 3 (-2)
79
+ // 1(+2) -[0/3/4]-> 2 -[0/4/5]-> 3 ->[0/6/-2]-> 4 (-2)
80
80
$ graph = new Graph ();
81
81
$ v1 = $ graph ->createVertex (1 )->setBalance (2 );
82
82
$ v2 = $ graph ->createVertex (2 );
@@ -90,6 +90,28 @@ public function testEdgeCapacities()
90
90
$ this ->assertEquals (14 , $ alg ->getWeightFlow ()); // 2*4 + 2*5 + 2*-2
91
91
}
92
92
93
+ public function testEdgeFlows ()
94
+ {
95
+ // 1(+4) ---[3/4/2]---> 2 ---[3/3/3]---> 4(-4)
96
+ // | | ^
97
+ // | [0/2/1] |
98
+ // | ↓ |
99
+ // \-------[1/2/2]---> 3 ---[1/5/1]-------/
100
+ $ graph = new Graph ();
101
+ $ v1 = $ graph ->createVertex (1 )->setBalance (4 );
102
+ $ v2 = $ graph ->createVertex (2 );
103
+ $ v3 = $ graph ->createVertex (3 );
104
+ $ v4 = $ graph ->createVertex (4 )->setBalance (-4 );
105
+ $ v1 ->createEdgeTo ($ v2 )->setFlow (3 )->setCapacity (4 )->setWeight (2 );
106
+ $ v2 ->createEdgeTo ($ v4 )->setFlow (3 )->setCapacity (3 )->setWeight (3 );
107
+ $ v1 ->createEdgeTo ($ v3 )->setFlow (1 )->setCapacity (2 )->setWeight (2 );
108
+ $ v3 ->createEdgeTo ($ v4 )->setFlow (1 )->setCapacity (5 )->setWeight (1 );
109
+ $ v2 ->createEdgeTo ($ v3 )->setFlow (0 )->setCapacity (2 )->setWeight (1 );
110
+
111
+ $ alg = $ this ->createAlgorithm ($ graph );
112
+ $ this ->assertEquals (14 , $ alg ->getWeightFlow ()); // 4*1 + 2*2 + 2*1 + 2*2
113
+ }
114
+
93
115
/**
94
116
* @expectedException UnexpectedValueException
95
117
*/
0 commit comments