Skip to content

Fix: Restore pgr_boyerMyrvold to build and fix compilation bugs#3078

Draft
Mohit242-bit wants to merge 9 commits intopgRouting:developfrom
Mohit242-bit:fix/clean-restore-boyerMyrvold
Draft

Fix: Restore pgr_boyerMyrvold to build and fix compilation bugs#3078
Mohit242-bit wants to merge 9 commits intopgRouting:developfrom
Mohit242-bit:fix/clean-restore-boyerMyrvold

Conversation

@Mohit242-bit
Copy link
Contributor

@Mohit242-bit Mohit242-bit commented Feb 24, 2026

Problem:
pgr_boyerMyrvold was developed but was never functional due to several bugs that prevented it from compiling. The source files existed but were excluded from the build system in src/planar/CMakeLists.txt and sql/planar/CMakeLists.txt.

Changes proposed in this pull request:

File Bug Fix
boyerMyrvold_driver.cpp Stale includes with pgr_ prefix Updated to alloc.hpp, assert.hpp etc.
boyerMyrvold_driver.h Function name mismatch Renamed to pgr_do_boyerMyrvold
boyerMyrvold_driver.cpp Incorrect UndirectedGraph constructor Changed to default constructor
boyerMyrvold.c Outdated IID_t_rt members Changed .source/.target to .from_vid/.to_vid
boyerMyrvold.hpp Unused header Removed is_kuratowski_subgraph.hpp
CMakeLists.txt (src/sql) Files excluded from build Added source and SQL files back to build system

Testing

  • Clean build from scratch with 0 warnings.
  • Verified function returns correct planar embedding (18 edges on sample graph).
  • K₅ (non-planar graph) correctly returns 0 rows.
  • Added 4 new pgTAP test files following existing isPlanar patterns.
  • All 153 pgTAP tests pass

Note:
RST documentation is not included in this PR — please let me know if it should be added here or handled in a follow-up.

@pgRouting/admins

Summary by CodeRabbit

  • New Features

    • Added pgr_boyermyrvold(text) for Boyer–Myrvold planar embedding; returns seq, source, target, cost (available in v4.1).
  • Tests

    • Added comprehensive pgTAP tests: edge cases, type/signature checks, inner-query behavior, no-crash verification, and version gating.
  • Documentation

    • Added user documentation and localized messages for the new planar routine; listed in experimental functions.
  • Packaging

    • Included new SQL files so the routine is packaged and installed.

Copilot AI review requested due to automatic review settings February 24, 2026 05:54
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 24, 2026

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

Walkthrough

Adds a Boyer–Myrvold planar-embedding feature: new C/C++ sources and driver, SQL function and signature updates, packaging and docs, a pgTAP test suite, minor header and SRF output adjustments, and test configuration/result updates.

Changes

Cohort / File(s) Summary
Core sources
src/planar/boyerMyrvold.c, src/planar/boyerMyrvold_driver.cpp, src/planar/CMakeLists.txt
Adds algorithm implementation and driver to build; adjusts SRF Datum field ordering and internal graph construction; updates include paths and adds new source files to the planar target.
Headers
include/drivers/planar/boyerMyrvold_driver.h, include/planar/boyerMyrvold.hpp
Renames exported driver function from pgr_do_pgr_boyerMyrvoldpgr_do_boyerMyrvold; removes one Boost header include to reduce dependency.
SQL definitions & packaging
sql/planar/_boyerMyrvold.sql, sql/planar/boyerMyrvold.sql, sql/planar/CMakeLists.txt
Adds/updates SQL entrypoints for _pgr_boyermyrvold/pgr_boyermyrvold, bumps version annotation, expands function OUT columns, and registers the SQL files for packaging.
Signatures
sql/sigs/pgrouting--4.1.sig
Registers new API signatures: _pgr_boyermyrvold(text) and pgr_boyermyrvold(text).
pgTAP tests
pgtap/planar/boyerMyrvold/edge_cases.pg, .../inner_query.pg, .../no_crash_test.pg, .../types_check.pg
Adds a test suite covering edge cases, inner-query behavior, no-crash checks, and type/signature validation with version gating and prepared queries.
Docs & localization
doc/planar/pgr_boyerMyrvold.rst, doc/src/experimental.rst, locale/en/LC_MESSAGES/pgrouting_doc_strings.po, locale/pot/pgrouting_doc_strings.pot, doc/_static/page_history.js, doc/planar/CMakeLists.txt
Adds documentation entry for pgr_boyermyrvold, experimental listing, localization strings, and registers the doc in build and page history (v4.1).
Packaging & test config/results
docqueries/planar/test.conf, docqueries/planar/boyerMyrvold.result
Adds boyerMyrvold.pg to test.conf and updates example/result SQL references from edge_tableedges, plus diagnostic blocks and comments.
Result/manifest tweaks
sql/planar/_boyerMyrvold.sql
Minor header version bump (v3.2 → v4.1) only in comment.

