W3cubDocs

/Drupal 8

public function Graph::__construct

public Graph::__construct($graph)

Instantiates the depth first search object.

Parameters

$graph: A three dimensional associated array, with the first keys being the names of the vertices, these can be strings or numbers. The second key is 'edges' and the third one are again vertices, each such key representing an edge. Values of array elements are copied over.

Example:

    $graph[1]['edges'][2] = 1;
    $graph[2]['edges'][3] = 1;
    $graph[2]['edges'][4] = 1;
    $graph[3]['edges'][4] = 1;
  

On return you will also have:

    $graph[1]['paths'][2] = 1;
    $graph[1]['paths'][3] = 1;
    $graph[2]['reverse_paths'][1] = 1;
    $graph[3]['reverse_paths'][1] = 1;
  

File

core/lib/Drupal/Component/Graph/Graph.php, line 40

Class

Graph
Directed acyclic graph manipulation.

Namespace

Drupal\Component\Graph

Code

public function __construct($graph) {
  $this->graph = $graph;
}

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!lib!Drupal!Component!Graph!Graph.php/function/Graph::__construct/8.1.x