Finding 'bottleneck edges' in a graph

落花浮王杯 提交于 2019-12-09 03:11:19

问题


Given a random unidirected graph, I must find 'bottleneck edges' to get from one vertex to another.

What I call 'bottleneck edges' (there must be a better name for that!) -- suppose I have the following unidirected graph:

    A
  / | \
 B--C--D
 |     |
 E--F--G
  \ | /
    H

To get from A to H independently of the chosen path edges BE and DG must always be traversed, therefore making a 'bottleneck'.

Is there a polynomial time algorithm for this?

edit: yes, the name is 'minimum cut' for what I meant witch 'bottleneck edges'.


回答1:


Sounds like you need minimum cut, the minimal set of edges removing which will separate your graph into two pieces.

http://en.wikipedia.org/wiki/Minimum_cut




回答2:


What you are looking for is a cut. Given a graph, a cut is a set of edges that partitions the vertices into two disjoint subsets.

Assuming you are trying to get the smallest cut possible, this is the classic min-cut problem. Here is a pseudo code version of the Ford-fulkerson algorithm, reworked for your case (undirected, unweighted graphs). I'm pretty sure it should work, but I am not sure I'm being the most efficient / idiomatic here.

reorganize your graph into a directed graph,
  with two directed edges (u->v, v->u) for each original edge (u-v)

while there is a path P from A to H:
  (hint: use breadth first search to find paths - long story here)
  //augment the path P:
  for each edge (u->v) in P:
    remove (u->v) from the graph and add (v->u) to it
    (if v->u isn't there already)

Label all vertices as reacheable or not reacheable from A.

The bottleneck edges is the set of edges
  that connect a reacheable and a unreacheable vertex

For example, in your case BFS would give us the path A-B-E-H. After removing these edges, we would still be able to find the path A-D-G-H. After these edges are removed, the graph is partitioned into the reacheable vertices {A,B,C,D} and the unreacheable {E,F,G,H}. The edges that have a vertex from each (B-E and D-G) set are the bottleneck edges.



来源:https://stackoverflow.com/questions/5810703/finding-bottleneck-edges-in-a-graph

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!