Graph Isomorphism

前端 未结 9 1981
陌清茗
陌清茗 2020-12-23 11:04

Is there an algorithm or heuristics for graph isomorphism?

Corollary: A graph can be represented in different different drawings.

What s the best approach to

相关标签:
9条回答
  • 2020-12-23 11:24

    As for heuristics: i've been fantasising about a modified Ullmann's algorithm, where you don't only use breadth first search but mix it with depth first search the way, that first you use breadth first search intensively, than you set a limit for breadth analysis and go deeper after checking a few neighbours, and you lower the breadh every step at some amount. This is practically how i find my way on a map: first locate myself with breadth first search, then search the route with depth first search - largely, and this is the best evolution of my brain has ever invented. :) On the long term some intelligence may be added for increasing breadth first search neighbour count at critical vertexes - for example where there are a large number of neighbouring vertexes with the same edge count. Like checking your actual route sometimes with the car (without a gps).

    0 讨论(0)
  • 2020-12-23 11:27

    One of the best algorithms out there for finding graph isomorphisms is VF2.

    I've written a high-level overview of VF2 as applied to chemistry - where it is used extensively. The post touches on the differences between VF2 and Ullmann. There is also a from-scratch implementation of VF2 written in Java that might be helpful.

    0 讨论(0)
  • 2020-12-23 11:34

    I've found out that the algorithm belongs in the category of k-dimension Weisfeiler-Lehman algorithms, and it fails with regular graphs. For more here:

    http://dabacon.org/pontiff/?p=4148

    Original post follows:

    I've worked on the problem to find isomorphic graphs in a database of graphs (containing chemical compositions).

    In brief, the algorithm creates a hash of a graph using the power iteration method. There might be false positive hash collisions but the probability of that is exceedingly small (i didn't had any such collisions with tens of thousands of graphs).

    The way the algorithm works is this:

    Do N (where N is the radius of the graph) iterations. On each iteration and for each node:

    • Sort the hashes (from the previous step) of the node's neighbors
    • Hash the concatenated sorted hashes
    • Replace node's hash with newly computed hash

    On the first step, a node's hash is affected by the direct neighbors of it. On the second step, a node's hash is affected by the neighborhood 2-hops away from it. On the Nth step a node's hash will be affected by the neighborhood N-hops around it. So you only need to continue running the Powerhash for N = graph_radius steps. In the end, the graph center node's hash will have been affected by the whole graph.

    To produce the final hash, sort the final step's node hashes and concatenate them together. After that, you can compare the final hashes to find if two graphs are isomorphic. If you have labels, then add them (on the first step) in the internal hashes that you calculate for each node.

    There is more background here:

    https://plus.google.com/114866592715069940152/posts/fmBFhjhQcZF

    You can find the source code of it here:

    https://github.com/madgik/madis/blob/master/src/functions/aggregate/graph.py

    0 讨论(0)
提交回复
热议问题