Assume that I have a mixed graph with some directed edges (the number of directed edges can be from 1 to 10).
This is an example of such graph g1
with 3 directed edges called a, b, c
.
Now I would like to create all possible graphs which are formed by permuting the directed edges.
From 3 directed edges, it is possible to generate 6 possible graphs below.
If g1
is given, how can we create all 6 graphs from g1
to g6
?
The condition of permuting directed edges are that the arrow direction should keep same and the two vertice associated with the edge should be moved together with the edge.
I'm trying to write a code to do this automatically for a graph with any number of directed edges less than 10.
Also it would be nice if it can be run quickly as I'll have to run it for billion times.
(the edge label is not important, just for presenting the problem)
myGraph[edges_] :=
Graph[edges, {EdgeStyle -> {Black},
VertexLabels -> {Placed[Automatic, Above]},
VertexLabelStyle -> {Red},
VertexStyle -> {Directive[Red, EdgeForm[None]]}}];
g1 = myGraph[{1 \[UndirectedEdge] 2, 2 \[UndirectedEdge] 3,
3 \[DirectedEdge] 4, 4 \[UndirectedEdge] 5, 6 \[DirectedEdge] 5,
6 \[UndirectedEdge] 7, 7 \[DirectedEdge] 8, 8 \[UndirectedEdge] 9,
9 \[UndirectedEdge] 10}]