Adjacency List Implementation Internals
-
A general purpose adjacency list graph.
Adjacency list representations of graphs are flexible and common. This protocol abstracts over the specific underlying storage of the data structure, and implements a variety of graph APIs on top of the basic storage:
VertexListGraph
EdgeListGraph
IncidenceGraph
MutableGraph
(implied byMutablePropertyGraph
)PropertyGraph
(implied byMutablePropertyGraph
)
And can additionally conform to:
Types conforming to
AdjacencyList
can implement directed, bidirectional, or undirected graphs.AdjacencyList types allow storing arbitrary additional data with each vertex and edge. If you select a zero-sized type (such as
Empty
), all overhead is optimized away by the Swift compiler.Note: because tuples cannot yet conform to protocols, we have to use a separate type instead of
Void
.AdjacencyList is parameterized by the
RawId
which can be carefully tuned to save memory. A good default isUInt32
, unless you are trying to represent more than 2^31 vertices.See also
DirectedAdjacencyList
See also
BidirectionalAdjacencyList
See also
UndirectedAdjacencyList
Declaration
Swift
public protocol AdjacencyListProtocol: VertexListGraph, EdgeListGraph, IncidenceGraph, MutablePropertyGraph, DefaultInitializable where VertexCollection == Range<RawId>
-
Data associated with each edge in an
See moreAdjacencyList
.Declaration
Swift
public protocol _AdjacencyListPerEdge
-
Data associated with each vertex in an
See moreAdjacencyList
.Declaration
Swift
public protocol _AdjacencyListPerVertex
-
Declaration
Swift
public struct _AdjacencyList_DirectedEdgeId<RawId> : Equatable, Hashable, Comparable where RawId : BinaryInteger
extension _AdjacencyList_DirectedEdgeId: CustomStringConvertible
-
Adjacency lists whose edges are directed.
See moreDeclaration
Swift
public protocol DirectedAdjacencyListProtocol: AdjacencyListProtocol, ParallelGraph where VertexEdgeCollection == _AdjacencyList_DirectedVertexEdgeCollection<_EdgeData>, ParallelProjection == _DirectedAdjacencyList_ParallelProjection<_VertexData>, EdgeCollection == _AdjacencyList_DirectedEdgeCollection<_Storage>
-
Undocumented
See moreDeclaration
Swift
public protocol UndirectedAdjacencyListProtocol: AdjacencyListProtocol where VertexEdgeCollection == _AdjacencyList_UndirectedVertexEdgeCollection<_EdgeData>, EdgeCollection == _AdjacencyList_UndirectedEdgeCollection<_Storage>, _VertexData: _AdjacencyListPerVertexUndirected
-
Augments
See more_AdjacencyListPerEdge
by adding reverse-edge information.Declaration
Swift
public protocol _AdjacencyListPerEdgeBidirectional : _AdjacencyListPerEdge
-
Augments
See more_AdjacencyListPerVertex
with reverse edge information.Declaration
Swift
public protocol _AdjacencyListPerVertexBidirectional: _AdjacencyListPerVertex where EdgeData: _AdjacencyListPerEdgeBidirectional
-
All internal information stored within a bidirectional graph for each edge.
See moreDeclaration
Swift
public struct _AdjacencyList_BidirectionalPerEdge< RawId: BinaryInteger, Edge: DefaultInitializable >: _AdjacencyListPerEdgeBidirectional
-
Undocumented
See moreDeclaration
Swift
public struct _AdjacencyList_BidirectionalPerVertex< Vertex: DefaultInitializable, EdgeData: _AdjacencyListPerEdgeBidirectional >: _AdjacencyListPerVertexBidirectional
-
Undocumented
See moreDeclaration
Swift
public protocol _AdjacencyListPerVertexUndirected: _AdjacencyListPerVertex where EdgeData: _AdjacencyListPerEdgeBidirectional
-
A collection of all edges in an
See moreAdjacencyList
.Declaration
Swift
public struct _AdjacencyList_DirectedEdgeCollection<Storage: Collection>: Collection where Storage.Element: _AdjacencyListPerVertex, Storage.Index == Int
-
Stores all relevant information for an edge within a directed adjacency list.
See moreDeclaration
Swift
public struct _AdjacencyList_DirectedPerEdge<VertexId, Edge> : _AdjacencyListPerEdge where VertexId : BinaryInteger
-
Stores all relevant information for a vertex within a directed adjacency list.
See moreDeclaration
Swift
public struct _AdjacencyList_DirectedPerVertex<Vertex, EdgeData> : _AdjacencyListPerVertex where EdgeData : _AdjacencyListPerEdge
-
All edges from a single vertex in an AdjacencyList graph.
See moreDeclaration
Swift
public struct _AdjacencyList_DirectedVertexEdgeCollection<EdgeData> : Collection where EdgeData : _AdjacencyListPerEdge
-
Undocumented
See moreDeclaration
Swift
public struct _AdjacencyList_UndirectedEdgeCollection<Storage: Collection>: Collection where Storage.Element: _AdjacencyListPerVertex, Storage.Index == Int
-
Declaration
Swift
public struct _AdjacencyList_UndirectedEdgeId<RawId> where RawId : BinaryInteger
extension _AdjacencyList_UndirectedEdgeId: Equatable, Hashable, Comparable
-
Undocumented
See moreDeclaration
Swift
public struct _AdjacencyList_UndirectedPerVertex< Vertex: DefaultInitializable, EdgeData: _AdjacencyListPerEdgeBidirectional >: _AdjacencyListPerVertexUndirected
-
Undocumented
See moreDeclaration
Swift
public struct _AdjacencyList_UndirectedVertexEdgeCollection< EdgeData: _AdjacencyListPerEdgeBidirectional >: Collection
-
A parallel representation of a
See moreDirectedAdjacencyList
.Declaration
Swift
public struct _DirectedAdjacencyList_ParallelProjection<PerVertex: _AdjacencyListPerVertex>: GraphProtocol, IncidenceGraph, PropertyGraph