简体   繁体   English

如何用双连通组件创建图形?

[英]How to create a graph out of biconnected components?

I have a graph and I have identified all of its biconnected components and all of its critical vertexes/articulation points using Tarjan's Algorithm.我有一个图表,我已经使用 Tarjan 算法识别了它的所有双连接组件及其所有关键顶点/关节点。

I am trying to create a new graph using the biconnected components: the components will be the new vertices and two biconnected components are linked if they share at least one articulation point.我正在尝试使用双连通组件创建一个新图:组件将成为新顶点,如果两个双连通组件共享至少一个关节点,则它们将被链接。

For example, for the graph in the image below, the adjacency lists for the new graph would be:例如,对于下图中的图形,新图形的邻接列表将是:

(1, 3) -> (3, 4, 5), (1, 2) (1, 3) -> (3, 4, 5), (1, 2)

(1, 2) -> (1, 3) (1, 2) -> (1, 3)

(3, 4, 5) -> (1, 3) (3, 4, 5) -> (1, 3)

where (1, 3), (1, 2), (3, 4, 5) are the biconnected components and 1, 3 are articulation points.其中 (1, 3), (1, 2), (3, 4, 5) 是双连通分量,1, 3 是关节点。 How could I create the new graph/the adjacency lists in a relatively optimal way?如何以相对最佳的方式创建新图/邻接列表? Can I do it while I'm running Tarjan on the graph?我可以在图表上运行 Tarjan 时执行此操作吗?

在此处输入图像描述

Edit: A biconnected component is a subset of the vertices of the graph where every vertex in this subset will remain connected even if you remove any vertex of the graph.编辑:双连接组件是图形顶点的子集,即使您删除图形的任何顶点,该子集中的每个顶点都将保持连接。 Wiki page for biconnected component双连接组件的 Wiki 页面

Yes you can do it quite easily using DSU(Disjoint Set Union, aka Union Find) data structure.是的,您可以使用 DSU(不相交集联合,又名联合查找)数据结构很容易地做到这一点。

The key is noticing some observations:关键是注意到一些观察结果:

  • New graph will be a tree or forest of trees (why? - any cycle is bi-connected so it will belong to same component)新图将是一棵树或树的森林(为什么? - 任何循环都是双向连接的,因此它属于同一组件)
  • The edges of resulting tree will be bridges of original graph (the resulting tree is also known as "Bridge tree")结果树的边缘将是原始图的桥梁(结果树也称为“桥树”)

Now we can already do some tarjan modifications:现在我们已经可以做一些 tarjan 修改了:

  • for every edge (u,v) if it's a bridge save it for later use对于每条边(u,v)如果它是一座桥,则将其保存以备后用
  • if its not a bridge, use DSU to merge disjoint sets u and v belong to如果它不是桥,则使用 DSU 合并不相交的集合uv属于
  • To construct the resulting tree after tarjan is over we can use saved bridges and remaining disjoint sets,为了在 tarjan 结束后构建结果树,我们可以使用保存的桥和剩余的不相交集,
  • (opt) we can enumerate disjoint sets if we wish to do so, but because there will never 2 bridges between 2 disjoint sets (that would make a cycle hence contradiction) we can just use disjoint sets identity vertices for new graph (选择)如果我们愿意,我们可以枚举不相交的集合,但是因为在 2 个不相交的集合之间永远不会有 2 个桥(这会产生一个循环,因此会产生矛盾),我们可以只使用不相交的集合身份顶点作为新图

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

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