Given an undirected graph represented as an adjacency list, find a minimum cycle basis, which is a set of simple cycles with the minimum total length such that any other cycle in the graph can be expressed as a linear combination of these cycles.
Explanation: The minimum cycle basis consists of two cycles: 0-1-2-0 and 1-2-3-1.
Explanation: The minimum cycle basis consists of a single cycle: 0-1-2-3-0.
Detect cycles in directed/undirected graphs
No dry run loaded.
🚀 Practice this problem
Run code, get AI hints & track streak