Sequence Diagram(s)

sequenceDiagram
    participant Client as SQL Client
    participant PG as PostgreSQL
    participant Driver as C/C++ Driver
    participant Alg as Boyer–Myrvold Alg

    Client->>PG: CALL pgr_boyermyrvold(text)
    PG->>Driver: invoke pgr_do_boyerMyrvold(sql, params...)
    Driver->>Alg: build undirected graph, run planarity test
    Alg-->>Driver: embedding/result
    Driver-->>PG: return SRF rows
    PG-->>Client: RETURN SETOF rows
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Suggested labels

Bug Fix, C/C++, Functionality/New, Documentation

Suggested reviewers

  • robe2
  • iosefa

Poem

🐰 I hopped through nodes and edges with delight,
Found loops and faces by moonlit byte.
Drivers compiled, tests set to run,
Docs penned and signatures done.
A carrot-coded planarity sight.

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title directly describes the main objective of the PR: restoring pgr_boyerMyrvold and fixing compilation bugs that prevented it from building.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR restores the pgr_boyerMyrvold function to a working state by fixing compilation bugs that prevented it from building. The function implements the Boyer-Myrvold planarity testing algorithm to compute planar embeddings of undirected graphs.

Changes:

  • Fixed stale include paths by removing pgr_ prefixes from cpp_common headers
  • Corrected function signature and UndirectedGraph constructor usage
  • Updated IID_t_rt structure member access from old .source/.target to current .from_vid/.to_vid
  • Re-enabled build by adding source files to CMakeLists.txt
  • Added comprehensive pgTAP test suite covering edge cases, type checks, and crash tests

