UndirectedAdjacencyList
public struct UndirectedAdjacencyList<
Vertex: DefaultInitializable,
Edge: DefaultInitializable,
RawId: BinaryInteger & IdIndexable
>: UndirectedAdjacencyListProtocol, SearchDefaultsGraph where RawId.Stride: SignedInteger
Undocumented
-
The name of a vertex in this graph.
Note:
VertexId‘s are not stable across some graph mutation operations.Declaration
Swift
public typealias VertexId = RawId -
The name of an edge in this graph.
Note:
EdgeId‘s are not stable across some graph mutation operations.Declaration
Swift
public typealias EdgeId = _AdjacencyList_UndirectedEdgeId<RawId> -
A collection of all
VertexId‘s inself.Declaration
Swift
public typealias VertexCollection = Range<RawId> -
Data structure storing per-edge information.
Declaration
Swift
public typealias _EdgeData = _AdjacencyList_BidirectionalPerEdge<VertexId, Edge> -
Data structure storing per-vertex data.
Declaration
Swift
public typealias _VertexData = _AdjacencyList_UndirectedPerVertex<Vertex, _EdgeData> -
The collection of all edges whose origin is a given vertex.
Declaration
Swift
public typealias VertexEdgeCollection = _AdjacencyList_UndirectedVertexEdgeCollection<_EdgeData> -
The collection of all edges in
self.Declaration
Swift
public typealias EdgeCollection = _AdjacencyList_UndirectedEdgeCollection<_Storage> -
The graph’s storage!
Declaration
Swift
public var _storage: _Storage -
Initialize an empty UndirectedAdjacencyList.
Declaration
Swift
public init() -
All
VertexId‘s inself.Declaration
Swift
public var vertices: Range<RawId> { get }
-
All edges originating from
vertex.Declaration
Swift
public func edges(from vertex: VertexId) -> VertexEdgeCollection -
The number of edges originating from
vertex.Declaration
Swift
public func outDegree(of vertex: VertexId) -> Int
-
A reasonable color map implementation.
Declaration
Swift
public typealias DefaultColorMap = TablePropertyMap<`Self`, VertexId, VertexColor> -
Makes a default color map where every vertex is set to
color.Declaration
Swift
public func makeDefaultColorMap(repeating color: VertexColor) -> DefaultColorMap -
Makes a default int map for every vertex.
Declaration
Swift
public func makeDefaultVertexIntMap(repeating value: Int) -> TablePropertyMap<`Self`, VertexId, Int> -
Makes a default vertex property map mapping vertices.
Declaration
Swift
public func makeDefaultVertexVertexMap(repeating vertex: VertexId) -> TablePropertyMap<`Self`, VertexId, VertexId>
-
Adds a new vertex with associated
vertexProperty, returning its identifier.Complexity
O(1) (amortized)Declaration
Swift
public mutating func addVertex(storing vertexProperty: Vertex) -> VertexId -
Adds a new edge from
sourcetodestinationand associatededgeProperty, returning its identifier.Complexity
O(1) (amortized)Declaration
-
Hints
selfto reserve space for a total ofvertexCountvertices.Declaration
Swift
public mutating func reserveCapacity(vertexCount: Int) -
Removes all edges from
utov.If there are parallel edges, it removes all edges.
Precondition
uandvare vertices inself.Complexity
worst case O(|E|)Declaration
Return Value
true if one or more edges were removed; false otherwise.
-
Removes
edge.Declaration
Swift
public mutating func remove(_ edge: EdgeId) -
Removes all edges that
shouldBeRemoved.Declaration
Swift
public mutating func removeEdges(where shouldBeRemoved: (EdgeId, `Self`) -> Bool) -
Remove all out edges of
vertexthat satisfy the given predicate.Complexity
O(|E|)Declaration
-
Removes all edges from
vertex.Complexity
O(|E|)Declaration
Swift
public mutating func clear(vertex: VertexId) -
Removes
vertexfrom the graph.Complexity
O(|E| + |V|)Declaration
Swift
public mutating func remove(_ vertex: VertexId)
View on GitHub
UndirectedAdjacencyList Structure Reference