UnweightedGraph
open class UnweightedGraph<V> : Graph where V : Decodable, V : Encodable, V : Equatable
An implementation of Graph with some convenience methods for adding and removing UnweightedEdges. WeightedEdges may be added to an UnweightedGraph but their weights will be ignored.
-
Undocumented
Declaration
Swift
public var vertices: [V]
-
Undocumented
Declaration
Swift
public var edges: [[UnweightedEdge]]
-
Undocumented
Declaration
Swift
public init()
-
Undocumented
Declaration
Swift
required public init(vertices: [V])
-
Add an edge to the graph.
Declaration
Swift
public func addEdge(_ e: UnweightedEdge, directed: Bool)
Parameters
e
The edge to add.
directed
If false, undirected edges are created. If true, a reversed edge is also created. Default is false.
-
Add a vertex to the graph.
Declaration
Swift
public func addVertex(_ v: V) -> Int
Parameters
v
The vertex to be added.
Return Value
The index where the vertex was added.