知识卡片

普通读书笔记卡 · 3658.a.2.c

BF判差分约束可行

理解等级:中级

差分约束 x_j−x_i≤b_k 对应约束图中的边 v_i→v_j,权重为 b_k;另加源点 v_0 和到每个变量顶点的 0 权边。若图无负环,令 x_i=δ(v_0,v_i),最短路的三角不等式 δ(v_0,v_j)≤δ(v_0,v_i)+b_k 正好给出原约束。

  • Bellman–Ford 返回真时,各最短路距离给出一组可行解;
  • 返回假表示存在负权环。沿环把对应约束相加,左侧变量差望远镜消成 0,右侧却为负数,得到 0≤负数 的矛盾,因此系统无解。

附加源点使所有变量顶点可达,所以任意负环都能被检出。n 个变量、m 条约束产生 V=n+1、E=n+m,Bellman–Ford 的 O(VE) 即 O(n²+nm)。

这张卡片看不懂?

已有反馈 · 0 条

    还没有人提交反馈。

    在整书笔记中的位置

    原书出处 · 1 处

    • 第22章 单源最短路径 · 查看原书依据

      Theorem 22.9 suggests how to use the Bellman-Ford algorithm to solve a system of difference constraints. Because the constraint graph contains edges from the source vertex v0 to all other vertices, any negative-weight cycle in the constraint graph is reachable from v0. If the Bellman-Ford algorithm

    参考来源

    - 位置:《算法导论(第4版)》第22章《单源最短路径》(OEBPS/chapter022.xhtml,文本字符[54000,55300))。 - 结论依据:原文说明附加源的可达性、布尔结果与输出解,并在下一段计算图规模和复杂度。 - 原始内容:Theorem 22.9 suggests how to use the Bellman-Ford algorithm to solve a system of difference constraints. Because the constraint graph contains edges from the source vertex v 0 to all other vertices, any negative-weight cycle in the constraint graph is reachable from v 0 . If the Bellman-Ford algorithm