Example #1
0
 public function get_vertex_provider()
 {
     $graph = new Graph\DirectedGraph();
     $vertex_a = new Vertex('A');
     $vertex_b = new Vertex('B');
     $vertex_c = new Vertex('C');
     $graph->add_vertex($vertex_a);
     $graph->add_vertex($vertex_b);
     $graph->add_vertex($vertex_c);
     return array(array($graph, 'A', $vertex_a, "Expects to have vertex 'A'"), array($graph, 'B', $vertex_b, "Expects to have vertex 'B'"), array($graph, 'C', $vertex_c, "Expects to have vertex 'C'"), array($graph, 'D', null, "Does not expect to have vertex 'D'"));
 }
 /**
  * @param Vertex $start
  * @param Edge\DirectedEdge $edge
  */
 protected function simple_path_recursive(Vertex $start, Edge\DirectedEdge $edge)
 {
     /**
      * We don't want to visit the same edge twice within a single path.
      * I.E. No loops in a single simple path.
      */
     if (in_array($edge, $this->current_path)) {
         return;
     } else {
         $this->current_path[] = $edge;
     }
     if ($start->outgoing_edges->count() == 0) {
         $this->simple_paths[] = $this->current_path;
         return;
     }
     /**
      * @var $edge Edge\DirectedEdge
      */
     foreach ($this->digraph->get_outgoing_edges_of($start) as $edge) {
         $this->simple_path_recursive($edge->get_target(), $edge);
         array_pop($this->current_path);
     }
 }