in Graph Theory edited by
769 views
1 vote
1 vote

An undirected graph can be 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.

in Graph Theory edited by
769 views

2 Answers

3 votes
3 votes
Best answer
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 $\text{visited[i]}$ which keeps track of unvisited edge -- if the edge $e_k$ is visited we do not perform BFS. This will create a directed graph with no back edge. Complexity -- $O(V+E)$
selected by
0 votes
0 votes

Answer:

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