计算子图实例

发布于 2024-10-04 05:04:45 字数 215 浏览 8 评论 0原文

假设我有一个大的(几千个节点)有向图G和一个小得多的(3-5个节点)有向图g。我想计算G中有多少个g同构。换句话说,我想知道G中有多少个唯一的节点集与g匹配。我意识到这是子图同构问题的一个实例,因此是 NP 完全的。但是,考虑到您可能假设 g 很小,是否有任何相当有效的算法可以做到这一点?

Let's say I have a large (several thousand node) directed graph G and a much smaller (3-5 node) directed graph g. I want to count how many isomorphisms of g are in G. In other words, I want to know how many unique sets of nodes in G match g. I realize that this is an instance of the subgraph isomorphism problem and is therefore NP-complete. However, given that you may assume that g is small, is there any reasonably efficient algorithm for doing this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

过气美图社 2024-10-11 05:04:45

尽管图同构通常是 NP 完全的,但在现实世界中遇到的问题通常非常简单。一个简单的暴力破解就足够了:设 M_i 为从 g 的前 i 个节点到 G 的节点的一组映射。从包含空映射的 m_0 开始并扩展一次一个节点,当且仅当m(x)->m(y)时,丢弃任何违反约束x->y的映射。

您需要对 g 中的节点进行排序,以便尽早进行大量修剪。假设你的图非常稀疏,你会想要一个尽早完成尽可能多的边的顺序,也许是来自最高度节点的 dfs。

Although graph isomorphism is NP-complete in general, problems you come across in the real world are often pretty easy. A simple brute-force should suffice: Let M_i be a set of maps from the first i nodes of g to nodes of G. Start with m_0 containing the empty map and extend it one node at a time, discarding any maps which violate the constraint x->y iff m(x)->m(y).

You'll want to order the nodes in g so that lots of pruning happens early. Assuming your graphs are pretty sparse, you'll want an order that completes as many edges as early as possible, maybe a dfs from the highest degree node.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文