def recompute_layout_from_view(self, widget): ual = self.micavis.unique_addresses namemap = dict((n,i) for i,n in enumerate(ual)) graph = igraph.Graph(directed=True) n = len(ual) graph.add_vertices(n) matrix = [ [0] * n for i in xrange(n) ] for addr in ual: view = self.micavis.current_node_view[addr] for peer, weight in view.iteritems(): matrix[namemap[addr]][namemap[peer]] = weight edges = list(logs.matrix_edge_generator(matrix)) graph.add_edges(edges) self.micavis.set_layout(graph, namemap)
def create_default_graph(self): if self.options['novis']: return None, None ual = self.unique_addresses g = igraph.Graph(directed=True) g.add_vertices(len(ual)) namemap = dict((n,i) for i,n in enumerate(ual)) matrix = logs.build_comm_matrix(ual,self.events) if matrix is None: # fall back to initial state view graph matrix = logs.build_final_view_matrix(ual,self.events, self.current_node_view) edges = list(logs.matrix_edge_generator(matrix)) g.add_edges(edges) return g, namemap