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

Fix shortest path in informations window (#378)

parent 359edf9e
Branches
Tags
No related merge requests found
...@@ -55,7 +55,7 @@ class WoTGraph(BaseGraph): ...@@ -55,7 +55,7 @@ class WoTGraph(BaseGraph):
# calculate path of nodes between identity and to_identity # calculate path of nodes between identity and to_identity
try: try:
path = networkx.shortest_path(self.nx_graph, account_identity.pubkey, to_identity.pubkey) path = networkx.shortest_path(self.nx_graph.to_undirected(), account_identity.pubkey, to_identity.pubkey)
except networkx.NetworkXNoPath as e: except networkx.NetworkXNoPath as e:
logging.debug(str(e)) logging.debug(str(e))
......
...@@ -106,6 +106,7 @@ class MemberDialog(QObject): ...@@ -106,6 +106,7 @@ class MemberDialog(QObject):
account_identity = await self.account.identity(self.community) account_identity = await self.account.identity(self.community)
path = await graph.get_shortest_path_to_identity(self.identity, path = await graph.get_shortest_path_to_identity(self.identity,
account_identity) account_identity)
nodes = graph.nx_graph.nodes(data=True)
if path: if path:
distance = len(path) - 1 distance = len(path) - 1
...@@ -114,20 +115,17 @@ class MemberDialog(QObject): ...@@ -114,20 +115,17 @@ class MemberDialog(QObject):
.format(self.tr('Distance'), distance)) .format(self.tr('Distance'), distance))
if distance > 1: if distance > 1:
index = 0 index = 0
for node in path: for node_id in path:
node = [n for n in nodes if n[0] == node_id][0]
if index == 0: if index == 0:
text += self.tr("""<tr><td align="right"><b>{:}</b></div></td><td>{:}</td></tr>""")\ text += self.tr("""<tr><td align="right"><b>{:}</b></div></td><td>{:}</td></tr>""")\
.format( .format(self.tr('Path'), node[1]['text'])
self.tr('Path'), node['text'])
else: else:
text += self.tr("""<tr><td align="right"><b>{:}</b></div></td><td>{:}</td></tr>""")\ text += self.tr("""<tr><td align="right"><b>{:}</b></div></td><td>{:}</td></tr>""")\
.format('', .format('', node[1]['text'] )
node[ if index == distance and node_id != self.account.pubkey:
'text'])
if index == distance and node['id'] != self.account.pubkey:
text += self.tr("""<tr><td align="right"><b>{:}</b></div></td><td>{:}</td></tr>""")\ text += self.tr("""<tr><td align="right"><b>{:}</b></div></td><td>{:}</td></tr>""")\
.format('', .format('', self.account.name)
self.account.name)
index += 1 index += 1
self.ui.label_path.setText(text) self.ui.label_path.setText(text)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment