When checking if a graph is a valid path here, the code should check if it's even possible to be true given the number of vertices and edges, as a path must have n - 1 edges. This can early identify some non-paths.
Implement the number of edges in a path as another fact (zero vertices must be correctly handled, too).
When checking if a graph is a valid path here, the code should check if it's even possible to be true given the number of vertices and edges, as a path must have n - 1 edges. This can early identify some non-paths.
Implement the number of edges in a path as another fact (zero vertices must be correctly handled, too).