Seeking algorithm to invert (reverse? mirror? turn inside-out) a DAG

后端 未结 5 1350
我寻月下人不归
我寻月下人不归 2021-02-01 09:54

I\'m looking for an algorithm to \"invert\" (reverse? turn inside-out?) a DAG:

       A*      # I can\'t ascii-art the arrows, so just
      / \\      # pretend          


        
5条回答
  •  深忆病人
    2021-02-01 10:43

    Just do a depth-first search marking where you have already been, and each time you traverse an arrow you add the reverse to your result DAG. Add the leaves as roots.

提交回复
热议问题