logo
  • 教程列表
  • SO官方文檔
  • Kruskal 的演算法
    • 基於最佳脫節集的實現
    • 簡單更詳細的實現
    • 簡單的基於不相交集的實現
    • 簡單的高階實現
  1. StackOverflow 文件
  2. algorithm 教程
  3. Kruskal 的演算法
  4. 簡單的高階實現

簡單的高階實現

Created: November-22, 2018

按值排序邊緣,如果不建立迴圈,則按排序順序將每個邊緣新增到 MST。

algorithm kruskalMST(G: a graph)
    sort G's edges by their value
    MST = an empty graph
    for each edge e in G:
        if adding e to MST does not create a cycle:
            add e to MST

    return MST
  • 簡單的基於不相交集的實現

Copyright © 2018. All right reserved

tastones.com 备案号:鲁ICP备18045372号-1

  • 關於本站
  • 免責聲明