graphs.minimum_spanning_tree_kruskal

Attributes

edges

Functions

kruskal(→ list[tuple[int, int, int]])

Module Contents

graphs.minimum_spanning_tree_kruskal.kruskal(num_nodes: int, edges: list[tuple[int, int, int]]) list[tuple[int, int, int]]
>>> kruskal(4, [(0, 1, 3), (1, 2, 5), (2, 3, 1)])
[(2, 3, 1), (0, 1, 3), (1, 2, 5)]
>>> kruskal(4, [(0, 1, 3), (1, 2, 5), (2, 3, 1), (0, 2, 1), (0, 3, 2)])
[(2, 3, 1), (0, 2, 1), (0, 1, 3)]
>>> kruskal(4, [(0, 1, 3), (1, 2, 5), (2, 3, 1), (0, 2, 1), (0, 3, 2),
... (2, 1, 1)])
[(2, 3, 1), (0, 2, 1), (2, 1, 1)]
graphs.minimum_spanning_tree_kruskal.edges = []