function GraphUnitTest::normalizeGraph

Return a normalized version of a graph.

1 call to GraphUnitTest::normalizeGraph()
GraphUnitTest::testDepthFirstSearch in drupal/core/modules/system/lib/Drupal/system/Tests/Graph/GraphUnitTest.php
Test depth-first-search features.

File

drupal/core/modules/system/lib/Drupal/system/Tests/Graph/GraphUnitTest.php, line 96
Definition of Drupal\system\Tests\Graph\GraphUnitTest.

Class

GraphUnitTest
Unit tests for the graph handling features.

Namespace

Drupal\system\Tests\Graph

Code

function normalizeGraph($graph) {
  $normalized_graph = array();
  foreach ($graph as $vertex => $edges) {

    // Create vertex even if it hasn't any edges.
    $normalized_graph[$vertex] = array();
    foreach ($edges as $edge) {
      $normalized_graph[$vertex]['edges'][$edge] = TRUE;
    }
  }
  return $normalized_graph;
}