查找图中的最小割边

发布于 2024-11-03 20:55:49 字数 256 浏览 1 评论 0原文

给定一个随机无向图,我必须找到“瓶颈边”(编辑:最小切割边)才能从一个顶点到达另一个顶点。

我所说的“瓶颈边缘”(编辑:最小切割边缘)-- 假设我有以下无向图:

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

要独立于所选路径边BE和DG从A到H,必须始终遍历BE和DG,因此形成“瓶颈”(编辑:最小切割)。

有一个多项式时间算法吗?

Given a random undirected graph, I must find 'bottleneck edges' (edit: minimum cut edges) to get from one vertex to another.

What I call 'bottleneck edges' (edit: minimum cut edges) --
suppose I have the following undirected 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' (edit: minimum cut).

Is there a polynomial time algorithm for this?

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

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

发布评论

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

评论(2

你不是我要的菜∠ 2024-11-10 20:55:49

听起来您需要最小切割,即删除最小的边集,这会将您的图形分成两部分。

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

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

寄风 2024-11-10 20:55:49

您正在寻找的是剪切。给定一个图,切割是一组边,它将顶点划分为两个不相交的子集。

假设您正在尝试获得尽可能小的切割,这是经典的最小切割问题。这是 Ford-fulkerson 算法的伪代码版本,针对您的情况进行了重新设计(无向、未加权图表)。我很确定它应该有效,但我不确定我是这里最高效/最惯用的。

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

例如,在您的情况下,BFS 将为我们提供路径 ABEH。删除这些边后,我们仍然能够找到路径 ADGH。删除这些边后,图被划分为可达顶点{A,B,C,D}和不可达顶点{E,F,G,H}。具有来自每个(BE 和 DG)集合的顶点的边是瓶颈边。

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.

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