SymmetricTest.php 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. <?php
  2. use Graphp\Algorithms\Symmetric as AlgorithmSymmetric;
  3. use Fhaculty\Graph\Graph;
  4. class SymmetricTest extends TestCase
  5. {
  6. public function testGraphEmpty()
  7. {
  8. $graph = new Graph();
  9. $alg = new AlgorithmSymmetric($graph);
  10. $this->assertTrue($alg->isSymmetric());
  11. }
  12. public function testGraphIsolated()
  13. {
  14. $graph = new Graph();
  15. $graph->createVertex(1);
  16. $graph->createVertex(2);
  17. $alg = new AlgorithmSymmetric($graph);
  18. $this->assertTrue($alg->isSymmetric());
  19. }
  20. public function testGraphSingleArcIsNotSymmetricr()
  21. {
  22. // 1 -> 2
  23. $graph = new Graph();
  24. $graph->createVertex(1)->createEdgeTo($graph->createVertex(2));
  25. $alg = new AlgorithmSymmetric($graph);
  26. $this->assertFalse($alg->isSymmetric());
  27. }
  28. public function testGraphAntiparallelIsSymmetricr()
  29. {
  30. // 1 -> 2 -> 1
  31. $graph = new Graph();
  32. $graph->createVertex(1)->createEdgeTo($graph->createVertex(2));
  33. $graph->getVertex(2)->createEdgeTo($graph->getVertex(1));
  34. $alg = new AlgorithmSymmetric($graph);
  35. $this->assertTrue($alg->isSymmetric());
  36. }
  37. public function testGraphSingleUndirectedIsSymmetricr()
  38. {
  39. // 1 -- 2
  40. $graph = new Graph();
  41. $graph->createVertex(1)->createEdge($graph->createVertex(2));
  42. $alg = new AlgorithmSymmetric($graph);
  43. $this->assertTrue($alg->isSymmetric());
  44. }
  45. }