Graph/bipartite_graph library

🎨 Bipartite Graph Check (Two-Coloring via BFS)

Determines if an undirected graph is bipartite by attempting to color nodes with two colors such that no adjacent nodes share the same color.

  • Time complexity: O(V + E)
  • Space complexity: O(V)

Example:

final square = {1: [2, 4], 2: [1, 3], 3: [2, 4], 4: [1, 3]};
final ok = isBipartite(square); // true

Functions

isBipartite<T>(Map<T, List<T>> graph) → bool