Can someone explain in simple terms to me what a directed acyclic graph is?

前端 未结 13 1192
暖寄归人
暖寄归人 2020-12-22 16:23

Can someone explain in simple terms to me what a directed acyclic graph is? I have looked on Wikipedia but it doesn\'t really make me see its use in programming.

13条回答
  •  轮回少年
    2020-12-22 16:46

    I assume you already know basic graph terminology; otherwise you should start from the article on graph theory.

    Directed refers to the fact that the edges (connections) have directions. In the diagram, these directions are shown by the arrows. The opposite is an undirected graph, whose edges don't specify directions.

    Acyclic means that, if you start from any arbitrary node X and walk through all possible edges, you cannot return to X without going back on an already-used edge.

    Several applications:

    • Spreadsheets; this is explained in the DAG article.
    • Revision control: if you have a look at the diagram in that page, you will see that the evolution of revision-controlled code is directed (it goes "down", in this diagram) and acyclic (it never goes back "up").
    • Family tree: it's directed (you are your parents' child, not the other way around) and acyclic (your ancestors can never be your descendant).

提交回复
热议问题