I'm trying to determine that shape of a directed graph by solving constraints on presence of nodes and arcs, e.g., binary variable V1V2
is 1
if there is an arc from node V1
to V2
. I would like to express the reachability constraint (or, alternatively, find a transitive closure), e.g., to require that the graph is connected, or that there is a path from one given node to another given node.
I've seen that SICStus Prolog has fd_closure
for this purpose, but I could not find anything similar in SWI Prolog. Should I use CHR? I've been looking at the arc/path consistency examples but I'm not sure whether I'm looking in the right direction.