Module dsa.prim
Module to access functions for Prim's Algorithm.
Functions
def mst_weight(graph) ‑> int
-
Returns the total weight of a graph given a starting vertex
Args
graph
- The graph to find the total edge weight of.
Returns
int
- The total weight of the graph.
def prims_mst(graph, start: str, mst_graph=None) ‑> AdjacencyListWeightedGraph
-
Returns an MST given a graph and starting vertex. (Future: return a Tree type instead of a Graph type)
Args
graph
- The graph to search an MST from. (can be either an AdjacencyListWeightedGraph or AdjacencyMatrixWeightedGraph)
start
:string
- The starting vertex label.
mst_graph
- An empty graph object to output the MST in to.
Returns
AdjacencyListWeightedGraph
- the MST of the graph.