Bearsampp 2026.9.23
Loading...
Searching...
No Matches
AcyclicTestTest.php
Go to the documentation of this file.
1<?php
2require_once dirname(__FILE__) . '/helper.inc';
3require_once 'Structures/Graph/Manipulator/AcyclicTest.php';
4
5class AcyclicTestTest extends \PHPUnit\Framework\TestCase
6{
7 public function testIsAcyclicFalse()
8 {
9 $graph = new Structures_Graph();
10 $node1 = new Structures_Graph_Node();
11 $graph->addNode($node1);
12
13 $node2 = new Structures_Graph_Node();
14 $graph->addNode($node2);
15 $node1->connectTo($node2);
16
17 $node3 = new Structures_Graph_Node();
18 $graph->addNode($node3);
19 $node2->connectTo($node3);
20
21 $node3->connectTo($node1);
22
23 $this->assertFalse(
25 'Graph is cyclic'
26 );
27 }
28
29 public function testIsAcyclicTrue()
30 {
31 $graph = new Structures_Graph();
32 $node1 = new Structures_Graph_Node();
33 $graph->addNode($node1);
34
35 $node2 = new Structures_Graph_Node();
36 $graph->addNode($node2);
37 $node1->connectTo($node2);
38
39 $node3 = new Structures_Graph_Node();
40 $graph->addNode($node3);
41 $node2->connectTo($node3);
42
43 $this->assertTrue(
45 'Graph is acyclic'
46 );
47 }
48}
49?>