我有以下图表:
我正在寻找一种图形数据科学算法,它可以以某种方式在图形内部找到一条路径,即给定起点,所有终点都可以到达。像这儿:
到目前为止,我已经尝试了 Dijkstra 单源和深度优先搜索算法以及与纯密码的 N 度关系,但无济于事。
我有几个类似的图表,因此我宁愿寻找算法解决方案,但我愿意接受任何建议。
密码:
:begin
CREATE CONSTRAINT ON (node:Node1) ASSERT (node.node1) IS UNIQUE;
CREATE CONSTRAINT ON (node:Node2) ASSERT (node.node2) IS UNIQUE;
:commit
CALL db.awaitIndexes(300);
:begin
UNWIND [{node1:"D100660078", properties:{CASE_ID:9}}, {node1:"D100660074", properties:{CASE_ID:9}}, {node1:"D100660080", properties:{CASE_ID:9}}, {node1:"200030914", properties:{CASE_ID:9}}, {node1:"D100660082", properties:{CASE_ID:9}}, {node1:"2100020143", properties:{CASE_ID:9}}, {node1:"D100660076", properties:{CASE_ID:9}}, {node1:"1600020093", properties:{CASE_ID:9, start_marker:1}}] AS row
CREATE (n:Node1{node1: row.node1}) SET n += row.properties;
UNWIND [{node2:"200030914", properties:{CASE_ID:9}}, {node2:"2100020143", properties:{CASE_ID:9}}] AS row
CREATE (n:Node2{node2: row.node2}) SET n += row.properties;
:commit
:begin
UNWIND [{start: {node2:"2100020143"}, end: {node1:"2100020143"}, properties:{}}, {start: {node2:"200030914"}, end: {node1:"200030914"}, properties:{}}, {start: {node2:"2100020143"}, end: {node1:"D100660076"}, properties:{}}, {start: {node2:"2100020143"}, end: {node1:"D100660080"}, properties:{}}, {start: {node2:"2100020143"}, end: {node1:"D100660078"}, properties:{}}, {start: {node2:"2100020143"}, end: {node1:"D100660074"}, properties:{}}, {start: {node2:"2100020143"}, end: {node1:"D100660082"}, properties:{}}, {start: {node2:"200030914"}, end: {node1:"2100020143"}, properties:{}}, {start: {node2:"200030914"}, end: {node1:"1600020093"}, properties:{}}] AS row
MATCH (start:Node2{node2: row.start.node2})
MATCH (end:Node1{node1: row.end.node1})
CREATE (start)-[r:GOES]->(end) SET r += row.properties;
:commit