Normally, UndirectedGraph
preserves the vertex names and the vertex ordering.
UndirectedGraph[Graph[{"a" -> "b"}], VertexLabels -> Automatic]
But sometimes it does not:
g = Graph[{1 <-> 0, 0 <-> 2}, VertexLabels -> Automatic]
dg = DirectedGraph[g, "Acyclic", VertexLabels -> Automatic]
ug = UndirectedGraph[%, VertexLabels -> Automatic]
EdgeList[g]
(* {1 \[UndirectedEdge] 0, 0 \[UndirectedEdge] 2} *)
EdgeList[ug]
(* {1 \[UndirectedEdge] 2, 2 \[UndirectedEdge] 3} *)
Is this inconsistency a bug? What is different between the first directed graph and the above example and dg
that causes UndirectedGraph
to process them differently?