Skip to content
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

Merged

Conversation

fmauch
Copy link
Contributor

@fmauch fmauch commented Nov 12, 2016

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.

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
@dirk-thomas
Copy link
Contributor

That sounds like a good improvement. Can you please provide a set of steps to exercise the new functionality.

@fmauch
Copy link
Contributor Author

fmauch commented Jan 2, 2017

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.

@fmauch
Copy link
Contributor Author

fmauch commented Jan 3, 2017

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.
With the changes in this PR the nested levels get created correctly.

@@ -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):
Copy link
Contributor

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:
Copy link
Contributor

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

Copy link
Contributor

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.

@fmauch
Copy link
Contributor Author

fmauch commented May 12, 2017

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())
Copy link
Contributor

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())
Copy link
Contributor

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))
Copy link
Contributor

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.

Copy link
Contributor Author

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.

@EliteMasterEric
Copy link
Contributor

I have independently made these changes in #87.

@dirk-thomas
Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants