Cov txheej txheem:

Yuav ua li cas los tsim ib daim duab qhia acyclic?
Yuav ua li cas los tsim ib daim duab qhia acyclic?

Video: Yuav ua li cas los tsim ib daim duab qhia acyclic?

Video: Yuav ua li cas los tsim ib daim duab qhia acyclic?
Video: Yuav ua li cas thiaj khiav dim lub ntiajteb no 2024, Kaum ib hlis
Anonim

Ib qho qhia graph tuaj yeem ua rau ib qho DAG los ntawm kev tshem tawm cov lus tawm tswv yim vertex teeb los yog lub tswv yim arc teeb, ib txheej ntawm vertices los yog ntug (raws li) uas kov txhua lub voj voog. Txawm li cas los xij, qhov tsawg tshaj plaws xws li teeb yog NP- nyuaj nrhiav.

Ua raws li qhov no hauv kev txiav txim siab, qhia acyclic graph ua haujlwm li cas?

Hauv ib qhia graph , cov ntug yog txuas kom txhua ntug tsuas yog mus ib txoj kev. A qhia acyclic graph txhais tau tias cov graph yog tsis yog cyclic, los yog hais tias nws yog tsis yooj yim sua kom pib ntawm ib qho chaw hauv lub daim duab thiab hla tag nrho daim duab . Txhua ntug yog qhia los ntawm ib tug ua ntej ntug mus rau tom qab ntug.

Tom qab, lo lus nug yog, DAG cov ntaub ntawv qauv yog dab tsi? A DAG yog a cov ntaub ntawv qauv los ntawm computer science uas tuaj yeem siv los ua qauv ntau yam teeb meem. Cov DAG muaj cov hauv qab no: Nodes. Txhua node sawv cev rau qee yam khoom lossis cov khoom cov ntaub ntawv.

Ib sab saum toj no, koj ua li cas thiaj nrhiav tau cov duab qhia acyclic?

Txhawm rau kuaj ib daim duab ua acyclic:

  1. Yog tias daim duab tsis muaj nodes, nres. Daim duab yog acyclic.
  2. Yog tias daim duab tsis muaj nplooj, nres. Daim duab yog cyclic.
  3. Xaiv ib nplooj ntawm daim duab.
  4. Mus rau 1.
  5. Yog tias Graph tsis muaj cov nodes, nres.
  6. Yog tias daim duab tsis muaj nplooj, nres.
  7. Xaiv ib nplooj ntawm Graph.
  8. Mus rau 1.

Dab tsi yog Dag nrog piv txwv?

Daim duab qhia acyclic ( DAG !) yog daim duab qhia uas tsis muaj lub voj voog. Ib tsob ntoo cag yog ib hom tshwj xeeb DAG thiab a DAG yog ib hom tshwj xeeb ntawm cov duab qhia. Rau piv txwv , a DAG tej zaum yuav siv los sawv cev rau cov subexpressions nyob rau hauv lub optimizing compiler.

Pom zoo: