Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
drupal
Manage
Activity
Members
Labels
Plan
Wiki
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
project
drupal
Merge requests
!11606
Issue
#3200162
: Improve documentation for Graph component
Code
Review changes
Check out branch
Download
Patches
Plain diff
Closed
Issue
#3200162
: Improve documentation for Graph component
issue/drupal-3200162:3200162-new-docs-update
into
11.x
Overview
0
Commits
2
Pipelines
2
Changes
1
Closed
Brandon Lira
requested to merge
issue/drupal-3200162:3200162-new-docs-update
into
11.x
1 month ago
Overview
0
Commits
2
Pipelines
2
Changes
1
Expand
Closes
#3200162
0
0
Merge request reports
Compare
11.x
version 1
68d762d8
1 month ago
11.x (base)
and
latest version
latest version
5931f95e
2 commits,
1 month ago
version 1
68d762d8
1 commit,
1 month ago
1 file
+
25
−
21
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
core/lib/Drupal/Component/Graph/Graph.php
+
25
−
21
Options
@@ -4,6 +4,25 @@
/**
* Directed acyclic graph manipulation.
*
* This class represents a directed acyclic graph (DAG) and provides methods
* for processing and sorting it.
*
* Example of a graph structure:
* @code
* 1────►2────►3
* │ │
* │ ▼
* └───► 4
* @endcode
*
* Example of defining a graph in PHP:
* @code
* $graph[1]['edges'][2] = 1;
* $graph[2]['edges'][3] = 1;
* $graph[2]['edges'][4] = 1;
* $graph[3]['edges'][4] = 1;
* @endcode
*/
class
Graph
{
@@ -15,29 +34,14 @@ class Graph {
protected
$graph
;
/**
* Instantiates the d
epth first searc
h object.
* Instantiates the d
irected acyclic grap
h object.
*
* @param array $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:
* @code
* $graph[1]['edges'][2] = 1;
* $graph[2]['edges'][3] = 1;
* $graph[2]['edges'][4] = 1;
* $graph[3]['edges'][4] = 1;
* @endcode
*
* On return you will also have:
* @code
* $graph[1]['paths'][2] = 1;
* $graph[1]['paths'][3] = 1;
* $graph[2]['reverse_paths'][1] = 1;
* $graph[3]['reverse_paths'][1] = 1;
* @endcode
* A three-dimensional associative array, with the first keys being the
* names of the vertices, which can be strings or numbers. The second key is
* 'edges', whose value is an array keyed by the names of the vertices
* connected to it; the values in this array can be simply TRUE or may
* contain other data.
*/
public
function
__construct
(
$graph
)
{
$this
->
graph
=
$graph
;
Loading