首页 >PHP讨论组 >javascript - 流程图获取深度,求各位算法高手帮帮忙

javascript - 流程图获取深度,求各位算法高手帮帮忙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为最后一个节点.根据数据得到以下流程图

求当前深度最深的流程有哪些节点,和流程的有几个分支

注:节点只能向下走

 
2
 
+1
-1
 
分享
全部回复 (2)我来回答
    滿天的星座
    0楼
    滿天的星座 · 7个月前

    这个结构像数据结构中的有向图

      赞+0添加回复

    过去多啦不再A梦
    0楼
    过去多啦不再A梦 · 7个月前

    额, 不就是深搜么

      赞+0添加回复

    首页上一页1下一页尾页