The Gateway to Computer Science Excellence
First time here? Checkout the FAQ!
0 votes

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 (98.5k points) | 84 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 (16.1k points)

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

36,187 questions
43,631 answers
42,905 users