The Gateway to Computer Science Excellence
First time here? Checkout the FAQ!
+1 vote

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 (115k points) | 127 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.8k 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
47,932 questions
52,335 answers
67,816 users