Are there Graph Theory Programs for generating graphs based on a set of constraints?

95 Views Asked by At

After completing the puzzle game The Witness, I have become quite curious about the math and theory behind it's grid-based puzzles. Some of the types of questions I have found myself asking are:

  • How many possible paths are their on a given grid?
  • How many paths that with non-trivial differences are there that fit the rules of this puzzle?
  • How would the number of viable paths change if one of the rules was changed?

I have done some experimenting and research on my own and quickly discovered that the difficulty of answering these questions goes up substantially with each new node added. So far, all of my experimentation has been done on graph paper - physical or digital - which can get extremely tedious with graphs of any substantial number of nodes.

So my question is this:

Are there any relatively-easy-to-use software programs that would let me experiment with these kinds of graph theory problems?

I.E. defining a set of nodes, possible edges, and rules for what edges are "active" or "used" or something like that, and having the program generate all possible graphs that fulfill my specified ruleset using my defined nodes and edges.

To illustrate the kinds of things I'm looking to produce, I've created some images of graphs on a 3x3 grid of nine nodes, where the only potential edges are between adjacent nodes and an additional rule has been applied:

Fig. 1: Picture showing a set of 25 graphs where every node is joined to no fewer than one and no more than two other nodes.

Fig. 2: Picture showing an set of 5 graphs, where black nodes must have either zero or two edges, green nodes (start/end) must have one edge, and the two red squares must be separated.

(These images do not contain all possible graphs that fit the rules, but hopefully contain enough to make the rules clear.)