Skip to content

Add DigraphHalfSquare[s] - #964

Merged
mtorpey merged 5 commits into
digraphs:mainfrom
William-Kenyon:half-squares
Nov 12, 2026
Merged

mtorpey merged 5 commits into
digraphs:mainfrom
William-Kenyon:half-squares

Conversation

@William-Kenyon

@William-Kenyon William-Kenyon commented Nov 10, 2026 •

Copy link
Copy Markdown
Collaborator

A bipartite digraph can be partitioned (not necessarily uniquely) into two sets of vertices (two "sides") such that there are no edges between vertices within a side. Given a digraph and one of these sets of vertices, a half-square is a new digraph on those vertices, with edges between $v_1$ and $v_2$ if there exists a directed path $v_1 \to x \to v_2$ in the original digraph, where $x$ is a vertex on the other side. DigraphHalfSquares returns both the half square of the given side and the other side.

This can replace DIGRAPHS_HalfSquare in PR #922.

@codecov

codecov Bot commented Nov 10, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.47%. Comparing base (eb7aef7) to head (237076a).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #964   +/-   ##
=======================================
  Coverage   97.47%   97.47%           
=======================================
  Files          53       53           
  Lines       21424    21466   +42     
  Branches      638      638           
=======================================
+ Hits        20883    20925   +42     
  Misses        477      477           
  Partials       64       64           

☔ 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.

Comment thread gap/oper.gi
fi;

# check if U is a bicomponent of D, i.e. no edges between vertices in U
# can't do 'U in DigraphBicomponents(D)' because the partition isn't unique

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 intrigued by this comment, why is the partition not unique? In what sense? Anyway, if you really only want to check "no edges between vertices in U" then you can use IsIndependentSet(D, U); to replace all these lines.

@William-Kenyon William-Kenyon Nov 11, 2026 •

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

From the docs: For a bipartite digraph with at least 3 vertices, there is a unique pair of bicomponents of bipartite if and only if the digraph is connected.

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.

Ah you're right, of course, not sure what I was thinking

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.

The other comment might make the code a little simpler though.

@mtorpey mtorpey left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Very legible and elegant code, thank you.

Two minor doc things to fix, then I'm happy.

Comment thread doc/oper.xml Resolved
Comment thread doc/oper.xml Resolved

@mtorpey mtorpey left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

One bad quote mark. Done after that!

Comment thread doc/oper.xml Resolved
@mtorpey
mtorpey merged commit d94d17b into digraphs:main Nov 12, 2026
@William-Kenyon
William-Kenyon deleted the half-squares branch November 12, 2026 16:03
@William-Kenyon William-Kenyon added the VIP Pull requests done by participants of the VIP programme. label Nov 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

VIP Pull requests done by participants of the VIP programme.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants