both are greedy algorithm

- kruskal algorithm, O(ElgV)

  • make set for each vertex. set only contains one vertex
  • sort G.E in non-descending order by weight of edge.
  • for each edge(u,v), if they are not in same set, add edge(u,v) to A. and union u and v to one set. 
minimum spanning tree (connect all vertices in undirected graphic)

- prime algorithm O(ElgV) , 

  • initialise all u.key=infinity max, u.pi = nil
  • set root.key = 0
  • make all nodes as a priority queue, root is in the first
  • take node from the queue and update its key of adjacent nodes to w(u,v)
  • repeat last step
minimum spanning tree (connect all vertices in undirected graphic)

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-01-19
  • 2022-01-09
  • 2021-12-21
  • 2022-02-28
  • 2022-01-21
  • 2022-12-23
猜你喜欢
  • 2021-11-18
  • 2022-12-23
  • 2022-12-23
  • 2021-08-25
  • 2021-08-23
  • 2021-06-30
相关资源
相似解决方案