File tree Expand file tree Collapse file tree 1 file changed +45
-0
lines changed Expand file tree Collapse file tree 1 file changed +45
-0
lines changed Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ use Fhaculty \Graph \Algorithm \Eulerian as AlgorithmEulerian ;
4
+ use Fhaculty \Graph \Graph ;
5
+
6
+ class EulerianTest extends TestCase
7
+ {
8
+ public function testGraphEmpty ()
9
+ {
10
+ $ graph = new Graph ();
11
+
12
+ $ alg = new AlgorithmEulerian ($ graph );
13
+
14
+ $ this ->assertFalse ($ alg ->hasCycle ());
15
+ }
16
+
17
+ public function testGraphPairHasNoCycle ()
18
+ {
19
+ // 1 -- 2
20
+ $ graph = new Graph ();
21
+ $ v1 = $ graph ->createVertex (1 );
22
+ $ v2 = $ graph ->createVertex (2 );
23
+ $ v1 ->createEdge ($ v2 );
24
+
25
+ $ alg = new AlgorithmEulerian ($ graph );
26
+
27
+ $ this ->assertFalse ($ alg ->hasCycle ());
28
+ }
29
+
30
+ public function testGraphTriangleCycleIsNotBipartit ()
31
+ {
32
+ // 1 -- 2 -- 3 -- 1
33
+ $ graph = new Graph ();
34
+ $ v1 = $ graph ->createVertex (1 );
35
+ $ v2 = $ graph ->createVertex (2 );
36
+ $ v3 = $ graph ->createVertex (3 );
37
+ $ v1 ->createEdge ($ v2 );
38
+ $ v2 ->createEdge ($ v3 );
39
+ $ v3 ->createEdge ($ v1 );
40
+
41
+ $ alg = new AlgorithmEulerian ($ graph );
42
+
43
+ $ this ->assertTrue ($ alg ->hasCycle ());
44
+ }
45
+ }
You can’t perform that action at this time.
0 commit comments