PHP Трейт 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.
Показать файл
Открыть проект
Защищенные свойства (Protected)
Свойство |
Тип |
Описание |
|
$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. |
|
Открытые методы
Защищенные методы
Метод |
Описание |
|
getTraversableSplos ( SplObjectStorage $splos ) : SplObjectStorage |
Helper function to ensure SPLOS traversal pointer is not overridden. |
|
Описание методов
__construct()
публичный Метод
ensureVertex()
публичный Метод
getTraversableSplos()
защищенный Метод
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. |
Результат |
SplObjectStorage |
A SPLOS that is safe for traversal; may or may not be a clone of the
original. |
hasVertex()
публичный Метод
vertices()
публичный Метод
Описание свойств
$size защищенное свойство
We keep track because calculating it on demand is expensive.
protected int $size |
Результат |
integer |
|
$vertices защищенное свойство
Contains the adjacency list of vertices.
protected SplObjectStorage $vertices |
Результат |
SplObjectStorage |
|
$walking защищенное свойство
Bookkeeper for nested iteration.
protected SplObjectStorage $walking |
Результат |
SplObjectStorage |
|