PHP Trait Gliph\Graph\AdjacencyList
Adjacency lists store vertices directly, and edges relative to the vertices
they connect. That means there is no overall list of edges in the graph; only
a list of the graph's vertices. In this implementation, that list is keyed by
vertex, with the value being a list of all the vertices to which that vertex
is adjacent - hence, "adjacency list."
Consequently, this structure offers highly efficient access to vertices, but
less efficient access to edges.
In an undirected graph, the edges are stored in both vertices' adjacency
lists. In a directed graph, only the out-edges are stored in each vertex's
adjacency list. This makes accessing in-edge information in a directed graph
highly inefficient.
Exibir arquivo
Open project: sdboyer/gliph
Protected Properties
Property |
Type |
Description |
|
$size |
integer |
We keep track because calculating it on demand is expensive. |
|
$vertices |
SplObjectStorage |
Contains the adjacency list of vertices. |
|
$walking |
SplObjectStorage |
Bookkeeper for nested iteration. |
|
Public Methods
Protected Methods
Method |
Description |
|
getTraversableSplos ( SplObjectStorage $splos ) : SplObjectStorage |
Helper function to ensure SPLOS traversal pointer is not overridden. |
|
Method Details
__construct()
public method
ensureVertex()
public method
getTraversableSplos()
protected method
This would otherwise occur if nested calls are made that traverse the
same SPLOS. This keeps track of which SPLOSes are currently being
traversed, and if it's in use, it returns a clone.
It is incumbent on the calling code to release the semaphore directly
by calling $this->walking->detach($splos) when the traversal in
question is complete. (This is very important!)
protected getTraversableSplos ( SplObjectStorage $splos ) : SplObjectStorage |
$splos |
SplObjectStorage |
The SPLOS to traverse. |
return |
SplObjectStorage |
A SPLOS that is safe for traversal; may or may not be a clone of the
original. |
hasVertex()
public method
Property Details
$size protected_oe property
We keep track because calculating it on demand is expensive.
$vertices protected_oe property
Contains the adjacency list of vertices.
protected SplObjectStorage $vertices |
return |
SplObjectStorage |
|
$walking protected_oe property
Bookkeeper for nested iteration.
protected SplObjectStorage $walking |
return |
SplObjectStorage |
|