Skip to content

Add planarity test and PMFG#208

Merged
Krastanov merged 45 commits intoJuliaGraphs:masterfrom
josephcbradley:josephcbradley/issue153
Feb 24, 2026
Merged

Add planarity test and PMFG#208
Krastanov merged 45 commits intoJuliaGraphs:masterfrom
josephcbradley:josephcbradley/issue153

Conversation

@josephcbradley
Copy link
Copy Markdown
Contributor

@josephcbradley josephcbradley commented Jan 2, 2023

This is an implementation of a planarity test and an algorithm to construct a planar maximally filtered graph, as mentioned in #153.

It is functioning and there are some basic tests for the planarity algorithm, but there are quite a few todos:

  • add tests for the PMFG algorithm
  • Speed up the PMFG algorithm (currently reallocating lots of structures that don't need to be)
  • implement traits for the PMFG algorithm (I could not get this to work for the life of me, would appreciate a pointer from someone more familiar with the syntax!)

etc. etc.

This is my first pull request so feedback appreciated!

@codecov
Copy link
Copy Markdown

codecov bot commented Jan 4, 2023

Codecov Report

❌ Patch coverage is 98.26840% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 97.32%. Comparing base (89dabeb) to head (08dfa48).
⚠️ Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
src/planarity.jl 99.04% 2 Missing ⚠️
...c/spanningtrees/planar_maximally_filtered_graph.jl 90.47% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #208      +/-   ##
==========================================
+ Coverage   97.29%   97.32%   +0.02%     
==========================================
  Files         123      125       +2     
  Lines        7421     7652     +231     
==========================================
+ Hits         7220     7447     +227     
- Misses        201      205       +4     

☔ View full report in Codecov by Sentry.
📢 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.

@josephcbradley josephcbradley changed the title Josephcbradley/issue153 Add planarity test and PMFG Jan 6, 2023
@simonschoelly
Copy link
Copy Markdown
Member

Hey, thanks for this contribution, I think planarity is indeed something we could use.

It might take a bit longer to completely review this PR, as these planarity algorithms are not known that much, so at least I need to get familiar with them again.

Comment thread src/Graphs.jl Outdated
Comment thread src/planarity.jl Outdated
Comment thread src/spanningtrees/planar_maximally_filtered_graph.jl Outdated
Comment thread src/spanningtrees/planar_maximally_filtered_graph.jl Outdated
Comment thread src/spanningtrees/planar_maximally_filtered_graph.jl
Comment thread src/spanningtrees/planar_maximally_filtered_graph.jl Outdated
Comment thread src/spanningtrees/planar_maximally_filtered_graph.jl Outdated
@josephcbradley
Copy link
Copy Markdown
Contributor Author

@simonschoelly I think that's everything for now.

I've added the docs for planarity and for the PMFG to the spanning trees page, as that's where it felt most relevant.

Comment thread test/spanningtrees/planar_maximally_filtered_graph.jl Outdated
@Krastanov
Copy link
Copy Markdown
Member

@josephcbradley , it seems this PR has stalled since it was reviewed a few years ago. If you have a chance to address the merge conflicts, it would be great to revive it. For now, I will mark it as a draft to manage my review queue a bit better, but do not hesitate to convert it back to not a draft if you decide to revive it.

@Krastanov Krastanov marked this pull request as draft February 21, 2026 05:39
@josephcbradley josephcbradley force-pushed the josephcbradley/issue153 branch from 9ea7ec8 to 6976fc8 Compare February 22, 2026 10:01
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Feb 22, 2026

Benchmark Results (Julia v1)

Time benchmarks
master 08dfa48... master / 08dfa48...
centrality/digraphs/betweenness_centrality 16.9 ± 0.84 ms 16.7 ± 0.7 ms 1.01 ± 0.066
centrality/digraphs/closeness_centrality 12 ± 1 ms 11.8 ± 0.72 ms 1.02 ± 0.11
centrality/digraphs/degree_centrality 1.93 ± 0.16 μs 1.92 ± 0.15 μs 1.01 ± 0.11
centrality/digraphs/katz_centrality 0.856 ± 0.07 ms 0.856 ± 0.046 ms 1 ± 0.098
centrality/digraphs/pagerank 0.0365 ± 0.00098 ms 0.0362 ± 0.00058 ms 1.01 ± 0.032
centrality/graphs/betweenness_centrality 28.8 ± 1.5 ms 28.8 ± 1.3 ms 1 ± 0.069
centrality/graphs/closeness_centrality 21.6 ± 0.59 ms 21.4 ± 0.51 ms 1.01 ± 0.037
centrality/graphs/degree_centrality 1.49 ± 0.16 μs 1.49 ± 0.15 μs 1 ± 0.15
centrality/graphs/katz_centrality 1.02 ± 0.046 ms 1.01 ± 0.06 ms 1.01 ± 0.075
connectivity/digraphs/strongly_connected_components 0.044 ± 0.002 ms 0.0427 ± 0.0011 ms 1.03 ± 0.054
connectivity/graphs/connected_components 24.7 ± 2.2 μs 24.3 ± 0.68 μs 1.02 ± 0.094
core/edges/digraphs 7.74 ± 0.03 μs 7.15 ± 0.011 μs 1.08 ± 0.0045
core/edges/graphs 17 ± 0.11 μs 15.6 ± 0.09 μs 1.09 ± 0.0095
core/has_edge/digraphs 5.23 ± 0.44 μs 5.09 ± 0.35 μs 1.03 ± 0.11
core/has_edge/graphs 5.64 ± 0.45 μs 5.46 ± 0.35 μs 1.03 ± 0.11
core/nv/digraphs 0.361 ± 0.011 μs 0.361 ± 0.01 μs 1 ± 0.041
core/nv/graphs 0.391 ± 0.01 μs 0.381 ± 0.011 μs 1.03 ± 0.04
edges/fille 8.17 ± 0.95 μs 8.61 ± 1.4 μs 0.949 ± 0.19
edges/fillp 5.87 ± 3.6 μs 6.05 ± 3.6 μs 0.97 ± 0.84
edges/tsume 2.54 ± 0.091 μs 2.56 ± 0.05 μs 0.992 ± 0.04
edges/tsump 2.56 ± 0.02 μs 2.54 ± 0.07 μs 1.01 ± 0.029
insertions/SG(n,e) Generation 24.7 ± 3.5 ms 25.1 ± 3.5 ms 0.983 ± 0.2
parallel/egonet/twohop 0.3 ± 0.0081 s 0.31 ± 0.0064 s 0.97 ± 0.033
parallel/egonet/vertexfunction 2.3 ± 0.41 ms 2.38 ± 0.58 ms 0.967 ± 0.29
serial/egonet/twohop 0.326 ± 0.012 s 0.31 ± 0.011 s 1.05 ± 0.054
serial/egonet/vertexfunction 2.26 ± 0.5 ms 2.33 ± 0.47 ms 0.968 ± 0.29
traversals/digraphs/bfs_tree 0.0518 ± 0.0092 ms 0.0503 ± 0.0023 ms 1.03 ± 0.19
traversals/digraphs/dfs_tree 0.0658 ± 0.0092 ms 0.0644 ± 0.0026 ms 1.02 ± 0.15
traversals/graphs/bfs_tree 0.0552 ± 0.0029 ms 0.0538 ± 0.002 ms 1.03 ± 0.066
traversals/graphs/dfs_tree 0.0679 ± 0.0041 ms 0.0664 ± 0.0024 ms 1.02 ± 0.072
time_to_load 0.54 ± 0.0018 s 0.546 ± 0.0055 s 0.989 ± 0.01
Memory benchmarks
master 08dfa48... master / 08dfa48...
centrality/digraphs/betweenness_centrality 0.29 M allocs: 24 MB 0.29 M allocs: 24 MB 1
centrality/digraphs/closeness_centrality 18.6 k allocs: 14.5 MB 18.6 k allocs: 14.5 MB 1
centrality/digraphs/degree_centrality 8 allocs: 5.01 kB 8 allocs: 5.01 kB 1
centrality/digraphs/katz_centrality 2.63 k allocs: 2.83 MB 2.63 k allocs: 2.83 MB 1
centrality/digraphs/pagerank 21 allocs: 14.9 kB 21 allocs: 14.9 kB 1
centrality/graphs/betweenness_centrality 0.545 M allocs: 0.0313 GB 0.545 M allocs: 0.0313 GB 1
centrality/graphs/closeness_centrality 19.3 k allocs: 14 MB 19.3 k allocs: 14 MB 1
centrality/graphs/degree_centrality 10 allocs: 5.43 kB 10 allocs: 5.43 kB 1
centrality/graphs/katz_centrality 2.96 k allocs: 3.1 MB 2.96 k allocs: 3.1 MB 1
connectivity/digraphs/strongly_connected_components 1.05 k allocs: 0.075 MB 1.05 k allocs: 0.075 MB 1
connectivity/graphs/connected_components 0.061 k allocs: 22.5 kB 0.061 k allocs: 22.5 kB 1
core/edges/digraphs 3 allocs: 0.0938 kB 3 allocs: 0.0938 kB 1
core/edges/graphs 3 allocs: 0.0938 kB 3 allocs: 0.0938 kB 1
core/has_edge/digraphs 20 allocs: 12.6 kB 20 allocs: 12.6 kB 1
core/has_edge/graphs 28 allocs: 13.8 kB 28 allocs: 13.8 kB 1
core/nv/digraphs 3 allocs: 0.0938 kB 3 allocs: 0.0938 kB 1
core/nv/graphs 3 allocs: 0.0938 kB 3 allocs: 0.0938 kB 1
edges/fille 3 allocs: 0.153 MB 3 allocs: 0.153 MB 1
edges/fillp 3 allocs: 0.153 MB 3 allocs: 0.153 MB 1
edges/tsume 0 allocs: 0 B 0 allocs: 0 B
edges/tsump 0 allocs: 0 B 0 allocs: 0 B
insertions/SG(n,e) Generation 0.0465 M allocs: 10.9 MB 0.0465 M allocs: 10.9 MB 1
parallel/egonet/twohop 10 allocs: 0.0768 MB 10 allocs: 0.0768 MB 1
parallel/egonet/vertexfunction 10 allocs: 0.0768 MB 10 allocs: 0.0768 MB 1
serial/egonet/twohop 3 allocs: 0.0764 MB 3 allocs: 0.0764 MB 1
serial/egonet/vertexfunction 3 allocs: 0.0764 MB 3 allocs: 0.0764 MB 1
traversals/digraphs/bfs_tree 2.34 k allocs: 0.113 MB 2.34 k allocs: 0.113 MB 1
traversals/digraphs/dfs_tree 2.44 k allocs: 0.118 MB 2.44 k allocs: 0.118 MB 1
traversals/graphs/bfs_tree 2.52 k allocs: 0.121 MB 2.52 k allocs: 0.121 MB 1
traversals/graphs/dfs_tree 2.63 k allocs: 0.127 MB 2.63 k allocs: 0.127 MB 1
time_to_load 0.145 k allocs: 11 kB 0.145 k allocs: 11 kB 1

@josephcbradley josephcbradley marked this pull request as ready for review February 22, 2026 10:25
@josephcbradley
Copy link
Copy Markdown
Contributor Author

@Krastanov thanks for the bump - I think I've merged successfully, please lmk if you have any comments.

Copy link
Copy Markdown
Member

@Krastanov Krastanov left a comment

Choose a reason for hiding this comment

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

I am adding some minor suggestions here. And it seems there are some test failures that you will have to address (hopefully they are not a sign of an unexpected bug).

By the way, we are struggling to find enough volunteers to help with PR reviews. Let me know if you are interested in being added to the github org to get notifications about the occasional incoming PR that can benefit from review.

Comment thread src/spanningtrees/planar_maximally_filtered_graph.jl
Comment thread src/spanningtrees/planar_maximally_filtered_graph.jl Outdated
@Krastanov
Copy link
Copy Markdown
Member

and you will need to rerun the automated formatter, as we now enforce format conventions on the codebase

@josephcbradley
Copy link
Copy Markdown
Contributor Author

@Krastanov cleaned up the formatting and fixed the bug. I will test the PMFG on some bigger graphs at some point and see if it's still worth the messy optimisation. The only failing test seems to be unrelated.

PS happy to be added to reviewer list.

@Krastanov
Copy link
Copy Markdown
Member

Thanks, Joseph! I will send you an invite to the github org shortly.

@Krastanov
Copy link
Copy Markdown
Member

By the way, a lot of us are also on the julia community slack in the #graphs channel

@Krastanov Krastanov merged commit 2bc509d into JuliaGraphs:master Feb 24, 2026
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants