How do I find all paths through a set of given nodes in a DAG?

前端 未结 2 810
一向
一向 2021-02-13 21:15

I have a list of items (blue nodes below) which are categorized by the users of my application. The categories themselves can be grouped and categorized themselves.

The

2条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-02-13 22:12

    Despite the fact that your graph is acyclic, the operations you cite remind me of similar aspects of control flow graph analysis. There is a rich set of algorithms based on dominance that may be applicable. For example, your third operation reminds me od computing dominance frontiers; I believe that algorithm would work directly if you temporarily introduce "entry" and "exit" nodes. The entry node connects the "given set of nodes" and the exit nodes connects the sinks.

    Also see Robert Tarjan's basic algorithms.

提交回复
热议问题