File tree Expand file tree Collapse file tree 1 file changed +62
-0
lines changed Expand file tree Collapse file tree 1 file changed +62
-0
lines changed Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ use Fhaculty \Graph \Algorithm \Flow as AlgorithmFlow ;
4
+ use Fhaculty \Graph \Graph ;
5
+
6
+ class FlowaTest extends TestCase
7
+ {
8
+ public function testGraphEmpty ()
9
+ {
10
+ $ graph = new Graph ();
11
+
12
+ $ alg = new AlgorithmFlow ($ graph );
13
+
14
+ $ this ->assertFalse ($ alg ->hasFlow ());
15
+
16
+ return $ graph ;
17
+ }
18
+
19
+ public function testEdgeWithZeroFlowIsConsideredFlow ()
20
+ {
21
+ // 1 -- 2
22
+ $ graph = new Graph ();
23
+ $ graph ->createVertex (1 )->createEdge ($ graph ->createVertex (2 ))->setFlow (0 );
24
+
25
+
26
+ $ alg = new AlgorithmFlow ($ graph );
27
+
28
+ $ this ->assertTrue ($ alg ->hasFlow ());
29
+ }
30
+
31
+ /**
32
+ *
33
+ * @param Graph $graph
34
+ * @depends testGraphEmpty
35
+ */
36
+ public function testGraphSimple (Graph $ graph )
37
+ {
38
+ // 1 -> 2
39
+ $ graph ->createVertex (1 )->createEdgeTo ($ graph ->createVertex (2 ));
40
+
41
+ $ alg = new AlgorithmFlow ($ graph );
42
+
43
+ $ this ->assertFalse ($ alg ->hasFlow ());
44
+
45
+ return $ graph ;
46
+ }
47
+
48
+ /**
49
+ *
50
+ * @param Graph $graph
51
+ * @depends testGraphSimple
52
+ */
53
+ public function testGraphWithUnweightedEdges (Graph $ graph )
54
+ {
55
+ // additional flow edge: 2 -> 3
56
+ $ graph ->getVertex (2 )->createEdgeTo ($ graph ->createVertex (3 ))->setFlow (10 );
57
+
58
+ $ alg = new AlgorithmFlow ($ graph );
59
+
60
+ $ this ->assertTrue ($ alg ->hasFlow ());
61
+ }
62
+ }
You can’t perform that action at this time.
0 commit comments