/**
  * checks whether walk is hamiltonian (i.e. walk over ALL VERTICES of the graph)
  *
  * A hamiltonian Walk is also known as a spanning walk.
  *
  * @return boolean
  * @see self::isEulerian() if you want to check for all EDGES instead of VERTICES
  * @uses self::isArrayContentsEqual()
  * @link http://en.wikipedia.org/wiki/Hamiltonian_path
  */
 public function isHamiltonian()
 {
     $vertices = $this->walk->getVertices()->getVector();
     // ignore starting vertex for cycles as it's always the same as ending vertex
     if ($this->isCycle()) {
         unset($vertices[0]);
     }
     return $this->isArrayContentsEqual($vertices, $this->walk->getGraph()->getVertices()->getVector());
 }
Exemple #2
0
 /**
  * @param Walk $walk
  * @depends testWalkPath
  */
 public function testWalkPathInvalidateByDestroyingVertex(Walk $walk)
 {
     // delete v3
     $walk->getVertices()->getVertexLast()->destroy();
     $this->assertFalse($walk->isValid());
 }