graphs.minimum_spanning_tree_boruvka ==================================== .. py:module:: graphs.minimum_spanning_tree_boruvka Classes ------- .. autoapisummary:: graphs.minimum_spanning_tree_boruvka.Graph Module Contents --------------- .. py:class:: Graph Data structure to store graphs (based on adjacency lists) .. py:class:: UnionFind Disjoint set Union and Find for Boruvka's algorithm .. py:method:: __len__() .. py:method:: find(item) .. py:method:: make_set(item) .. py:method:: union(item1, item2) .. py:attribute:: parent .. py:attribute:: rank .. py:method:: __str__() Returns string representation of the graph .. py:method:: add_edge(head, tail, weight) Adds an edge to the graph .. py:method:: add_vertex(vertex) Adds a vertex to the graph .. py:method:: boruvka_mst(graph) :staticmethod: Implementation of Boruvka's algorithm >>> g = Graph() >>> g = Graph.build([0, 1, 2, 3], [[0, 1, 1], [0, 2, 1],[2, 3, 1]]) >>> g.distinct_weight() >>> bg = Graph.boruvka_mst(g) >>> print(bg) 1 -> 0 == 1 2 -> 0 == 2 0 -> 1 == 1 0 -> 2 == 2 3 -> 2 == 3 2 -> 3 == 3 .. py:method:: build(vertices=None, edges=None) :staticmethod: Builds a graph from the given set of vertices and edges .. py:method:: distinct_weight() For Boruvks's algorithm the weights should be distinct Converts the weights to be distinct .. py:method:: get_edges() Returna all edges in the graph .. py:method:: get_vertices() Returns all vertices in the graph .. py:attribute:: adjacency .. py:attribute:: num_edges :value: 0 .. py:attribute:: num_vertices :value: 0