检查删除图中的边是否会导致图分裂
我有一个图形结构,我将一一删除边缘,直到满足某些条件。我的大脑完全停止了,我找不到有效的方法来检测删除边缘是否会导致我的图分裂成两个或更多图。
强力解决方案是进行 bfs,直到可以从随机节点到达所有节点,但这对于大图来说会花费太多时间......
有什么想法吗?
编辑:经过一番搜索后,我想做的事情似乎与 fleury 的算法非常相似,我需要查找一条边是否是“桥”。
I have a graph structure where I am removing edges one by one until some conditions are met. My brain has totally stopped and i can't find an efficient way to detect if removing an edge will result in my graph splitting in two or more graphs.
The bruteforce solution would be to do an bfs until one can reach all the nodes from a random node, but that will take too much time with large graphs...
Any ideas?
Edit: After a bit of search it seems what I am trying to do is very similar to the fleury's algorithm, where I need to find if an edge is a "bridge" or not.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
删除后使图断开连接的边称为“桥”。通过对整个图进行一次深度优先搜索,您可以在 O(|V|+|E|) 中找到它们。相关算法会找到所有的“连接点”(如果删除的话,会使图形断开连接的节点)。两个铰接点之间的任何边缘都是桥(您可以在第二次遍历所有边缘时进行测试)。
Edges that make a graph disconnected when removed are called 'bridges'. You can find them in O(|V|+|E|) with a single depth-first search over the whole graph. A related algorithm finds all 'articulation points' (nodes that, if removed, makes the graph disconnected) follows. Any edge between two articulation-points is a bridge (you can test that in a second pass over all edges).
如果删除顶点 A 和 B 之间的链接,难道不能检查边删除后是否仍然可以从 B 到达 A 吗?这比从随机节点获取所有节点要好一些。
If you remove the link between vertices A and B, can't you just check that you can still reach A from B after the edge removal? That's a little better than getting to all nodes from a random node.
如何选择要删除的边缘?
您能详细介绍一下您的问题领域吗?
你的图表有多大?也许 BFS 就可以了!
当你写到你试图找出一条边是否是一座桥之后,我建议
您按照边的介数度量的降序删除边。
本质上,介数是对图中边(或顶点)中心性的度量。
介数值较高的边更有可能成为图中的桥梁。
网上查了一下,这个算法叫“Girvan-Newman算法”。
How do you choose the edges to be removed?
Can you tell more about your problem domain?
Just how large Is your graph? maybe BFS is just fine!
After you wrote that you are trying to find out whether an edge is a bridge or not, I suggest
you remove edges in decreasing order of their betweenness measure.
Essentially, betweenness is a measure of an edges (or vertices) centrality in a graph.
Edges with higher value of betweenness have greater potential of being a bridge in a graph.
Look it up on the web, the algorithm is called 'Girvan-Newman algorithm'.