Skip to content

Commit 84dd3aa

Browse files
committed
Add tests with 100% coverage for Algorithm\Eulerian
1 parent dcd3aac commit 84dd3aa

File tree

1 file changed

+45
-0
lines changed

1 file changed

+45
-0
lines changed

tests/EulerianTest.php

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
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+
}

0 commit comments

Comments
 (0)