I am interested in listing all the unlabeled1 acyclic digraphs with n vertices which satisfy some additional constraints, such as (a) the resulting graph is connected and (b) except for R
identified root vertices, all vertices have two incoming edges and zero or one outgoing edges.
There may also be additional domain-specific constraints, but they are probably easy enough to implement by simply generating and rejecting graphs that do not meet the constraints. In principle, conditions (a) and (b) above could be satisfied in this way above, but at least in the case of (b) it seems very advantageous to consider them directly in generating process since the output is likely to be quite sparse (i.e., a large majority of graphs will fail to satisfy (b) and this ration increases with increasing n).
My problem is twofold:
Even ignoring the constraints part, I have not be able to determine how to efficiently generate DAGs. I know there are a lot of them so I'll mostly be dealing with smallish n, let's say
n < 15
. There seem to be some promising papers, although may of them are focused on the closed-form counting of the number of graphs rather than actual generation, and any remaining ones are paywalled.I want to apply the at least enough of the constraint part during the generation to avoid the case where nearly all generated graphs are simply rejected. That is, I hope the generation of the constrained graphs is considerably faster than the generation of the much larger number without constraints.
You can find lots of information on random generation of such graphs, but not much on exhaustive generation (which seems like the easier of the two problems).
1 That is, I want to exclude generation of isomorphic graphs.
nauty
andgeng
but they didn't seem like a good fit here. In particular,geng
is focused mostly on undirected graphs - the approach to get directed graphs seems to be to generate all the underlying undirected skeletons, and then to use the option innauty
to generate all orientations of the skeletons. Unfortunately, this doesn't work well at all with constraints - many of the constraints cannot be expressed at all in the undirected graph. – BeeOnRope Jul 12 '16 at 18:57nauty
/geng
are a poor fit. As you suggest I will also integrate a note about that into the the question. – BeeOnRope Jul 12 '16 at 19:11