Re: How to judge if the graph is cyclic when add a new edge?



On Apr 26, 4:34 am, "cstnt" <c...@xxxxxxxxxxx> wrote:
How to judge if the graph is cyclic when add a new edge? How to do it
quickly.

Assuming your graph is undirected, the standard approach
is to use the "union-find" (a.k.a. "disjoint-sets") data structure.
The time per edge insetion / will edge add a cycle is
essentially constant.

.