Skip to content

Clarify biconnected components description#303

Merged
simonlindholm merged 1 commit intokth-competitive-programming:mainfrom
JJCUBER:patch-5
Nov 6, 2025
Merged

Clarify biconnected components description#303
simonlindholm merged 1 commit intokth-competitive-programming:mainfrom
JJCUBER:patch-5

Conversation

@JJCUBER
Copy link
Contributor

@JJCUBER JJCUBER commented Nov 4, 2025

Two distinct paths is a very weak statement (as having overlapping paths which differ by just one edge/node are distinct). Internally disjoint is a much more apt description.

Two distinct paths is a very weak statement (as having overlapping paths which differ by just one edge/node are distinct).  Internally disjoint is a much more apt description.
@simonlindholm
Copy link
Member

"Internally disjoint" is not a term I've heard. Can we just swap out distinct for disjoint but otherwise leave the original description intact?

@JJCUBER
Copy link
Contributor Author

JJCUBER commented Nov 5, 2025

"Internally disjoint" is not a term I've heard. Can we just swap out distinct for disjoint but otherwise leave the original description intact?

In formal math/graph theory, internally disjoint is the term for having two paths where they share no vertices or edges except possibly the endpoints (internal refers to everything strictly between the endpoints). From this point of view, disjoint would be incorrect since both paths share endpoints, i.e. they aren't disjoint. (It's also ambiguous as to whether it's referring to edge-disjoint vs vertex-disjoint.)

Since I am coming from a more formal setting, if you think dropping "internal" would still be clear enough for competitive programmers, then sure that's fine.

@bjorn-martinsson
Copy link
Contributor

Wouldn't it be easier to change the code to use wiki's definition https://en.wikipedia.org/wiki/Biconnected_component ?

Define biconnected components as maximal biconnected subgraphs, where a graph is considered biconnected iff it remains connected even if any one node is removed.
One can prove that every edge lies in exactly one biconnected component.
Bridges correspond to biconnected components consisting of a single edge.
Cut vertices are the nodes that lie in two or more biconnected components (i.e. the intersection of biconnected components).

@simonlindholm
Copy link
Member

In formal math/graph theory, internally disjoint is the term for having two paths where they share no vertices or edges except possibly the endpoints (internal refers to everything strictly between the endpoints). From this point of view, disjoint would be incorrect since both paths share endpoints, i.e. they aren't disjoint. (It's also ambiguous as to whether it's referring to edge-disjoint vs vertex-disjoint.)

Ah, right, I was thinking disjoint as in edge-disjoint but of course that's not what biconnectivity is about... No, on further thought this PR makes total sense; I'll merge.

Wouldn't it be easier to change the code to use wiki's definition https://en.wikipedia.org/wiki/Biconnected_component ?

I think the code is good as is, it's easy enough to change if you want the callback to be called for bridges too, and they are a bit of a special case that you often want to treat separately.

@simonlindholm simonlindholm merged commit ba85dcd into kth-competitive-programming:main Nov 6, 2025
1 check passed
@bjorn-martinsson
Copy link
Contributor

bjorn-martinsson commented Nov 6, 2025

This is more of a nitpick. If you have just two nodes with an edge between them. Is the path between them internally disjoint with itself? I would argue that it is. It is also what you get googling the definition of internally disjoint.

This is part of the reason why I think it is natural to just include bridges as biconnected components in the first place.

@JJCUBER
Copy link
Contributor Author

JJCUBER commented Nov 6, 2025

This is more of a nitpick. If you have just two nodes with an edge between them. Is the path between them internally disjoint with itself? I would say that it is.

It is not as they share an edge (internally disjoint refers to comparing both the vertices and edges with an allowance for the endpoints repeated; edges are always internal). It also isn't possible to form a cycle out of a single edge.

More on internally disjoint can be found here:

Two paths are vertex-independent (alternatively, internally disjoint or internally vertex-disjoint) if they do not have any internal vertex or edge in common. Similarly, two paths are edge-independent (or edge-disjoint) if they do not have any edge in common. Two internally disjoint paths are edge-disjoint, but the converse is not necessarily true.

@bjorn-martinsson
Copy link
Contributor

bjorn-martinsson commented Nov 6, 2025

This is more of a nitpick. If you have just two nodes with an edge between them. Is the path between them internally disjoint with itself? I would say that it is.

It is not as they share an edge (internally disjoint refers to comparing both the vertices and edges with an allowance for the endpoints repeated; edges are always internal). It also isn't possible to form a cycle out of a single edge.

More on internally disjoint can be found here:

Two paths are vertex-independent (alternatively, internally disjoint or internally vertex-disjoint) if they do not have any internal vertex or edge in common. Similarly, two paths are edge-independent (or edge-disjoint) if they do not have any edge in common. Two internally disjoint paths are edge-disjoint, but the converse is not necessarily true.

Seems to me like wiki is the odd one out. All of the other top hits on google, and for example chatgpt, define internally disjoint as having no vertices in common except for the two end points. See: https://chatgpt.com/share/690d0042-da7c-8012-bc8d-ad5f314a8190 .

@JJCUBER
Copy link
Contributor Author

JJCUBER commented Nov 6, 2025

This is more of a nitpick. If you have just two nodes with an edge between them. Is the path between them internally disjoint with itself? I would say that it is.

It is not as they share an edge (internally disjoint refers to comparing both the vertices and edges with an allowance for the endpoints repeated; edges are always internal). It also isn't possible to form a cycle out of a single edge.
More on internally disjoint can be found here:

Two paths are vertex-independent (alternatively, internally disjoint or internally vertex-disjoint) if they do not have any internal vertex or edge in common. Similarly, two paths are edge-independent (or edge-disjoint) if they do not have any edge in common. Two internally disjoint paths are edge-disjoint, but the converse is not necessarily true.

Seems to me like wiki is the odd one out. All of the other top hits on google, and for example chatgpt, define internally disjoint as having no vertices in common except for the two end points.

As with most things in math, there are multiple definitions. One of the valid definitions does refer to sharing no internal vertices, but the devil is in the details. If you find a definition in a textbook (I wouldn't recommend an LLM since it doesn't give full context and can hallucinate), you would notice that it's referring to two paths from u to v (distinct is implicit since we wouldn't say that the graph $P_2$ has two paths). It is accordingly not valid to say that path P is internally disjoint with itself since we are not comparing two of the paths from u to v.

Try asking the LLM you provided the very question you were actually trying to answer (whether a path can be internally disjoint with itself).

@simonlindholm
Copy link
Member

Try asking the LLM you provided the very question you were actually trying to answer (whether a path can be internally disjoint with itself).

FWIW when I ask ChatGPT whether a single edge path is internally disjoint from itself it says yes, referencing the definition that only looks at vertices.

@JJCUBER
Copy link
Contributor Author

JJCUBER commented Nov 7, 2025

Try asking the LLM you provided the very question you were actually trying to answer (whether a path can be internally disjoint with itself).

FWIW when I ask ChatGPT whether a single edge path is internally disjoint from itself it says yes, referencing the definition that only looks at vertices.

Interestingly, I previously asked the same question directly in the link you provided and it said the opposite. I hope this makes it clear why using LLMs for something like this isn't reliable.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants