简体   繁体   English

图同构

[英]Graph Isomorphism

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 find different drawing of a graph? 找到不同图形图的最佳方法是什么?

It is a hell of a problem. 这是一个问题的地狱。

In general, the basic idea is to simplify the graph into a canonical form, and then perform comparison of canonical forms. 一般来说,基本思想是将图形简化为规范形式,然后执行规范形式的比较。 Spanning trees are generated with this objective, but spanning trees are not unique, so you need to have a canonical way to create them. 使用此目标生成生成树,但生成树不是唯一的,因此您需要使用规范方法来创建它们。

After you have canonical forms, you can perform isomorphism comparison (relatively) easy, but that's just the start, since non-isomorphic graphs can have the same spanning tree. 在有规范形式之后,您可以轻松地执行同构比较(相对),但这只是一个开始,因为非同构图可以具有相同的生成树。 (eg think about a spanning tree T and a single addition of an edge to it to create T'. These two graphs are not isomorph, but they have the same spanning tree). (例如,考虑一个生成树T和一个边缘的单独添加来创建T'。这两个图不是同构,但它们具有相同的生成树)。

Other techniques involve comparing descriptors (eg number of nodes, number of edges), which can produce false positive in general. 其他技术涉及比较描述符(例如,节点数,边数),其通常可以产生误报。

I suggest you to start with the wiki page about the graph isomorphism problem . 我建议你从关于图同构问题的维基页面开始。 I also have a book to suggest: "Graph Theory and its applications" . 我还有一本书建议: “图论及其应用” It's a tome, but worth every page. 这是一本书,但值得每一页。

As from you corollary, every possible spatial distribution of a given graph's vertexes is an isomorph. 从你的推论出发,给定图的顶点的每个可能的空间分布都是同构的。 So two isomorph graphs have the same topology and they are, in the end, the same graph, from the topological point of view. 因此,两个同构图具有相同的拓扑结构,从拓扑的角度来看,它们最终是相同的图形。 Another matter is, for example, to find those isomorph structures enjoying particular properties (eg with non crossing edges, if exists), and that depends on the properties you want. 另一个问题是,例如,找到那些享有特定属性的同构结构(例如,如果存在非交叉边缘),这取决于您想要的属性。

One of the best algorithms out there for finding graph isomorphisms is VF2. 寻找图同构的最佳算法之一是VF2。

I've written a high-level overview of VF2 as applied to chemistry - where it is used extensively. 我已经写了一篇应用于化学的VF2的高级概述 - 它被广泛使用。 The post touches on the differences between VF2 and Ullmann . 该帖子涉及VF2和Ullmann之间的差异。 There is also a from-scratch implementation of VF2 written in Java that might be helpful. 还有一个用Java编写的VF2的从头开始实现可能会有所帮助。

A very similar problem - graph automorphism - can be solved by saucy , which is available in source code. 一个非常相似的问题 - 图自同构 - 可以通过源代码中提供的saucy来解决。 This finds all symmetries of a graph. 这可以找到图形的所有对称性。 If you have two graphs, join them into one and any isomorphism can be discovered as an automorphism of the join. 如果你有两个图,将它们连接成一个,任何同构都可以被发现为连接的自同构。

Disclaimer: I am one of co-authors of saucy. 免责声明:我是俏皮的合着者之一。

There are algorithms to do this -- however, I have not had cause to seriously investigate them as of yet. 有算法可以做到这一点 - 但是,我还没有理由认真研究它们。 I believe Donald Knuth is either writing or has written on this subject in his Art of Computing series during his second pass at (re)writing them. 我相信唐纳德·克努特(Donald Knuth)正在写作或者在他的第二次传递(重新)写作时,在他的计算机艺术系列中写过这个主题。

As for a simple way to do something that might work in practice on small graphs, I would recommend counting degrees, then for each vertex, also note the set of degrees for those vertexes that are adjacent. 至于在小图上做一些可能在实践中起作用的简单方法,我建议计算度数,然后对于每个顶点,还要注意那些相邻顶点的度数集。 This will then give you a set of potential vertex isomorphisms for each point. 然后,这将为每个点提供一组潜在的顶点同构。 Then just try all those (via brute force, but choosing the vertexes in increasing order of potential vertex isomorphism sets) from this restricted set. 然后尝试所有这些(通过强力,但从潜在顶点同构集的增加顺序中选择顶点)来自此受限集。 Intuitively, most graph isomorphism can be practically computed this way, though clearly there would be degenerate cases that might take a long time. 直觉上,大多数图形同构可以通过这种方式实际计算,但显然会出现可能需要很长时间的退化情况。

My project - Griso - at sf.net: http://sourceforge.net/projects/griso/ with this description: 我的项目- Griso -在sf.net: http://sourceforge.net/projects/griso/有这样的描述:
Griso is a graph isomorphism testing utility written in C++. Griso是用C ++编写的图形同构测试实用程序。 It is based on my own POLYNOMIAL-TIME (in this point the salt of the project) algorithm. 它基于我自己的POLYNOMIAL-TIME (在这一点上是项目的盐)算法。 See Griso's sample input/output on http://funkybee.narod.ru/graphs.htm page. 请参阅http://funkybee.narod.ru/graphs.htm页面上的Griso示例输入/输出。

我最近发现了以下论文: http//arxiv.org/abs/0711.2010本文提出了“图同构的多项式时间算法”

nauty and Traces are programs for computing automorphism groups of graphs and digraphs [*]. nauty和Traces是用于计算图形和有向图的自同构组的程序[*]。 They can also produce a canonical label. 他们还可以生产规范标签。 They are written in a portable subset of C, and run on a considerable number of different systems. 它们是用C的可移植子集编写的,可以在相当多的不同系统上运行。

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. 至于启发式:我一直在幻想改进的Ullmann算法,你不仅要使用广度优先搜索,而是将其与深度优先搜索方式混合,首先使用广度优先搜索,而不是设置限制检查一些邻居后进行广度分析并进一步深入,并且每一步都要降低一些量。 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). 比如有时用车检查你的实际路线(没有gps)。

I've found out that the algorithm belongs in the category of k-dimension Weisfeiler-Lehman algorithms, and it fails with regular graphs. 我发现该算法属于k维Weisfeiler-Lehman算法的类别,并且它失败了常规图。 For more here: 更多信息:

http://dabacon.org/pontiff/?p=4148 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. 做N(其中N是图的半径)迭代。 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. 在第二步,节点的哈希受到距离它的2跳的邻域的影响。 On the Nth step a node's hash will be affected by the neighborhood N-hops around it. 在第N步,节点的散列将受到其周围的邻域N跳的影响。 So you only need to continue running the Powerhash for N = graph_radius steps. 所以你只需要继续运行Powerhash for N = graph_radius步骤。 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 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 https://github.com/madgik/madis/blob/master/src/functions/aggregate/graph.py

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM