Cov txheej txheem:

Yuav ua li cas koj nrhiav tau qhov tsawg kawg nkaus spanning ntoo?
Yuav ua li cas koj nrhiav tau qhov tsawg kawg nkaus spanning ntoo?

Video: Yuav ua li cas koj nrhiav tau qhov tsawg kawg nkaus spanning ntoo?

Video: Yuav ua li cas koj nrhiav tau qhov tsawg kawg nkaus spanning ntoo?
Video: Ntsaim vaj - Muaj poj niam lawm ua tsis tau li cas ( Official MV ) Nkauj tawm tshiab 2020 2024, Kaum ib hlis
Anonim

Kruskal qhov tsawg kawg nkaus Spanning Ntoo Algorithm | Greedy Algo-2

  1. Cais tag nrho cov npoo hauv qhov tsis txo qis ntawm lawv qhov hnyav.
  2. Xaiv lub tsawg tshaj plaws ntug. Xyuas seb nws tsim ib lub voj voog nrog cov tsob ntoo tsim kom deb li deb. Yog tsis tsim lub voj voog, suav nrog ntug no. Tsis tas li ntawd, muab pov tseg.
  3. Rov ua kauj ruam # 2 kom txog thaum muaj (V-1) ntug hauv tsob ntoo .

Tib neeg kuj nug, dab tsi yog tus nqi qis tshaj ntawm tsob ntoo?

Cov nqi ntawm tsob ntoo yog qhov sib npaug ntawm qhov hnyav ntawm tag nrho cov npoo hauv qhov tsob ntoo . Yuav muaj ntau yam hla ntoo . Yam tsawg kawg nkaus tsob ntoo yog cov tsob ntoo qhov twg nqi yog yam tsawg kawg nkaus ntawm tag nrho cov hla ntoo . Kuj tseem muaj ntau tsawg kawg spanning ntoo.

Ib yam li ntawd, koj yuav pom qhov tsawg kawg nkaus spanning ntoo siv Kruskal's algorithm li cas? Kruskal lub algorithm rau nrhiav tus yam tsawg kawg nkaus nqi tsob ntoo siv txoj kev ntshaw ntshaw.

Kruskal's Spanning Tree Algorithm

  1. Kauj Ruam 1 - Tshem tag nrho cov voj voog thiab cov ntug sib luag.
  2. Kauj Ruam 2 - Npaj tag nrho cov npoo hauv lawv qhov kev txiav txim siab ntawm qhov hnyav.
  3. Kauj Ruam 3 - Ntxiv cov ntug uas muaj qhov hnyav tshaj plaws.

Ntxiv mus, qhov tsawg kawg nkaus spanning ntoo nrog piv txwv?

A tsawg kawg spanning ntoo yog ib hom tshwj xeeb ntawm tsob ntoo uas txo qhov ntev (lossis "qhov hnyav") ntawm cov npoo ntawm qhov tsob ntoo . Ib piv txwv yog ib lub tuam txhab cable xav nteg kab rau ntau lub zej zog; los ntawm kev txo qis ntawm cov cable tso, lub tuam txhab cable yuav txuag nyiaj. A tsob ntoo muaj ib txoj kev koom nrog ob lub vertices.

Koj txhais li cas los ntawm qhov tsawg kawg nkaus spanning ntoo?

A tsawg kawg spanning ntoo (MST) lub yam tsawg kawg nkaus hnyav tsob ntoo yog ib tug subset ntawm cov npoo ntawm ib qho kev cob cog rua, edge-weighted undirected graph uas txuas tag nrho cov vertices ua ke, tsis muaj ib tug cycles thiab nrog rau yam tsawg kawg nkaus ua tau tag nrho ntug hnyav. Nyob ntawd yog heev ob peb yam siv rau tsawg kawg spanning ntoo.

Pom zoo: