2

I have a list of edge lists of some graphs. For example, let's consider the following list

G_list = [[(0,1), (0,2)], [(0,3), (1,3)], [(0,3), (1,3)], [(0,3), (1,3), (2,3)]]

The graphs generated from the above list, G0, G1, G2 and G3 are shown below:

enter image description here

We can see (and check) that G0 is isomorphic to G3. Also, note that G0 is isomorphic to G1, but G0 and G1 are automorphic to each other.

Now I want to find the fastest way to find all pairs of isomorphic graphs in such a list and output them as a list of tuples. It would be even better if we can reject automorphisms from this list.

Here the ideal output from the list should be G_iso = [(G0, G3)]. However note that there can be more than one isomorphic pairs of graphs in the list.

Thanks a ton in advance! Sorry if this is an extremely noob question.

evil_potato
  • 129
  • 4
  • What is an automorphism? – Dani Mesejo Nov 01 '21 at 17:59
  • An automorphism of a graph is a graph isomorphism with itself, i.e., a mapping from the vertices of the given graph back to vertices of such that the resulting graph is isomorphic with. From Wolfram. :) – evil_potato Nov 01 '21 at 18:10
  • 2
    In general, this is a nice question. But it is too specific and too general at the same time: For your specific list, you could do this "hardcoded" after manual evaluation - which is nonsense and trivial. In general, your problem is well known and not so much a question of implementation, but of algorithm, see https://en.wikipedia.org/wiki/Graph_isomorphism_problem. Did you have a read on the existing algorithms? You cannot expect SO members to outperform this ;) – matheburg Nov 01 '21 at 18:15
  • No no, although this list may seem hardcoded, I can assure you it's not. This is just one of many possibilities. – evil_potato Nov 01 '21 at 18:23
  • With regard to my question, I'm not sure if I worded it correctly (English isn't my primary language). I want to be able to take two of these lists in G_list and just check for isomorphic pairs. If they're isomorphic, I'll just store them as a tuple or something. What's the fastest way to do this without having redundant pairs? – evil_potato Nov 01 '21 at 18:26
  • 1
    Adding a smaller example of your problem could improve your question, such as a graph with a minimal number of edges to illustrate the problem and what the result it would have looks like! – ti7 Nov 01 '21 at 18:31
  • Thanks, @ti7 for your comment! I read it last night but it was too late and I decided to call it a day. I have tried to make improvements to the question. Hope this helps :) – evil_potato Nov 02 '21 at 04:29
  • `networkx` does have an implementation for checking for isomorphisms [here](https://networkx.org/documentation/stable/reference/algorithms/generated/networkx.algorithms.isomorphism.is_isomorphic.html). Whether the heuristic and implementation will be optimal for your case will depend on your graph structures. – Paul Brodersen Nov 02 '21 at 15:28
  • I'll actually be checking for a large number of graphs, and it's taking some time. On top of that, I'll be checking over some SRG (Strongly regular graphs) families. I'm also looking at Nauty but I'm yet to figure out the implementation, especially with my python interface. – evil_potato Nov 02 '21 at 17:04

0 Answers0