【发布时间】:2013-11-09 21:56:01
【问题描述】:
我的 VF2 算法实现有问题。在许多情况下,一切似乎都运行良好,但是有一个问题我无法解决。
该算法不适用于以下示例。在此示例中,我们正在比较两个相同的图表(见下图)。起始顶点为 0。 在 s0 内部计算的集合 P 存储了所有顶点对的幂集。
以下是关于 VF2 的出版物中包含的伪代码,我的实现正是基于该伪代码。
/*右边的注释描述了我理解代码的方式:
我不确定创建 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