protected function GraphTest::normalizeGraph in Drupal 10
Same name and namespace in other branches
- 8 core/tests/Drupal/Tests/Component/Graph/GraphTest.php \Drupal\Tests\Component\Graph\GraphTest::normalizeGraph()
- 9 core/tests/Drupal/Tests/Component/Graph/GraphTest.php \Drupal\Tests\Component\Graph\GraphTest::normalizeGraph()
Normalizes a graph.
Parameters
$graph: A graph array processed by \Drupal\Component\Graph\Graph::searchAndSort()
Return value
array The normalized version of a graph.
1 call to GraphTest::normalizeGraph()
- GraphTest::testDepthFirstSearch in core/
tests/ Drupal/ Tests/ Component/ Graph/ GraphTest.php - Tests depth-first-search features.
File
- core/
tests/ Drupal/ Tests/ Component/ Graph/ GraphTest.php, line 91
Class
- GraphTest
- @coversDefaultClass \Drupal\Component\Graph\Graph @group Graph
Namespace
Drupal\Tests\Component\GraphCode
protected function normalizeGraph($graph) {
$normalized_graph = [];
foreach ($graph as $vertex => $edges) {
// Create vertex even if it hasn't any edges.
$normalized_graph[$vertex] = [];
foreach ($edges as $edge) {
$normalized_graph[$vertex]['edges'][$edge] = TRUE;
}
}
return $normalized_graph;
}