00-最短路-02-松弛.svg 1.6 KB

1234567
  1. <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 780 270" role="img" aria-labelledby="title desc">
  2. <title id="title">松弛逐步压低距离上界</title><desc id="desc">先通过直边得到距离七,后发现经过 B 的路线把距离降低到三。</desc>
  3. <style>text{font-family:system-ui,sans-serif;fill:#172033}.edge{stroke:#64748b;stroke-width:5;fill:none}.new{stroke:#16a34a;stroke-width:6;fill:none}.node{fill:#fff;stroke:#2563eb;stroke-width:4}.box{fill:#fef3c7;stroke:#d97706;stroke-width:3}.note{font-size:19px}.label{font-size:24px;font-weight:700}</style>
  4. <text x="26" y="31" class="note">dist 不是刻在石头上的答案;发现更便宜的真实路线,就把上界压低。</text>
  5. <path class="edge" d="M120 150 L605 150" marker-end="url(#a)"/><path class="new" d="M120 150 L350 70 L605 150" marker-end="url(#a)"/><circle class="node" cx="120" cy="150" r="29"/><circle class="node" cx="350" cy="70" r="29"/><circle class="node" cx="605" cy="150" r="29"/><text class="label" x="111" y="159">S</text><text class="label" x="341" y="79">B</text><text class="label" x="596" y="159">T</text><text x="365" y="137" class="note">7</text><text x="220" y="84" class="note" fill="#15803d">1</text><text x="484" y="84" class="note" fill="#15803d">2</text>
  6. <rect class="box" x="243" y="205" width="300" height="43" rx="8"/><text x="270" y="234" class="note">dist[T]:∞ → 7 → 3</text><defs><marker id="a" viewBox="0 0 10 10" refX="8" refY="5" markerWidth="7" markerHeight="7" orient="auto"><path d="M0 0 L10 5 L0 10z" fill="#475569"/></marker></defs>
  7. </svg>