Classes
The following classes are available globally.
-
Unweighted Adjacency list.
Stores a graph as a dictionary of vertices with an array of directly adjacent vertices. More memory efficient than adjacency matrices, but determining direct adjacency takes more time.
Includes basic functionality, but cannot be used as a graph because it does not know whether or not it’s directed. Directed and Undirected AList inherit from this class.
See moreDeclaration
Swift
public class AdjacencyList<Vertex: Hashable>
-
An undirected graph implemented as an adjacency list. Edges are symmetric, meaning v is adjacent to u iff u is adjacent to v.
In implementation, this means that if u is in v’s neighbor array, v must also be in u’s neighbor array, for any two vertices.
See moreDeclaration
Swift
public class UndirectedAList<Vertex: Hashable>: AdjacencyList<Vertex>, UndirectedGraph
-
Directed adjacency list. When using this class, source is different from destination vertex in an edge.
In other words, if u is in v’s neighbor array, v may not be in u’s unless the antiparallel edge exists in the graph.
See moreDeclaration
Swift
public class DirectedAList<Vertex: Hashable>: AdjacencyList<Vertex>, DirectedGraph
-
Implementation of a weighted undirected graph using an adjacency list.
The weights are stored separately from the edges, in a dictionary of dictionaries. Weights are Doubles.
See moreDeclaration
Swift
final public class WeightedUndirectedAList<Vertex: Hashable> : AdjacencyList<Vertex>, WeightedUndirectedGraph
-
A weighted directed Adjacency List implementation of weighted, directed graphs. Similar to the WeightedUndirected adjacency list, but with asymmetric edges.
Weights are stored separately from edges, in a nested dictionary of type [Vertex: [Vertex: Double]].
See moreDeclaration
Swift
final public class WeightedDirectedAList<Vertex: Hashable> : AdjacencyList<Vertex>, WeightedDirectedGraph
-
Adjacency matrices for general graphs.
The
See moreAdjacencyMatrix
class is only capable of keeping track of the size and shape of the matrix. To use adjacency matrices as graphs, use its subclasses, UndirectedAMatrix and DirectedAMatrix.Declaration
Swift
public class AdjacencyMatrix<Vertex: Hashable>
-
Adjacency matrices for undirected graphs.
See moreDeclaration
Swift
final public class UndirectedAMatrix<Vertex: Hashable>: AdjacencyMatrix<Vertex>, UndirectedGraph
-
Adjacency matrices for directed graphs.
See moreDeclaration
Swift
final public class DirectedAMatrix<Vertex: Hashable>: AdjacencyMatrix<Vertex>, DirectedGraph