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
额, 不就是深搜么
这个结构像数据结构中的有向图