Skip to content

Map Graph Recognition - #922

Open
anujthak wants to merge 5 commits into
digraphs:mainfrom
anujthak:map-graphs
Open

anujthak wants to merge 5 commits into
digraphs:mainfrom
anujthak:map-graphs

Conversation

@anujthak

Copy link
Copy Markdown
Contributor

Adding an algorithm in response to #546 that recognizes whether or not an inputted graph is a map graph.

@codecov

codecov Bot commented Apr 23, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 91.66667% with 13 lines in your changes missing coverage. Please review.
✅ Project coverage is 97.43%. Comparing base (7c00ce7) to head (7a73ede).

Files with missing lines Patch % Lines
gap/planar.gi 91.55% 13 Missing ⚠️

❌ Your patch check has failed because the patch coverage (91.66%) is below the target coverage (100.00%). You can increase the patch coverage or adjust the target coverage.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #922      +/-   ##
==========================================
- Coverage   97.48%   97.43%   -0.05%     
==========================================
  Files          53       53              
  Lines       21363    21519     +156     
  Branches      639      639              
==========================================
+ Hits        20825    20968     +143     
- Misses        473      486      +13     
  Partials       65       65              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

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

@james-d-mitchell james-d-mitchell added the new-feature A label for new features. label Apr 24, 2026
Comment thread doc/planar.xml Outdated
Comment thread gap/planar.gi

# reconstruct graph from the planar bipartite graph
# for the inputted H we have U = [1...n] and V is the rest(all junctions)
BindGlobal("DIGRAPHS_HalfSquare",

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think this should be an attribute (or maybe an operation), for a bipartite graph, that has independent documentation and tests. It should probably take which set of vertices to use (instead of [1 .. n]), and check if that set of vertices is one of the two sets used in the definition of the bipartite graph.

Comment thread gap/planar.gi Outdated
Comment thread gap/planar.gi Outdated
Comment thread gap/planar.gi
m := DigraphNrAdjacenciesWithoutLoops(G);

if n < 5 or m < 9 then
return true;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

be good to combine these ifs into a single statement using elif, and possibly providing a reference for why these conditions imply the answers they do.

Comment thread doc/planar.xml Outdated
Comment thread doc/planar.xml Outdated
Comment thread gap/planar.gi Outdated
Comment thread gap/planar.gi Outdated
Comment thread gap/planar.gi Outdated
Comment thread gap/planar.gi Outdated
Comment thread gap/planar.gi Outdated
Add(canon, v);
fi;
Sort(canon);
key := String(canon);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I don't think this will work in general, how is the key "123" interpreted? It can be generated by [1, 23], and [123], and there's no way to tell the difference. I think you maybe want to use a HashMap here instead of a record.

Comment thread gap/planar.gi
for i in [1 .. Length(nbrs)] do
mapping[nbrs[i]] := i;
od;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Local functions that depend on the state of "global" variables, like subEdges here, smell bad, and should probably be avoided. Can you please refactor this so that EdgesCoveredBy is a global function and that it's arguments are explicitly given?

Comment thread gap/planar.gi
subEdges := [];
for i in DigraphVertices(sub) do
for e in OutNeighboursOfVertex(sub, i) do
if e > i then

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I'm struggling to understand why e > i is being checked here? Be good to have some more comments to understand what's being done here.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Intent is so that we don't double count edges([1,2] and [2,1]) ordering doesn't matter but edges are undirected(as a cant neighbor b without b also neighboring a)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Gotcha, I'd still like to understand what algorithm your implementing but we can discuss it tomorrow, looks like there's great stuff in here!

@William-Kenyon
William-Kenyon marked this pull request as ready for review October 15, 2026 15:07

@james-d-mitchell james-d-mitchell left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@William-Kenyon thanks for working on this PR, it's really helpful! There are still a couple of unresolved comments from my earlier review, can you please take a look at those too?

The other thing that's missing, which is the real blocker for merging this is that I don't know what algorithm @anujthak originally implemented. I had intended to ask @anujthak at the final VIP meeting last semester, but the opportunity did not arise. @William-Kenyon if you know what algorithm is being implemented, can you add a description as a comment somewhere in the code? I mean a high-level explanation of what is being done (not how).

This branch has not been deployed

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

Labels

new-feature A label for new features.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants