Skip to content
Snippets Groups Projects
Commit a6b0eba5 authored by inso's avatar inso
Browse files

Fix graph scene arrows

parent 574bc768
Branches
Tags
No related merge requests found
...@@ -73,7 +73,7 @@ class ExplorerScene(BaseScene): ...@@ -73,7 +73,7 @@ class ExplorerScene(BaseScene):
while queue: while queue:
n = queue.pop() n = queue.pop()
nsteps = data[n]['scenter'] + 1 nsteps = data[n]['scenter'] + 1
for edge in networkx.edges(nx_graph, n): for edge in networkx.edges(nx_graph.to_undirected(), n):
next_node = edge[0] if edge[0] is not n else edge[1] next_node = edge[0] if edge[0] is not n else edge[1]
if data[next_node]['sparent']: if data[next_node]['sparent']:
continue continue
...@@ -128,7 +128,7 @@ class ExplorerScene(BaseScene): ...@@ -128,7 +128,7 @@ class ExplorerScene(BaseScene):
:param str current: the current node which we compute the subtree :param str current: the current node which we compute the subtree
""" """
ratio = data[current]['span'] / data[current]['stsize'] ratio = data[current]['span'] / data[current]['stsize']
for edge in nx_graph.edges(current): for edge in nx_graph.to_undirected().edges(current):
next_node = edge[0] if edge[0] != current else edge[1] next_node = edge[0] if edge[0] != current else edge[1]
if data[next_node]['sparent'] != current: if data[next_node]['sparent'] != current:
continue continue
...@@ -152,7 +152,7 @@ class ExplorerScene(BaseScene): ...@@ -152,7 +152,7 @@ class ExplorerScene(BaseScene):
else: else:
theta = data[current]['theta'] - data[current]['span'] / 2 theta = data[current]['theta'] - data[current]['span'] / 2
for edge in nx_graph.edges(current): for edge in nx_graph.to_undirected().edges(current):
next_node = edge[0] if edge[0] != current else edge[1] next_node = edge[0] if edge[0] != current else edge[1]
if data[next_node]['sparent'] != current: if data[next_node]['sparent'] != current:
continue continue
...@@ -179,7 +179,7 @@ class ExplorerScene(BaseScene): ...@@ -179,7 +179,7 @@ class ExplorerScene(BaseScene):
if len(nx_graph.nodes()) == 1: if len(nx_graph.nodes()) == 1:
return {nx_graph.nodes()[0]: (0, 0)} return {nx_graph.nodes()[0]: (0, 0)}
nx_graph = nx_graph.to_undirected() #nx_graph = nx_graph.to_undirected()
data = ExplorerScene._init_layout(nx_graph) data = ExplorerScene._init_layout(nx_graph)
if not center: if not center:
...@@ -191,7 +191,7 @@ class ExplorerScene(BaseScene): ...@@ -191,7 +191,7 @@ class ExplorerScene(BaseScene):
data[center]['theta'] = 0.0 data[center]['theta'] = 0.0
ExplorerScene._set_positions(nx_graph, data, center) ExplorerScene._set_positions(nx_graph, data, center)
distances = networkx.shortest_path_length(nx_graph, center) distances = networkx.shortest_path_length(nx_graph.to_undirected(), center)
nx_pos = {} nx_pos = {}
for node in nx_graph.nodes(): for node in nx_graph.nodes():
hyp = distances[node] + 1 hyp = distances[node] + 1
...@@ -266,7 +266,7 @@ class ExplorerScene(BaseScene): ...@@ -266,7 +266,7 @@ class ExplorerScene(BaseScene):
for edge in nx_graph.edges(data=True): for edge in nx_graph.edges(data=True):
edge[2]["confirmation_text"] = "" edge[2]["confirmation_text"] = ""
if (edge[0], edge[1]) not in self.edges and (edge[1], edge[0]) not in self.edges: if (edge[0], edge[1]) not in self.edges:
distance = max(self.nodes[edge[0]].steps, self.nodes[edge[1]].steps) distance = max(self.nodes[edge[0]].steps, self.nodes[edge[1]].steps)
explorer_edge = ExplorerEdge(edge[0], edge[1], edge[2], graph_pos, distance, dist_max) explorer_edge = ExplorerEdge(edge[0], edge[1], edge[2], graph_pos, distance, dist_max)
self.node_moved.connect(explorer_edge.move_source_point) self.node_moved.connect(explorer_edge.move_source_point)
...@@ -283,8 +283,16 @@ class ExplorerScene(BaseScene): ...@@ -283,8 +283,16 @@ class ExplorerScene(BaseScene):
for node in self.nodes.values(): for node in self.nodes.values():
node.neutralize() node.neutralize()
path = []
try:
path = networkx.shortest_path(self.nx_graph, node_id, self.identity.pubkey)
except (networkx.exception.NetworkXError, networkx.exception.NetworkXNoPath) as e:
logging.debug(str(e))
try: try:
path = networkx.shortest_path(self.nx_graph.to_undirected(), self.identity.pubkey, node_id) path = networkx.shortest_path(self.nx_graph, self.identity.pubkey, node_id)
except (networkx.exception.NetworkXError, networkx.exception.NetworkXNoPath) as e:
logging.debug(str(e))
for node, next_node in zip(path[:-1], path[1:]): for node, next_node in zip(path[:-1], path[1:]):
if (node, next_node) in self.edges: if (node, next_node) in self.edges:
...@@ -296,5 +304,3 @@ class ExplorerScene(BaseScene): ...@@ -296,5 +304,3 @@ class ExplorerScene(BaseScene):
self.nodes[node].highlight() self.nodes[node].highlight()
self.nodes[next_node].highlight() self.nodes[next_node].highlight()
logging.debug("Update edge between {0} and {1}".format(node, next_node)) logging.debug("Update edge between {0} and {1}".format(node, next_node))
except (networkx.exception.NetworkXError, networkx.exception.NetworkXNoPath) as e:
logging.debug(str(e))
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment