# Prove that every undirected graph has some orientation that is a Directed Acyclic Graph.

Prove that every undirected graph has some orientation that is a Directed Acyclic Graph.

I understand that in graph theory, an acyclic orientation of an undirected graph is an assignment of a direction to each edge (an orientation) that does not form any directed cycle and therefore makes it into a directed acyclic graph. Every graph has an acyclic orientation. But I'm not sure how to prove it. Any help would be appreciated!

• Orient each edge according to the levels given by a Breadth First Search. – logarithm May 6 '19 at 1:56
• NB – there are a few notions of graph in common use. This problem applies to graphs without self-loops. – Rylee Lyman May 6 '19 at 2:03

We give a simple algorithm that orients the edges of $$G$$ to get a DAG. Number the vertices $$n$$ vertices of $$G$$ arbitrarily $$\{v_1,\ldots, v_n\}$$. If $$v_i$$ and $$v_j$$ are adjacent in $$G$$, then direct the edge $$v_iv_j$$ as follows: If $$i < j$$ direct $$v_iv_j$$ towards $$j$$; otherwise direct the edge towards $$i$$.

The resulting orientation of the edges has no directed cycles. Indeed, for each $$i$$, every vertex reachable from $$v_i$$ is of the form $$v_k; k > i$$.

• Same as @PkT 's answer. – Ethan Bolker May 6 '19 at 2:05
• @Ethan, yes, to a degree. But I like this formulation better since it doesn't need to depend on building the graph one node at a time. Others might prefer the other one for that exact same reason. – hmakholm left over Monica May 6 '19 at 2:09

Add vertices $$\{v_1, \cdots, v_n\}$$ to the directed graph one by one. When vertex $$v_i$$ is added, assign all edges between $$v_i$$ and $$\{v_1, \cdots, v_{i-1}\}$$ to be outgoing from $$v_i$$.

Once the process is done, $$v_n$$ is not in a directed cycle. So we can remove $$v_n$$ and its associated edges. Now $$v_{n-1}$$ cannot be in any cycles, and so on. This means that we came up with an acyclic directed version of our graph.

• Same as @Mike 's answer. – Ethan Bolker May 6 '19 at 2:05

Any undirected graph can be made in to finite number of directed graphs, Now there are two cases, none of these directed graphs have a cycle (A) and you have at least one (B). So if it is case (A) we have at least one Directed Acyclic Graph. For Case(B), Take all cases with the cycle, and flip the direction of one of the edge to make it a Directed Acyclic graph or all cycles can be removed by flipping an edge.

Im not a math guy. so just an idea

• The problem is that if you don't do this systematically, then flipping edges to remove some cycles creates new cycles. And if you do do this systematically, you need to say how. – Misha Lavrov May 6 '19 at 7:59