setStartingVertex() public method

Sets the vertex which we are starting from to calculate the shortest path.
public setStartingVertex ( Doctrine\OrientDB\Graph\VertexInterface $vertex )
$vertex Doctrine\OrientDB\Graph\VertexInterface
Esempio n. 1
0
 /**
  * @see http://it.wikipedia.org/wiki/File:Ricerca_operativa_percorso_minimo_09.gif
  */
 public function testWikipediaExample()
 {
     $graph = new Graph();
     $home = new Vertex('home');
     $a = new Vertex('a');
     $b = new Vertex('b');
     $c = new Vertex('c');
     $d = new Vertex('d');
     $e = new Vertex('e');
     $office = new Vertex('office');
     $graph->add($home);
     $graph->add($a);
     $graph->add($b);
     $graph->add($c);
     $graph->add($d);
     $graph->add($e);
     $graph->add($office);
     $home->connect($a, 2);
     $home->connect($d, 8);
     $a->connect($b, 6);
     $a->connect($c, 2);
     $b->connect($office, 5);
     $c->connect($d, 2);
     $c->connect($e, 9);
     $d->connect($e, 3);
     $e->connect($office);
     $algorithm = new Dijkstra($graph);
     $algorithm->setStartingVertex($home);
     $algorithm->setEndingVertex($office);
     $this->assertEquals(array($home, $a, $c, $d, $e, $office), $algorithm->solve());
 }