def __init__(self, connectivity, weighted=False): """Connectivity describes which tables have foreign keys into which other tables.""" if weighted: graph = WGraph(connectivity) else: graph = Graph(connectivity) self.graph = graph glen = len(self.graph) self._mst = [[]] * glen self.undirected_graph = graph.get_undirected() self._spanning = [] self.weighted = weighted # traversing graph # get spanning path of BFS from this node # self._spannning stores those path for node_index in range(0, glen): span = self.undirected_graph.breadth_first_search(node_index) self._spanning.append(span) if weighted: for index in range(0, glen): mst = prim(self.undirected_graph._graph, range(glen), index) self._mst[index] = UWGraph(mst, index) self.undirected_graph.gen_dist_matrix()