[Tutor] (no subject)

singh000taran at gmail.com
Sun Mar 14 08:39:58 EDT 2021

```Dear sir, I have not studies graph-related things in python. While
answering please try to be more descriptive; I will be grateful if you do
so.

Question - In this problem, you need to create a program for managing
Graphs. The input to the program will be as described next: The first line
will contain a positive integer NN. NN denotes the number of nodes in the
graph. Nodes themselves are numbered from 0 to N−1N−1. The second line will
contain a non-negative integer MM (M≥0M≥0). This will be the number of
edges in the graph (However, some of these could be invalid/duplicate). The
next MM lines each will contain a pair of integers i,ji,j representing a
directed edge i→ji→j. Self edges (i→ii→i) are allowed. However, multi-edges
(two or more instances of i→ji→j) have to be stored only once. Last line
will contain an integer kk. The output of the program is: If kk represents
a valid node, print all the nodes ss such that s→ks→k is a (directed) edge
in the graph. The nodes have to be in sorted order, separated by COMMA (no
whitespace). If kk does not represent a valid node, print "ERROR: Invalid
Node." EXAMPLES ___________________________________ INPUT: 3 4 0,1 1,2 2,0
0,2 2 OUTPUT: 0,1 _____________________________ INPUT: 3 4 0,1 0,2 2,0 0,2
2 OUTPUT: 0 _____________________________ INPUT: 1 0 0 OUTPUT: (Note empty
output) _____________________________ NOTE: Remember that Self edges (i→ii→i)
are allowed. Multi-edges (two or more instances of i→ji→j) have to be
counted only once.
```