Reviewed changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/planar/boyerMyrvold_driver.cpp Updated include paths, fixed UndirectedGraph default constructor, removed unused variable
src/planar/boyerMyrvold.c Updated IID_t_rt member access to use from_vid/to_vid
include/drivers/planar/boyerMyrvold_driver.h Corrected function name from pgr_do_pgr_boyerMyrvold to pgr_do_boyerMyrvold
include/planar/boyerMyrvold.hpp Removed unused is_kuratowski_subgraph.hpp header
src/planar/CMakeLists.txt Added boyerMyrvold source files back to build
sql/planar/CMakeLists.txt Added boyerMyrvold SQL files back to build
pgtap/planar/boyerMyrvold/*.pg Added 4 comprehensive test files following isPlanar patterns
docqueries/planar/test.conf Added boyerMyrvold.pg to test configuration
docqueries/planar/boyerMyrvold.result Test execution results showing correct function behavior

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 4

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@docqueries/planar/boyerMyrvold.result`:
- Around line 73-101: The q4 example calls pgr_boyerMyrvold with a filter using
component = 14 which doesn't exist in the sample edges, causing the "No edges
found" error; update the q4 example in the doc to either (A) replace component =
14 with a valid component id present in the edges data so pgr_boyerMyrvold
returns a planar embedding, or (B) if demonstrating the error path is
intentional, add an explicit clarifying comment near q4 in the .pg source that
states this is demonstrating the "no matching edges" error; locate the query
using the pgr_connectedComponents call and the pgr_boyerMyrvold invocation to
make the change.

In `@pgtap/planar/boyerMyrvold/edge_cases.pg`:
- Around line 30-144: The test labels and prepared-statement names are
inconsistent (e.g., zeroEdgeTest2, q3, vertexNotPresent4, oneVertexTest6,
twoVerticesTest10, fullGraphTest11, k5Test12, q13, fourVerticesCyclicTest14)
which makes TAP diagnostics confusing; rename all prepared statements and the
human-readable test descriptions to a single sequential scheme (e.g.,
test01_query, test02_boyerMyrvold, etc.) and update every corresponding RETURN
QUERY label string (the second argument to is_empty/set_eq/throws_ok/isnt_empty)
so the numeric ID and prefix match the prepared-statement name and the actual
test order (1..12); ensure you update both the PREPARE statement names and all
subsequent references to those names in SELECTs so names like q5/q9/q13 are
replaced with the new sequential identifiers and labels reflect the same
numbers.

In `@pgtap/planar/boyerMyrvold/no_crash_test.pg`:
- Line 44: Replace the final call to finish() so it matches the test-suite
idiom: change the plain call "finish()" to a set-returning call by using "SELECT
* FROM finish()" where finish() is invoked; update the statement that currently
reads SELECT finish() to SELECT * FROM finish() to ensure the SETOF TEXT is
expanded consistently with other tests.

In `@sql/planar/CMakeLists.txt`:
- Around line 5-10: The package adds new SQL files (_boyerMyrvold.sql,
boyerMyrvold.sql, _isPlanar.sql, isPlanar.sql) which introduce the new
pgr_boyerMyrvold signature—before merging, re-run the repository's
signature-generation step to regenerate the auto-generated pgrouting--*.sig file
so the new pgr_boyerMyrvold entry is captured (do not hand-edit the sig file);
ensure the generation is performed as part of the release or CI step so sql/sigs
reflects the new SQLs.

ℹ️ Review info

Configuration used: Repository UI

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 4912a28 and e04a1a9.

📒 Files selected for processing (12)
  • docqueries/planar/boyerMyrvold.result
  • docqueries/planar/test.conf
  • include/drivers/planar/boyerMyrvold_driver.h
  • include/planar/boyerMyrvold.hpp
  • pgtap/planar/boyerMyrvold/edge_cases.pg
  • pgtap/planar/boyerMyrvold/inner_query.pg
  • pgtap/planar/boyerMyrvold/no_crash_test.pg
  • pgtap/planar/boyerMyrvold/types_check.pg
  • sql/planar/CMakeLists.txt
  • src/planar/CMakeLists.txt
  • src/planar/boyerMyrvold.c
  • src/planar/boyerMyrvold_driver.cpp
💤 Files with no reviewable changes (1)
  • include/planar/boyerMyrvold.hpp

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@pgtap/planar/boyerMyrvold/no_crash_test.pg`:
- Line 9: Update the version check in the test to match the actual SQL API
presence: change the call to min_version('3.2.0') to min_version('4.1.0') so the
conditional in SELECT CASE WHEN min_version(...) THEN plan (5) ELSE plan(1) END;
correctly reflects that the function exists starting in pgrouting 4.1; locate
the min_version call in the no_crash_test.pg test and replace the version string
accordingly.

ℹ️ Review info

Configuration used: Repository UI

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e04a1a9 and 46b199f.

📒 Files selected for processing (2)
  • pgtap/planar/boyerMyrvold/no_crash_test.pg
  • sql/sigs/pgrouting--4.1.sig

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

♻️ Duplicate comments (1)
docqueries/planar/boyerMyrvold.result (1)

73-101: Error output in doc example can confuse readers.
q4 renders ERROR: No edges found. If this is intentional, keep it but ensure the companion .pg source clarifies the purpose; otherwise, use a component that exists in sample data.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@docqueries/planar/boyerMyrvold.result` around lines 73 - 101, The example
query q4 calling pgr_boyerMyrvold with a WHERE component = 14 causes "ERROR: No
edges found"; either update the component filter to a component that exists in
the sample data (replace the literal 14 in both pgr_connectedComponents calls)
so the query returns edges, or leave the error but add a clarifying comment in
the companion .pg source explaining that the error is intentional and why;
locate the occurrences by referencing the q4 block and the
pgr_connectedComponents calls that build the ARRAY used by pgr_boyermyrvold.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Duplicate comments:
In `@docqueries/planar/boyerMyrvold.result`:
- Around line 73-101: The example query q4 calling pgr_boyerMyrvold with a WHERE
component = 14 causes "ERROR: No edges found"; either update the component
filter to a component that exists in the sample data (replace the literal 14 in
both pgr_connectedComponents calls) so the query returns edges, or leave the
error but add a clarifying comment in the companion .pg source explaining that
the error is intentional and why; locate the occurrences by referencing the q4
block and the pgr_connectedComponents calls that build the ARRAY used by
pgr_boyermyrvold.

ℹ️ Review info

Configuration used: Repository UI

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 46b199f and 4a03ffe.

📒 Files selected for processing (1)
  • docqueries/planar/boyerMyrvold.result

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

♻️ Duplicate comments (1)
pgtap/planar/boyerMyrvold/edge_cases.pg (1)

24-144: 🧹 Nitpick | 🔵 Trivial

Test labels remain inconsistent across cases.
This matches the prior review concern about non‑sequential labels and mixed naming (q1/q3 vs zeroEdgeTest2, etc.), which makes TAP diagnostics harder to correlate.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@pgtap/planar/boyerMyrvold/edge_cases.pg` around lines 24 - 144, The TAP test
labels are inconsistent (mixed q1/q3 and descriptive names like
zeroEdgeTest2/vertexNotPresent4) which hurts diagnostics; rename and standardize
all PREPARE identifiers and their corresponding result-check calls to a
consistent sequential naming scheme (e.g., test1_prepare/test1_check or
test1_query/test1_result) so each case maps 1:1 — update PREPARE q1 -> PREPARE
test1Query, throws_ok zeroEdgeTest2 -> test2Result, PREPARE q3/vertexNotPresent4
-> test3Query/test3Result, q5/oneVertexTest6 -> test4Query/test4Result,
q9/twoVerticesTest10 -> test5Query/test5Result, fullGraphTest11 ->
test6Query/test6Result, k5Test12 -> test7Query/test7Result,
q13/fourVerticesCyclicTest14 -> test8Query/test8Result and adjust the SELECT
calls and descriptive TAP messages to use the new names so labels are sequential
and consistent across the file.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Duplicate comments:
In `@pgtap/planar/boyerMyrvold/edge_cases.pg`:
- Around line 24-144: The TAP test labels are inconsistent (mixed q1/q3 and
descriptive names like zeroEdgeTest2/vertexNotPresent4) which hurts diagnostics;
rename and standardize all PREPARE identifiers and their corresponding
result-check calls to a consistent sequential naming scheme (e.g.,
test1_prepare/test1_check or test1_query/test1_result) so each case maps 1:1 —
update PREPARE q1 -> PREPARE test1Query, throws_ok zeroEdgeTest2 -> test2Result,
PREPARE q3/vertexNotPresent4 -> test3Query/test3Result, q5/oneVertexTest6 ->
test4Query/test4Result, q9/twoVerticesTest10 -> test5Query/test5Result,
fullGraphTest11 -> test6Query/test6Result, k5Test12 -> test7Query/test7Result,
q13/fourVerticesCyclicTest14 -> test8Query/test8Result and adjust the SELECT
calls and descriptive TAP messages to use the new names so labels are sequential
and consistent across the file.

ℹ️ Review info

Configuration used: Repository UI

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 4a03ffe and 03dbaa5.

📒 Files selected for processing (4)
  • pgtap/planar/boyerMyrvold/edge_cases.pg
  • pgtap/planar/boyerMyrvold/inner_query.pg
  • pgtap/planar/boyerMyrvold/no_crash_test.pg
  • pgtap/planar/boyerMyrvold/types_check.pg

Copy link
Member

@cvvergara cvvergara left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Mohit242-bit
Documentation is missing we need documentation
Looks like there was no documentation created when this was attempted on 2020
Please add documentation.
you will need to add the .rst of the function under doc/planar directory
also modify the doc/_static/page_history.js
It is an experimental function.

Also the SQL files should have the correct version 4.1
For example

--v3.2
CREATE FUNCTION  ....

Change to

--v4.1
CREATE FUNCTION 

@cvvergara cvvergara marked this pull request as draft March 1, 2026 17:40
@Mohit242-bit Mohit242-bit marked this pull request as ready for review March 2, 2026 03:28
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@doc/planar/pgr_boyerMyrvold.rst`:
- Line 7: Remove the version text from the :single: index entry for the official
function; specifically edit the :single: entry referencing "boyerMyrvold" so it
does not include " - Experimental on v4.1" and leave any version/availability
notes only in the Availability section for the boyerMyrvold function
documentation.

In `@locale/pot/pgrouting_doc_strings.pot`:
- Around line 7543-7550: Duplicate return-description msgids are present: "This
function returns the edges of the planar embedding when the graph is planar."
and "It will return the edges of the planar embedding when the graph is
planar."; keep only one of these return-description sentences in the source .rst
and remove the other to avoid duplicate msgids, while retaining the
implementation note "This implementation uses the Boyer-Myrvold Planarity
Testing." so the doc contains a single concise return sentence plus the
implementation note.

ℹ️ Review info

Configuration used: Repository UI

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 03dbaa5 and 56eeb4b.

📒 Files selected for processing (8)
  • doc/_static/page_history.js
  • doc/planar/CMakeLists.txt
  • doc/planar/pgr_boyerMyrvold.rst
  • doc/src/experimental.rst
  • locale/en/LC_MESSAGES/pgrouting_doc_strings.po
  • locale/pot/pgrouting_doc_strings.pot
  • sql/planar/_boyerMyrvold.sql
  • sql/planar/boyerMyrvold.sql

@Mohit242-bit Mohit242-bit requested a review from cvvergara March 2, 2026 04:12
@Mohit242-bit Mohit242-bit force-pushed the fix/clean-restore-boyerMyrvold branch from e6731b1 to d310928 Compare March 3, 2026 04:42
@@ -0,0 +1,135 @@
:file: This file is part of the pgRouting project.
:copyright: Copyright (c) 2020-2026 pgRouting developers
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually the file is originally from 2026 so

:copyright: Copyright (c) 2026-2026 pgRouting developers

Signatures
-------------------------------------------------------------------------------

.. rubric:: Summary
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is only one function so no summary word is needed

-----+--------+--------+------
1 | 14 | 15 | 1
(1 row)
ERROR: No edges found
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmmm, the inner query is not returning edges

SELECT node FROM pgr_connectedComponents(
                            'SELECT id, source, target, cost, reverse_cost FROM edges ')
                        WHERE component = 14;
 node 
------
(0 rows)

but this one works:

SELECT node FROM pgr_connectedComponents(
                            'SELECT id, source, target, cost, reverse_cost FROM edges ')
                        WHERE component = 13;
 node 
------
   13
   14
(2 rows)

@cvvergara
Copy link
Member

Because of the unused include I went to read the boost documentation for boyer_myrvold

Computing a planar embedding for a graph if it is planar, otherwise finding a set of edges that forms an obstructing Kuratowski subgraph:

if (boyer_myrvold_planarity_test(boyer_myrvold_params::graph = g,
                                 boyer_myrvold_params::embedding = embedding_pmap,
                                 boyer_myrvold_params::kuratowski_subgraph = out_itr
                                 )
    )
{
  //do something with the embedding in embedding_pmap
}
else
{
  //do something with the kuratowski subgraph output to out_itr
}

Right now when the graph is not planar its giving an empty result, the intention is to output the kuratowski_subgraph when its not planar.

See this example from boost
maybe it can be used.

@cvvergara cvvergara marked this pull request as draft March 4, 2026 00:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants