【问题标题】:VF2 algorithm - implementationVF2 算法 - 实现
【发布时间】:2013-11-09 21:56:01
【问题描述】:

我的 VF2 算法实现有问题。在许多情况下,一切似乎都运行良好,但是有一个问题我无法解决。

该算法不适用于以下示例。在此示例中,我们正在比较两个相同的图表(见下图)。起始顶点为 0。 在 s0 内部计算的集合 P 存储了所有顶点对的幂集。

以下是关于 VF2 的出版物中包含的伪代码,我的实现正是基于该伪代码。

http://citeseerx.ist.psu.edu/viewdoc/download;jsessionid=B51AD0DAEDF60D6C8AB589A39A570257?doi=10.1.1.101.5342&rep=rep1&type=pdf

http://www.icst.pku.edu.cn/intro/leizou/teaching/2012-autumn/papers/part2/VF2%20A%20%28sub%29Graph%20Isomorphism%20Algorithm%20For%20Matching%20Large%20Graphs.pdf

/*右边的注释描述了我理解代码的方式:

我不确定创建 P() 集是否有效,如下所述。对的幂集按字典顺序依次通过对的第一个值和第二个值进行迭代。

PROCEDURE Match(s)
  INPUT: an intermediate state s; the initial state s0 has M(s0)=empty
  OUTPUT: the mappings between the two graphs
  IF M(s) covers all the nodes of G2 THEN
    OUTPUT M(s)
  ELSE
    Compute the set P(s) of the pairs candidate for inclusion in M(s)
    /*by powerset of all succesors from already matched M(s) if not empty or
    /*predestors to already matched M(s) if not empty
    /*or all possible not included vertices in M(s)
    FOREACH (n, m)∈ P(s)
      IF F(s, n, m) THEN
    Compute the state s ́ obtained by adding (n, m) to M(s)
    /*add n to M1(s), exclude from T1(s)
    /*add m to M2(s), exclude from T2(s)
    /*M1(s) is now M1(s'), other structures belong to s' too
    CALL Match(s′)
      END IF
    END FOREACH
    Restore data structures
    /*Return all structures as from before foreach
  END IF
END PROCEDURE

当算法进入 s4 时,当从函数返回时,它会丢失关于良好顶点匹配的信息。 它导致搜索子图同构 ({(0,0),(1,1),(2,2),(5,3),(6,4)}) - 即使图是同构的。

我在这里做错了什么?

【问题讨论】:

  • 已经半年多了。你找到自己问题的答案了吗?还是顺其自然继续前进?

标签: algorithm graph subgraph isomorphism


【解决方案1】:

我认为要知道您的问题“我在这里做错了什么”,有必要在此处包含您的一些代码。您根据论文中提供的伪代码自己重新实现了代码?或者您是在一些图形处理包的帮助下进行匹配的?

对我来说,我没有时间深入研究细节,但我也使用图表,因此我尝试使用 networkx(一个 Python 包)和 Boost 1.55.0 库(非常广泛的 C++ 图表库)。您的示例和具有 1000 个节点、1500 条边的图的另一个示例返回正确的匹配(将图与其自身匹配的简单情况)。

import networkx as nx
G1 = nx.Graph()
G2 = nx.Graph()

G1.clear()
G2.clear()

G1.add_nodes_from(range(0,7))
G2.add_nodes_from(range(0,7))
G1.add_edges_from([(0,1), (1,2), (2,3), (3,4), (2,5), (5,6)])
G2.add_edges_from([(0,1), (1,2), (2,3), (3,4), (2,5), (5,6)])

from networkx.algorithms import isomorphism
GM = isomorphism.GraphMatcher(G2,G1)
print GM.is_isomorphic()
GM.mapping

是的

输出[39]: {0:0、1:1、2:2、3:3、4:4、5:5、6:6}

【讨论】:

    猜你喜欢
    • 2011-12-31
    • 1970-01-01
    • 1970-01-01
    • 2013-11-29
    • 2016-11-06
    • 2020-05-18
    • 2017-12-10
    • 2022-01-05
    • 2011-07-02
    相关资源
    最近更新 更多