Depth First Search#8760

Depth First Search

1 másodperc
128 megabájt
Könnyű

The undirected graph is given. Start a depth-first search from the given vertex and print the vertex numbers in the order of their first visit.

Bemenet

The first line contains the number of vertices n~(n \le 100) and edges of the graph. Each of the following lines contains two vertices and — an undirected edge of the graph. The last line contains the vertex .

Kimenet

Start a depth-first search from vertex and print the vertex numbers in the order of their first visit.

Példák

1. példa

Loading
Loading

2. példa

Loading
Loading