Javascript – Flussdiagramm, um Tiefe zu erhalten, bitte helfen Sie mit Algorithmus-Experten
仅有的幸福
仅有的幸福 2017-05-19 10:48:24
0
2
1123

Dieses Problem beschäftigt mich seit langem. Ich habe die folgenden JSON-Daten

[
    {"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}
]

Unter diesen stellt prev_node den vorherigen Knoten und next_node den nächsten Knoten dar. Wenn prev_node Null ist, stellt er den aktuellen Knoten dar. Den Daten zufolge wird das folgende Flussdiagramm erhalten

Finden Sie die Knoten des aktuell tiefsten Prozesses und wie viele Zweige es gibt

Hinweis: Knoten können nur nach unten gehen

仅有的幸福
仅有的幸福

Antworte allen(2)
过去多啦不再A梦

额, 不就是深搜么

滿天的星座

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

Beliebte Tutorials
Mehr>
Neueste Downloads
Mehr>
Web-Effekte
Quellcode der Website
Website-Materialien
Frontend-Vorlage