-
Notifications
You must be signed in to change notification settings - Fork 74
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
parse subgraphs recursively #72
parse subgraphs recursively #72
Conversation
Before, only one subgraphlevel was added correctly, as pydot.get_subgraph_list only returns the subgraphs at the current level. I put the node and edge parsing into a separate function and made them recursive.
This was only relevant for developing
That sounds like a good improvement. Can you please provide a set of steps to exercise the new functionality. |
It's easiest to check using a unit test. I'll upload one shortly, but first #77 could be merged, maybe, as I added the unittest inside that file. |
I added an example test case with a graph with two nested subgraphs. If this test is run on the kinetic-devel branch, it will fail, as the edge inside the most inner subgraph can't be created, as the nodes never got parsed. |
@@ -295,5 +304,26 @@ def dotcode_to_qt_items(self, dotcode, highlight_level, same_label_siblings=Fals | |||
self.addEdgeItem(edge, nodes, edges, | |||
highlight_level=highlight_level, | |||
same_label_siblings=same_label_siblings) | |||
return edges | |||
|
|||
def dotcode_to_qt_items(self, dotcode, highlight_level, same_label_siblings=False): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please do not move code around since it makes the diff much more complicated to review.
@@ -237,34 +241,27 @@ def addEdgeItem(self, edge, nodes, edges, highlight_level, same_label_siblings=F | |||
sibling.add_sibling_edge(edge_item) | |||
|
|||
if label not in edges: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The check seems to not match the updated assignment in the next lines.
edge_name = source_node.strip('"\n"') + '_TO_' + destination_node.strip('"\n"') | ||
if label is not None: | ||
edge_name = edge_name + '_' + label | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please move these lines above line 243 since edge_name
is not used until then.
Sorry, it took me a while to get some time for this... @dirk-thomas: I tried to follow your suggestions for the PR |
graph.subgraphs_iter = graph.get_subgraph_list | ||
|
||
num_subgraphs = len(graph.get_subgraph_list()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This variable is not used anywhere?
nodes = {} | ||
for subgraph in graph.subgraphs_iter(): | ||
subgraph_nodeitem = self.getNodeItemForSubgraph(subgraph, highlight_level) | ||
num_subgraphs = len(subgraph.get_subgraph_list()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This variable is not used anywhere?
nodes = {} | ||
for subgraph in graph.subgraphs_iter(): | ||
subgraph_nodeitem = self.getNodeItemForSubgraph(subgraph, highlight_level) | ||
num_subgraphs = len(subgraph.get_subgraph_list()) | ||
|
||
nodes = dict(nodes, **self.parse_nodes(subgraph, highlight_level)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the following would be more readable and make the intention of the line clearer:
nodes.update(...)
Same below for edges
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dirk-thomas thanks for the really thorough review. I included the mentioned changes.
I have independently made these changes in #87. |
I am sorry for the long delay. I have just tried the current state and it looks good to me. Thank you for contributing this patch. |
Before, only one subgraphlevel was added correctly, as pydot.get_subgraph_list
only returns the subgraphs at the current level.
I put the node and edge parsing into a separate function and made them recursive.