javascript - 流程圖取得深度,求各位演算法高手幫忙
仅有的幸福
仅有的幸福 2017-05-19 10:48:24
0
2
1134

最近這個問題困擾我半天,我有以下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為最後一個節點.根據資料得到以下流程圖

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

註:節點只能向下走

仅有的幸福
仅有的幸福

全部回覆(2)
过去多啦不再A梦

額, 不就是深搜麼

滿天的星座

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

熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板