Skip to content

Commit

Permalink
Merge pull request #15 from iwatake2222/fix_multi_edge
Browse files Browse the repository at this point in the history
fix: multi nodes between two nodes by replacing DiGraph with MultiDiG…
  • Loading branch information
iwatake2222 authored Jul 28, 2024
2 parents 7850aca + d23b0cf commit d965aea
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 7 deletions.
9 changes: 7 additions & 2 deletions setting.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,15 @@
"offset": [3.0, -0.8, 3.0, 1.5],
"color": [196, 64, 0]
},
"__others__": {
"/system": {
"direction": "horizontal",
"offset": [-0.5, -0.5, 1.0, 1.0],
"color": [64, 64, 128]
},
"__others__": {
"direction": "horizontal",
"offset": [0.5, -0.5, 1.0, 1.0],
"color": [16, 64, 96]
}
}
}
}
8 changes: 4 additions & 4 deletions src/dear_ros_node_viewer/caret2networkx.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def parse_target_path(yml, node_name_list, topic_pub_dict, topic_sub_dict):
def make_graph_from_topic_association(topic_pub_dict: dict[str, list[str]],
topic_sub_dict: dict[str, list[str]]):
"""make graph from topic association"""
graph = nx.DiGraph()
graph = nx.MultiDiGraph()
for topic, node_pub_list in topic_pub_dict.items():
if topic in topic_sub_dict:
node_sub_list = topic_sub_dict[topic]
Expand All @@ -93,14 +93,14 @@ def make_graph_from_topic_association(topic_pub_dict: dict[str, list[str]],
continue
for node_pub in node_pub_list:
for node_sub in node_sub_list:
# logger.debug(topic, node_pub, node_sub)
# logger.debug(f'{topic}, {node_pub}, {node_sub}')
graph.add_edge(node_pub, node_sub, label=topic)

return graph


def caret2networkx(filename: str, target_path: str = 'all_graph',
ignore_unconnected=True) -> nx.classes.digraph.DiGraph:
ignore_unconnected=True) -> nx.classes.multidigraph.MultiDiGraph:
"""
Create NetworkX Graph from architecture.yaml generated by CARET
Expand All @@ -115,7 +115,7 @@ def caret2networkx(filename: str, target_path: str = 'all_graph',
Returns
-------
graph : nx.classes.digraph.DiGraph
graph : nx.classes.multidigraph.MultiDiGraph
NetworkX Graph
"""

Expand Down
7 changes: 6 additions & 1 deletion src/dear_ros_node_viewer/setting.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,14 @@
"offset": [3.0, -0.8, 3.0, 1.5],
"color": [196, 64, 0]
},
"__others__": {
"/system": {
"direction": "horizontal",
"offset": [-0.5, -0.5, 1.0, 1.0],
"color": [64, 64, 128]
},
"__others__": {
"direction": "horizontal",
"offset": [0.5, -0.5, 1.0, 1.0],
"color": [16, 64, 96]
}
}
Expand Down

0 comments on commit d965aea

Please sign in to comment.