• Courses
  • Tutorials
  • Jobs
  • Practice
  • Contests
June 01, 2022 |1.1K Views
Assign directions to edges so that the directed graph remains acyclic
  Share   Like
Description
Discussion

Given a graph with both directed and undirected edges. It is given that the directed edges don’t form cycle. How to assign directions to undirected edges so that the graph (with all directed edges) remains acyclic even after the assignment?
1) Consider the subgraph with directed edges only and find topological sorting of the subgraph. In the above example, topological sorting is {0, 5, 1, 2, 3, 4}. Below diagram shows topological sorting for the above example graph.

Assign directions to edges so that the directed graph remains acyclic : https://www.geeksforgeeks.org/assign-directions-to-edges-so-that-the-directed-graph-remains-acyclic/