Skip to content

fix: vf2 isomorphism on vertex filtered graphs - #692

Merged
Becheler merged 5 commits into
boostorg:developfrom
Becheler:fix/pr-282-vf2-filtered
Nov 1, 2026
Merged

Becheler merged 5 commits into
boostorg:developfrom
Becheler:fix/pr-282-vf2-filtered

Conversation

@Becheler

@Becheler Becheler commented Nov 1, 2026 •

Copy link
Copy Markdown
Collaborator

Motivation

Supersedes #282, which went stale. Refs #690.

vf2_subgraph_iso and vf2_graph_iso use num_vertices and num_edges as counts. For a filtered_graph these forward to the underlying graph, so hidden vertices and edges are counted. With a vertex filter, vf2 then reports no match when one exists.

What this PR does

  • 67d7c9ce adds vf2_filtered_graph_test.cpp, which hides one vertex of a small graph. Both subgraph and graph isomorphism fail on it (CI red).
  • 0954b4dd, d0411e33, 64b1f125 are the original vf2_sub_graph_iso.hpp: fix bug when subgraph is filtered #282 commits by @count0 and @jeremy-murphy, rebased on develop. They count vertices with std::distance over vertices(g), which stays O(1) for random access iterators.
  • 14a8bea9 does the same for edges. vf2_graph_iso rejects graphs whose edge counts differ, so the vertex fix alone leaves graph isomorphism broken (CI green).

Before submitting

  • I searched for an existing PR or issue covering the same change.
  • This PR targets the develop branch.
  • My contribution is licensed under the Boost Software License 1.0.

Kind of change

  • Reformat (layout only, no token added or removed)
  • Refactor (no observable behavior change)
  • Behavior change (observable to users of the library)
  • No code change (documentation, build, CI, or tooling)

Change category

  • Bug fix
  • New algorithm or API addition
  • Deprecation or removal
  • Performance
  • Tests
  • Documentation
  • Build, CI, or tooling
  • Other (specify below)

@Becheler Becheler self-assigned this Nov 1, 2026
@Becheler Becheler added algorithm type of issue related to algorithms fix labels Nov 1, 2026
@github-actions

github-actions Bot commented Nov 1, 2026 •

Copy link
Copy Markdown

Boost dependency footprint vs develop (auto-generated).
PR run 41322914614 vs develop run 41315027699 (14a8bea964).

Header-inclusion weights (graph files pulling each direct dependency in):

No header-inclusion-weight changes.

Transitive Boost modules: 47 → 47 (0)

Becheler and others added 5 commits November 1, 2026 15:41
This fixes a bug when num_vertices() returns a value that does not match
the actual number of vertices. This happens for instances of
filtered_graph<>.

The fix involves looping over the graph to count the actual number of
vertices. The performance overhead is negligible.
@Becheler
Becheler force-pushed the fix/pr-282-vf2-filtered branch 2 times, most recently from 14a8bea to 67d7c9c Compare November 1, 2026 14:43
@github-actions

github-actions Bot commented Nov 1, 2026 •

Copy link
Copy Markdown

Compiler-warning counts vs develop (auto-generated).
PR run 41322914554 vs develop run 41315027672 (14a8bea964).

Job Baseline After Delta
macos (clang, 14) 260 256 -4
macos (clang, 17) 259 255 -4
macos (clang, 20) 259 255 -4
ubuntu (clang-19, 14) 260 256 -4
ubuntu (clang-19, 17) 259 255 -4
ubuntu (clang-19, 20) 259 255 -4
ubuntu (clang-19, 23) 259 255 -4
ubuntu (gcc-14, 14) 361 350 -11
ubuntu (gcc-14, 17) 357 346 -11
ubuntu (gcc-14, 20) 357 346 -11
ubuntu (gcc-14, 23) 357 346 -11
windows_msvc_14_3 (msvc-14.3) 955 955 0

@codecov

codecov Bot commented Nov 1, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@Becheler
Becheler marked this pull request as ready for review November 1, 2026 16:18
@Becheler Becheler changed the title test: reproduce vf2 failures on vertex filtered graphs fix: vf2 isomorphism on vertex filtered graphs Nov 1, 2026
@Becheler
Becheler merged commit 3ec12fe into boostorg:develop Nov 1, 2026
62 checks passed
@jeremy-murphy

Copy link
Copy Markdown
Collaborator

Great work fixing this comprehensively!

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

Labels

algorithm type of issue related to algorithms fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants