Graph connectivity · Compiler
Graph connectivity
Count the vertices that cannot be reached from a given starting vertex s by following zero or more edges in an undirected graph.
- Input
- The first line contains n, m, and s (1 <= n <= 100, 0 <= m <= n*(n-1)/2, 1 <= s <= n). Vertices are numbered 1 through n. Each of the next m lines contains the endpoints of one undirected edge. There are no self-loops or repeated edges.
- Output
- Print the number of vertices unreachable from s.
Compiler Explorer runs your code when you run or check it.
Loading your exercise draft…