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.