搜尋

首頁  >  問答  >  主體

javascript - 流程圖取得深度,求各位演算法高手幫忙

最近這個問題困擾我半天,我有以下json數據

[
    {"prev_node": "0000000000000005","next_node": "0000000000000006"},
    {"prev_node": "0000000000000006","next_node": "0000000000000007"},
    {"prev_node": "0000000000000006","next_node": "0000000000000008"},
    {"prev_node": "0000000000000008","next_node": "0000000000000012"},
    {"prev_node": "0000000000000009","next_node": "0000000000000010"},
    {"prev_node": "0000000000000010","next_node": "0000000000000011"},
    {"prev_node": "0000000000000014","next_node": "0000000000000015"},
    {"prev_node": "0000000000000015","next_node": "0000000000000016"},
    {"prev_node": "0000000000000016","next_node": "0000000000000017"},
    {"prev_node": "0000000000000018","next_node": "0000000000000019"},
    {"prev_node": "0000000000000020","next_node": "0000000000000021"},
    {"prev_node": "0000000000000019","next_node": "0000000000000020"},
    {"prev_node": "0000000000000012","next_node": "0000000000000022"},
    {"prev_node": "0000000000000022","next_node": "0000000000000023"},
    {"prev_node": "0000000000000023","next_node": "0000000000000009"},
    {"prev_node": "0000000000000011","next_node": "0000000000000024"},
    {"prev_node": "0000000000000024","next_node": "0000000000000014"},
    {"prev_node": "0000000000000017","next_node": "0000000000000025"},
    {"prev_node": "0000000000000025","next_node": "0000000000000018"},
    {"prev_node": "0000000000000007","next_node": "0000000000000021"},
    {"prev_node": null,"next_node": "0000000000000005"},
    {"prev_node": "0000000000000021","next_node": null}
]

其中,prev_node代表上一個節點,next_node為下一節點.如果prev_node為Null,則代表當前為第一個節點.next_node為null為最後一個節點.根據資料得到以下流程圖

#求目前深度最深的流程有哪些節點,和流程的有幾個分支

註:節點只能向下走

仅有的幸福仅有的幸福2737 天前1116

全部回覆(2)我來回復

  • 过去多啦不再A梦

    过去多啦不再A梦2017-05-19 10:50:24

    額, 不就是深搜麼

    回覆
    0
  • 滿天的星座

    滿天的星座2017-05-19 10:50:24

    這個結構像資料結構中的有向圖

    回覆
    0
  • 取消回覆