FANFNA
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights
    • Engagement control
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Versions and GitHub Sync Note Insights Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Engagement control Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       owned this note    owned this note      
    Published Linked with GitHub
    Subscribed
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    Subscribe
    # Max_flow_algo :::spoiler [TOC] ::: ## 介紹 :::success 1. Capacity constraint:從vertex(X)流向vertex(Y)的flow,不能比edge(X,Y)的capacity還大,f(X,Y)≤c(X,Y)。 若每單位時間內,水管孔徑只能容納5單位,那flow最多就是5單位。 以圖二(b)為例,在Path:S−A−C−D−T上的edge之capacity皆大於6,因此在此路徑上流入6單位的flow是可行的。 ![](https://i.imgur.com/WFdHShE.png) <font color="red">左邊</font>為花費/右邊為總數 ::: :::success 2. Skew symmetry:若定義「從vertex(X)指向vertex(Y)」之edge(X,Y)上,有5單位的flow,f(X,Y)=5,這就等價於,從vertex(Y)到vertex(X)之edge(Y,X)上,有−5單位的flow,f(Y,X)=−5。 與「電子流(負電荷)」與「電流(正電荷)」之概念雷同,從「左到右的電流」與「從右到左的電子流」具有等價的物理意義。 ::: :::success 3. Flow conservation:對Graph中除了source與sink以外的vertex(X)而言,所有「流進flow」之總和要等於所有「流出flow」的總和。 也就是水流不會無故增加或無故減少,可視為一種能量守恆。 以圖二(b)為例,流入vertex(A)的flow為6,流出vertex(A)的flow也是6,對vertex(C)、vertex(D)也是。 ::: ![](https://i.imgur.com/9gx187U.png) ## Ford-Fulkerson Algorithm :::success Ford-Fulkerson Algorithm需要兩個輔助工具: - Residual Networks(剩餘網路) - Augmenting Paths(增廣路徑) ::: ### Residual Networks(剩餘網路) :::success Residual Networks的概念為,記錄Graph上之edge還有多少「剩餘的容量」可以讓flow流過。 ::: :::info 以圖三(a)為例,若在Path:S−A−C−D−T上的所有edge都有6單位的flow流過,那麼這些edge(edge(S,A)、edge(A,C)、edge(C,D)、edge(D,T))的可用「剩餘capacity」,都應該要「減6」,例如,edge(S,A)只能「再容納9−6=3單位」的flow,edge(C,D)只能「再容納7−6=1單位」的flow。 ::: :::info 這些「**剩餘capacity**」就稱為residual capacity,以c~f~表示。 若edge(X,Y)上有flow流過,f(X,Y),便將edge(X,Y)上的residual capacity定義為: c~f~(X,Y)=c(X,Y)−f(X,Y) c(X,Y)為原來水管孔徑大小; f(X,Y)表示目前水管已經有多少流量; c~f~(X,Y)表示水管還能再容納多少流量。 ::: ![](https://i.imgur.com/opQ6msG.png) :::warning 因為**Skew symmetry**,f(C,A)=−f(A,C); 再根據定義,c~f~(C,A)=c(C,A)−f(C,A)=c(C,A)+f(A,C)=0+6=6 ==如果想要重新配置水流方向來形容會很好(回來的方向)== ::: ### Augmenting Paths(增廣路徑) :::success 在Residual Networks裡,所有能夠「從source走到termination」的路徑,也就是所有能夠「增加flow的path」,就稱為Augmenting Paths。 ::: :::danger 他不會超過 residual flow ::: ### 演算法概念 :::success Ford-Fulkerson Algorithm(若使用BFS搜尋路徑,又稱為Edmonds-Karp Algorithm的方法如下: ::: :::info 在**Residual Networks**上尋找**Augmenting Paths**。 1. 若以BFS()尋找,便能確保每次找到的Augmenting Paths一定經過「最少的edge」。 2. 找到Augmenting Paths上的「最小residual capacity」加入總flow。 3. 再以「最小residual capacity」更新Residual Networks上的edge之residual capacity。 4. 重複上述步驟,直到再也沒有**Augmenting Paths**為止。 5. 便能找到**Maximum Flow**。 ::: 以圖二(a)之Flow Networks作為範例,尋找Maximum Flow之步驟如下: 先以「flow為零」對residual networks進行初始化,如圖五(a)。 觀察後發現,Gf就是Adjacency Matrix。 ![](https://i.imgur.com/CV02tjx.png) :::success 利用「已經求取完最大流量」的 Residual network 可得到「原本流量網路」的 Minimum cut Minimum cut:有 (S,T) 兩個子圖,滿足 - S ∪ T = V 且 S ∩ T = ϕ 從子圖 S 連至子圖 T 之所有邊的權重和為所有「Cut」中最小 在求完最大流量的「**Residual network**」中,令 - S:{自 S 可以到達的節點} - T:{自 T 可以到達的節點} 則 (S, T) 是原本「Flow network」的「**Minimum cut**」 :::

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password

    or

    By clicking below, you agree to our terms of service.

    Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully