Bölüm 4.1 · Simülatör

Bipartite, Cycle & Bridge Explorer

← Bölüm 4.1

Bipartite, Cycle & Bridge Explorer

Analyze the same undirected graph from three structural perspectives.

How to use

  • Choose a graph and press one of the three analysis buttons; Clear removes the highlighting.
  • Bipartite Test: vertices are coloured with two colours (blue / red). If the graph is not bipartite, the conflicting edge whose endpoints received the same colour is highlighted.
  • Cycle Detection: the first cycle found by DFS is highlighted.
  • Find Bridges: every bridge is highlighted.

Bipartite test (BFS 2-colouring)

Colour a start vertex, give each neighbour the opposite colour, and repeat with BFS. A graph is bipartite exactly when it has no odd cycle, i.e. when no edge ever joins two vertices of the same colour. Time O(V + E).

Cycle detection (DFS)

In an undirected graph, DFS finds a cycle when it meets an already visited vertex that is not the parent of the current vertex (a back edge). Following the parent links from the current vertex back to that vertex gives the cycle. Time O(V + E).

Bridges (Tarjan)

A bridge is an edge whose removal disconnects the graph. DFS records the discovery time disc[u] and low[u], the earliest discovery time reachable from u's subtree using at most one back edge. A tree edge (u, v) is a bridge exactly when low[v] > disc[u]. Time O(V + E).