The directed graph is given with the adjacency list. The vertex of directed graph is called a source if no edge comes in
Posted: Sat Jul 09, 2022 11:48 am
The directed graph is given with the adjacency list. The vertex of directed graph is called a source if no edge comes into it. Count the number of sources in the graph. Input First line contains the number of vertices n. The next i-th line contains the number of edges adjacent to the i-th vertex, and the vertex numbers where these edges go. Output Print the number of sources in the graph. Sample input 5 1 3 2 1 3 15 2 12 21 2 Sample output 1 5 1 4 3 1 2 3 4 5 (3) (1,3) (5) (1,2) (1,2) Activate Windows Go to Settings to activate Window