The Gateway to Computer Science Excellence
First time here? Checkout the FAQ!
x
+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 by Veteran (112k points) | 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)

Related questions



Quick search syntax
tags tag:apple
author user:martin
title title:apple
content content:apple
exclude -tag:apple
force match +apple
views views:100
score score:10
answers answers:2
is accepted isaccepted:true
is closed isclosed:true

44,281 questions
49,767 answers
164,271 comments
65,853 users