+1 vote
112 views

An undirected graph canbe converted into a directed graph by choosing a direction for every edge. Here is an example:

Show that for every undirected graph, there is a way of choosing directions for its edges so that the resulting directed graph has no directed cycles.

asked in Others | 112 views

1 Answer

0 votes

select any random vertex and start BFS algorithm such that if you are at vertex u and going to vertex v direction of the edge will be from u to v, u$\rightarrow$v, maintain a data structure visited[i] which keeps track of unvisited edge if the edge ek is visited we don't perform BFS this will create a directed graph with no back edge. complexity O(V+E)

answered by Boss (17.4k points)

0 votes
1 answer
1
0 votes
0 answers
2
0 votes
1 answer
3
+1 vote
2 answers
4
0 votes
1 answer
5
0 votes
2 answers
6
0 votes
0 answers
7