-
-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
Multiply rooted graph similarity #4907
base: main
Are you sure you want to change the base?
Multiply rooted graph similarity #4907
Conversation
root_u, root_v = roots | ||
if root_u not in pending_u or root_v not in pending_v: | ||
raise nx.NodeNotFound("Root node not in graph.") | ||
roots = [roots] if type(roots) == tuple else roots |
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.
roots = [roots] if type(roots) == tuple else roots | |
if isinstance(roots, tuple) and len(roots) == 2: | |
roots = [roots] |
initial_cost = sum( | ||
[1 - node_match(G1.nodes[root_u], G2.nodes[root_v]) for root_u, root_v in roots]) |
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.
Should this be (1 - sum(node_match for all pairs of root nodes)) or sum( 1 - nodematch)??
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 this looks pretty good. Sorry for the delay in review while we focused on release of NX v2.6. Can you add a paragraph to the doc_string explaining what it means to have multiply rooted graphs and how that affects the algorithm?
Adding support for multiple roots in all similarity algorithms.
optimize_edit_paths
andgraph_edit_distance
had support for a single root, I've extended the functionality to support multiple roots (multiply vertex-rooted graphs)optimize_graph_edit_distance
andoptimal_edit_paths
actually useoptimize_edit_paths
to search for results but didn't have support for roots, I've added it to those methods as well.