TransposeGraph
public struct TransposeGraph<Underlying> : BidirectionalGraph where Underlying : BidirectionalGraph
extension TransposeGraph: VertexListGraph where Underlying: VertexListGraph
extension TransposeGraph: EdgeListGraph where Underlying: EdgeListGraph
extension TransposeGraph: PropertyGraph where Underlying: PropertyGraph
extension TransposeGraph: SearchDefaultsGraph where Underlying: SearchDefaultsGraph
Transposes an underlying graph.
The transpose of a graph of the same number of vertices, but where the source and destination of
every edge is reversed. TransposeGraph
adapts a graph in constant space and constant time to
operate as its transpose.
To continue to use property maps with the new graph, simply wrap them in
TransposeGraphPropertyMapAdapter
.
Note: the VerteId’s and EdgeId’s from the original graph are preserved, which ensures property maps continue to function.
All operations on a TransposeGraph
operate with identical complexity as the underlying graph.
-
Creates a graph that is a transpose of
underlying
.Declaration
Swift
public init(_ underlying: Underlying)
-
The name of a vertex in
self
.Declaration
Swift
public typealias VertexId = Underlying.VertexId
-
The name of an edge in
self
.Declaration
Swift
public typealias EdgeId = Underlying.EdgeId
-
Returns the collection of edges whose source is vertex.
Declaration
Swift
public func edges(from vertex: VertexId) -> Underlying.VertexInEdgeCollection
-
Returns the source of
edge
. -
Returns the destination of
edge
. -
Returns the number of edges whose source is
vertex
.Declaration
Swift
public func outDegree(of vertex: VertexId) -> Int
-
Returns the collection of edges whose destination is
vertex
.Declaration
Swift
public func edges(to vertex: VertexId) -> Underlying.VertexEdgeCollection
-
Returns the number of “in-edges” of
vertex
.Declaration
Swift
public func inDegree(of vertex: VertexId) -> Int
-
Returns the number of “in-edges” plus “out-edges” of
vertex
inself
.Declaration
Swift
public func degree(of vertex: VertexId) -> Int
-
Declaration
Swift
public var vertices: Underlying.VertexCollection { get }
-
Declaration
Swift
public var vertexCount: Int { get }
-
Declaration
Swift
public var edgeCount: Int { get }
-
Declaration
Swift
public var edges: Underlying.EdgeCollection { get }
-
Makes a default color map where every vertex is set to
color
.Declaration
Swift
public func makeDefaultColorMap(repeating color: VertexColor) -> TransposeGraphPropertyMapAdapter<Underlying.DefaultColorMap>
-
Makes a default int map for every vertex.
Declaration
Swift
public func makeDefaultVertexIntMap(repeating value: Int) -> TransposeGraphPropertyMapAdapter<Underlying.DefaultVertexIntMap>
-
Makes a default vertex property map mapping vertices.
Declaration
Swift
public func makeDefaultVertexVertexMap(repeating vertex: VertexId) -> TransposeGraphPropertyMapAdapter<Underlying.DefaultVertexVertexMap>