-
Notifications
You must be signed in to change notification settings - Fork 162
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
Stabilize Vf2++ matching order #375
Conversation
Pull Request Test Coverage Report for Build 990596717
💛 - Coveralls |
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.
LGTM
I'm curious is there any difference in performance form this? I expect the sort to be slower but the use of a vec for next_level
to be faster, so I'm not sure what to expect.
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.
LGTM, it will make the output deterministic
LGTM
I'm curious is there any difference in performance form this? I expect the sort to be slower but the use of a vec for
next_level
to be faster, so I'm not sure what to expect.
I wouldn't be surprised if the difference is negligible. This change only affects the matching order, no? If we benchmark the algorithm, I belive we will spend more time on try_match
In case this has performance consequence, on my side, I would be okey if this is optional. |
Running this benchmark, i don't really see any significant difference: import timeit
import random
import retworkx as rx
def permute(graph, seed=42):
nodes = list(graph.node_indexes())
rng = random.Random(seed)
rng.shuffle(nodes)
edges = [(nodes[u], nodes[v]) for (u, v) in graph.edge_list()]
if isinstance(graph, rx.PyDiGraph):
res = rx.PyDiGraph()
else:
res = rx.PyGraph()
res.add_nodes_from(nodes)
res.add_edges_from_no_data(edges)
return res
def benchmark():
n = 10000
degrees = [10, 15, 50, 100]
cases = []
for deg in degrees:
p = 2 * deg / (n - 1)
g_a = rx.directed_gnp_random_graph(n, p, seed=42)
g_b = permute(g_a, seed=4242)
cases += [(g_a, g_a), (g_a, g_b)]
return cases
def run(cases):
for (g_a, g_b) in cases:
res = rx.is_isomorphic(g_a, g_b,
id_order=False)
assert res
cases = benchmark()
print(
timeit.timeit("run(cases)", globals=globals(), number=5)
)
|
This PR removes the unstable sort and the (unnecessary) use of a
HashSet
that would make the result of VF2++ heuristic matching order non-deterministic.