nintendo
nintendo

Reputation: 140

Calculate all possible connected planar graphs with "E" edge

I'm developing a c++ program which calculate and draw all possible connected planar graphs with given E number edge. Like this :

My first thought was to find all possible solutions for the N edge by adding one edge to after finding the answer to (n-1) by doing recursion.

As you can see in the picture, the solution of the problem n = 4 is basically an improved version of the solution n = 3 with one edge more.

But it did not feel like a very effective solution. I could not find this problem in a particular algorithm.

is there any other way of finding and drawing all possible connected planar graphs with E edge?

Upvotes: 3

Views: 236

Answers (1)

MT0
MT0

Reputation: 168351

is there any other way of finding and drawing all possible connected planar graphs with E edge?

Start with the complete graph K(E+1) - this will have (E+1) vertices and E(E+1)/2 edges. Enumerate the edges 1 .. E(E+1)/2.

  • For each permutation of E values from the set <1 .. E(E+1)/2>
    • Keep those E edges and delete the rest
    • Delete any unconnected vertices
    • If the graph is connected, planar and is not isomorphic to a previous graph then
      • It is a new unique graph with E edges.

You can probably perform significant optimisations by considering the symmetry of the complete graph and eliminating permutations that have a combination of rotational and/or reflectional symmetry with a previous permutation.

Upvotes: 3

Related Questions