# Enumerating all orientations of an undirected graph

Given an undirected graph $G$, an orientation of $G$ is a directed graph obtained by assigning every edge a direction, a superorientation of $G$ is a directed graph obtained by orienting every edge in one direction or both ways.

I'm trying to enumerate all superorientations (isomorphic superorientations count as one) of an undirected graph. Since graph isomorphism problem is NP-intermediate, I never intended to ask digraphs in the enumeration to be pairwise non-isomorphic. But since the list can be exponentially large, I want to make it as compact as possible, or in other words, to make isomorphic graphs as less as possible.

My attempt is given below.

SuperOrientation[g_Graph]:=Module[{el,tal,al},
el=EdgeList[g];
tal=DirectedEdge@@@el;
Graph/@al];


But it yields too many isomorphic graphs. My question is whether we have other ways to work around. Even we cannot make any improvements in general, but how about some special classes of graphs, say symmetric graphs?

Any suggestions or comments are welcome!

• You said "isomorphism is allowed." Do you mean isomorphic superorientations are considered the same, or counted differently? I'm not sure which is meant by "allowed." If the answer is they are counted differently, there are $3^{|E|}$. I suppose if it's not that simple, "allowed" means isomorphic graphs all count as one. – Kellen Myers Apr 2 '16 at 22:22
• @KellenMyers Sorry for the confusion caused. When I said allowing isomorphism, I mean all isomorphic superorientations count as one. I will update the description in the post later. – hxiao Apr 3 '16 at 2:49

The directg tool from the nauty suite can do this: generate all non-isomorphic orientations of an undirected graph.

It takes its input in Graph6 format, which Mathematica can export to.

It outputs results in Digraph6 format, which the IGraph/M package can handle.

I have directg installed in /opt/local/bin, so I can use

g = CycleGraph[3]

Needs["IGraphM"]
IGImportString[
RunProcess["/opt/local/bin/directg", "StandardOutput",
ExportString[g, "Graph6"]],
"Digraph6"
]


Pass the -o option to orient every edge in a single direction only:

IGImportString[
RunProcess[{"/opt/local/bin/directg", "-o"}, "StandardOutput",
ExportString[g, "Graph6"]],
"Digraph6"
]


If you only need to count orientations, not output them, directg` has an option for that.