это скриншот примера графика:
образец данных графика генерации:
CREATE (r:Red {key:'someid'})
CREATE (t1:Teal)
CREATE (t2:Teal)
CREATE (t3:Teal)
CREATE (t4:Teal)
CREATE (t5:Teal)
CREATE (t6:Teal)
CREATE (r2:Red)
CREATE (b1:Blue)
CREATE (b2:Blue)
CREATE (b3:Blue)
CREATE (b4:Blue)
CREATE (f:FINAL_NODE)
CREATE (r)<-[:TO_ACTIVE_DRAFT]-(t1)
CREATE (r)<-[:TO_ACTIVE_DRAFT]-(t2)
CREATE (r)<-[:TO_ACTIVE_DRAFT]-(t3)
CREATE (r)<-[:TO_ACTIVE_DRAFT]-(t4)
CREATE (r)<-[:TO_ACTIVE_DRAFT]-(t5)
CREATE (r)<-[:TO_ACTIVE_DRAFT]-(t6)
CREATE (t1)<-[:TO_ATL]-(r2)
CREATE (t2)<-[:TO_ATL]-(r2)
CREATE (t3)<-[:TO_ATL]-(r2)
CREATE (t4)<-[:TO_ATL]-(r2)
CREATE (t5)<-[:TO_ATL]-(r2)
CREATE (t6)<-[:TO_ATL]-(r2)
CREATE (r2)<-[:TO_ACTIVE_DRAFT]-(b1)
CREATE (r2)<-[:TO_ACTIVE_DRAFT]-(b2)
CREATE (r2)<-[:TO_ACTIVE_DRAFT]-(b3)
CREATE (r2)<-[:TO_ACTIVE_DRAFT]-(b4)
CREATE (b1)-[:TO_FINAL]->(f)
CREATE (b2)-[:TO_FINAL]->(f)
CREATE (b3)-[:TO_FINAL]->(f)
CREATE (b4)-[:TO_FINAL]->(f)
если мой запрос выглядит так:
MATCH (f:Red {key:'someid'})
CALL apoc.path.expand(f, '<TO_ACTIVE_DRAFT|<TO_ATL|TO_FINAL>', '>FINAL_NODE',-1,-1) yield path as p
RETURN p
при использовании браузера и просмотре табличного представления похоже, что данные возвращаются в виде отдельных путей в массиве. Таким образом, массив в массиве.
[
[
{red},
{relationship},
{teal},
{relationship},
{red},
{relationship},
{blue},
{relationship},
{green}
],
[
{red},
{relationship},
{teal},
{relationship},
{red},
{relationship},
{blue},
{relationship},
{green}
],
etc
]
{} - это свойства каждого узла и отношения.
Если я использую
RETURN Nodes (p)
он просто дает мне список всех элементов без глубины, и если я пытаюсь использовать размер или длину с путем, в этом случае все они равны 5 и не дают мне отдельные узлы.
Что я действительно хотел бы, так это иметь возможность воссоздать уровни графика, так что в идеале данные должны быть возвращены так:
[
[
{red}
],[
{teal},
{teal},
{teal},
{teal},
{teal},
{teal}
],[
{red}
],[
{blue},
{blue},
{blue},
{blue},
{blue},
{blue},
{blue}
],[
{green}
]
]
Возможно ли это с помощью функции расширения, или мне нужно выяснить, как сделать то же самое со стандартным шаблоном с помощью шифра - т. Е. MATCH (r) - [: *] - (final)?
// пара уточнений:
Там может быть произвольное количество маршрутов и узлов. Так что в этом примере это красный, чирок, красный, синий, зеленый. Это может быть красный, чирок, красный, чирок, красный, синий, зеленый. Может быть просто красным, синим, зеленым.
Я использую C # и драйвер neo4j, если это имеет значение, для каких данных я могу получить возвращенный пример ответа, который я получаю от простого возврата пути в C #
[{"p":{"Start":{"Id":0,"Labels":["Red"],"Properties":{"key":"someid"}},"End":{"Id":26,"Labels":["FINAL_NODE"],"Properties":{}},"Nodes":[{"Id":0,"Labels":["Red"],"Properties":{"key":"someid"}},{"Id":20,"Labels":["Teal"],"Properties":{}},{"Id":21,"Labels":["Red"],"Properties":{}},{"Id":25,"Labels":["Blue"],"Properties":{}},{"Id":26,"Labels":["FINAL_NODE"],"Properties":{}}],"Relationships":[{"Id":5,"Type":"TO_ACTIVE_DRAFT","StartNodeId":20,"EndNodeId":0,"Properties":{}},{"Id":11,"Type":"TO_ATL","StartNodeId":21,"EndNodeId":20,"Properties":{}},{"Id":15,"Type":"TO_ACTIVE_DRAFT","StartNodeId":25,"EndNodeId":21,"Properties":{}},{"Id":19,"Type":"TO_FINAL","StartNodeId":25,"EndNodeId":26,"Properties":{}}]}},{"p":{"Start":{"Id":0,"Labels":["Red"],"Properties":{"key":"someid"}},"End":{"Id":26,"Labels":["FINAL_NODE"],"Properties":{}},"Nodes":[{"Id":0,"Labels":["Red"],"Properties":{"key":"someid"}},{"Id":20,"Labels":["Teal"],"Properties":{}},{"Id":21,"Labels":["Red"],"Properties":{}},{"Id":24,"Labels":["Blue"],"Properties":{}},{"Id":26,"Labels":["FINAL_NODE"],"Properties":{}}],"Relationships":[{"Id":5,"Type":"TO_ACTIVE_DRAFT","StartNodeId":20,"EndNodeId":0,"Properties":{}},{"Id":11,"Type":"TO_ATL","StartNodeId":21,"EndNodeId":20,"Properties":{}},{"Id":14,"Type":"TO_ACTIVE_DRAFT","StartNodeId":24,"EndNodeId":21,"Properties":{}},{"Id":18,"Type":"TO_FINAL","StartNodeId":24,"EndNodeId":26,"Properties":{}}]}},{"p":{"Start":{"Id":0,"Labels":["Red"],"Properties":{"key":"someid"}},"End":{"Id":26,"Labels":["FINAL_NODE"],"Properties":{}},"Nodes":[{"Id":0,"Labels":["Red"],"Properties":{"key":"someid"}},{"Id":20,"Labels":["Teal"],"Properties":{}},{"Id":21,"Labels":["Red"],"Properties":{}},{"Id":23,"Labels":["Blue"],"Properties":{}},{"Id":26,"Labels":["FINAL_NODE"],"Properties":{}}],"Relationships":[{"Id":5,"Type":"TO_ACTIVE_DRAFT","StartNodeId":20,"EndNodeId":0,"Properties":{}},{"Id":11,"Type":"TO_ATL","StartNodeId":21,"EndNodeId":20,"Properties":{}},{"Id":13,"Type":"TO_ACTIVE_DRAFT","StartNodeId":23,"EndNodeId":21,"Properties":{}},{"Id":17,"Type":"TO_FINAL","StartNodeId":23,"EndNodeId":26,"Properties":{}}]}},{"p":{"Start":{"Id":0,"Labels":["Red"],"Properties":{"key":"someid"}},"End":{"Id":26,"Labels":["FINAL_NODE"],"Properties":{}},"Nodes":[{"Id":0,"Labels":["Red"],"Properties":{"key":"someid"}},{"Id":20,"Labels":["Teal"],"Properties":{}},{"Id":21,"Labels":["Red"],"Properties":{}},{"Id":22,"Labels":["Blue"],"Properties":{}},{"Id":26,"Labels":["FINAL_NODE"],"Properties":{}}],"Relationships":[{"Id":5,"Type":"TO_ACTIVE_DRAFT","StartNodeId":20,"EndNodeId":0,"Properties":{}},{"Id":11,"Type":"TO_ATL","StartNodeId":21,"EndNodeId":20,"Properties":{}},{"Id":12,"Type":"TO_ACTIVE_DRAFT","StartNodeId":22,"EndNodeId":21,"Properties":{}},{"Id":16,"Type":"TO_FINAL","StartNodeId":22,"EndNodeId":26,"Properties":{}}]}},{"p":{"Start":{"Id":0,"Labels":["Red"],"Properties":{"key":"someid"}},"End":{"Id":26,"Labels":["FINAL_NODE"],"Properties":{}},"Nodes":[{"Id":0,"Labels":["Red"],"Properties":{"key":"someid"}},{"Id":5,"Labels":["Teal"],"Properties":{}},{"Id":21,"Labels":["Red"],"Properties":{}},{"Id":25,"Labels":["Blue"],"Properties":{}},{"Id":26,"Labels":["FINAL_NODE"],"Properties":{}}],"Relationships":[{"Id":4,"Type":"TO_ACTIVE_DRAFT","StartNodeId":5,"EndNodeId":0,"Properties":{}},{"Id":10,"Type":"TO_ATL","StartNodeId":21,"EndNodeId":5,"Properties":{}},{"Id":15,"Type":"TO_ACTIVE_DRAFT","StartNodeId":25,"EndNodeId":21,"Properties":{}},{"Id":19,"Type":"TO_FINAL","StartNodeId":25,"EndNodeId":26,"Properties":{}}]}},{"p":{"Start":{"Id":0,"Labels":["Red"],"Properties":{"key":"someid"}},"End":{"Id":26,"Labels":["FINAL_NODE"],"Properties":{}},"Nodes":[{"Id":0,"Labels":["Red"],"Properties":{"key":"someid"}},{"Id":5,"Labels":["Teal"],"Properties":{}},{"Id":21,"Labels":["Red"],"Properties":{}},{"Id":24,"Labels":["Blue"],"Properties":{}},{"Id":26,"Labels":["FINAL_NODE"],"Properties":{}}],"Relationships":[{"Id":4,"Type":"TO_ACTIVE_DRAFT","StartNodeId":5,"EndNodeId":0,"Properties":{}},{"Id":10,"Type":"TO_ATL","StartNodeId":21,"EndNodeId":5,"Properties":{}},{"Id":14,"Type":"TO_ACTIVE_DRAFT","StartNodeId":24,"EndNodeId":21,"Properties":{}},{"Id":18,"Type":"TO_FINAL","StartNodeId":24,"EndNodeId":26,"Properties":{}}]}},{"p":{"Start":{"Id":0,"Labels":["Red"],"Properties":{"key":"someid"}},"End":{"Id":26,"Labels":["FINAL_NODE"],"Properties":{}},"Nodes":[{"Id":0,"Labels":["Red"],"Properties":{"key":"someid"}},{"Id":5,"Labels":["Teal"],"Properties":{}},{"Id":21,"Labels":["Red"],"Properties":{}},{"Id":23,"Labels":["Blue"],"Properties":{}},{"Id":26,"Labels":["FINAL_NODE"],"Properties":{}}],"Relationships":[{"Id":4,"Type":"TO_ACTIVE_DRAFT","StartNodeId":5,"EndNodeId":0,"Properties":{}},{"Id":10,"Type":"TO_ATL","StartNodeId":21,"EndNodeId":5,"Properties":{}},{"Id":13,"Type":"TO_ACTIVE_DRAFT","StartNodeId":23,"EndNodeId":21,"Properties":{}},{"Id":17,"Type":"TO_FINAL","StartNodeId":23,"EndNodeId":26,"Properties":{}}]}},{"p":{"Start":{"Id":0,"Labels":["Red"],"Properties":{"key":"someid"}},"End":{"Id":26,"Labels":["FINAL_NODE"],"Properties":{}},"Nodes":[{"Id":0,"Labels":["Red"],"Properties":{"key":"someid"}},{"Id":5,"Labels":["Teal"],"Properties":{}},{"Id":21,"Labels":["Red"],"Properties":{}},{"Id":22,"Labels":["Blue"],"Properties":{}},{"Id":26,"Labels":["FINAL_NODE"],"Properties":{}}],"Relationships":[{"Id":4,"Type":"TO_ACTIVE_DRAFT","StartNodeId":5,"EndNodeId":0,"Properties":{}},{"Id":10,"Type":"TO_ATL","StartNodeId":21,"EndNodeId":5,"Properties":{}},{"Id":12,"Type":"TO_ACTIVE_DRAFT","StartNodeId":22,"EndNodeId":21,"Properties":{}},{"Id":16,"Type":"TO_FINAL","StartNodeId":22,"EndNodeId":26,"Properties":{}}]}},{"p":{"Start":{"Id":0,"Labels":["Red"],"Properties":{"key":"someid"}},"End":{"Id":26,"Labels":["FINAL_NODE"],"Properties":{}},"Nodes":[{"Id":0,"Labels":["Red"],"Properties":{"key":"someid"}},{"Id":4,"Labels":["Teal"],"Properties":{}},{"Id":21,"Labels":["Red"],"Properties":{}},{"Id":25,"Labels":["Blue"],"Properties":{}},{"Id":26,"Labels":["FINAL_NODE"],"Properties":{}}],"Relationships":[{"Id":3,"Type":"TO_ACTIVE_DRAFT","StartNodeId":4,"EndNodeId":0,"Properties":{}},{"Id":9,"Type":"TO_ATL","StartNodeId":21,"EndNodeId":4,"Properties":{}},{"Id":15,"Type":"TO_ACTIVE_DRAFT","StartNodeId":25,"EndNodeId":21,"Properties":{}},{"Id":19,"Type":"TO_FINAL","StartNodeId":25,"EndNodeId":26,"Properties":{}}]}},{"p":{"Start":{"Id":0,"Labels":["Red"],"Properties":{"key":"someid"}},"End":{"Id":26,"Labels":["FINAL_NODE"],"Properties":{}},"Nodes":[{"Id":0,"Labels":["Red"],"Properties":{"key":"someid"}},{"Id":4,"Labels":["Teal"],"Properties":{}},{"Id":21,"Labels":["Red"],"Properties":{}},{"Id":24,"Labels":["Blue"],"Properties":{}},{"Id":26,"Labels":["FINAL_NODE"],"Properties":{}}],"Relationships":[{"Id":3,"Type":"TO_ACTIVE_DRAFT","StartNodeId":4,"EndNodeId":0,"Properties":{}},{"Id":9,"Type":"TO_ATL","StartNodeId":21,"EndNodeId":4,"Properties":{}},{"Id":14,"Type":"TO_ACTIVE_DRAFT","StartNodeId":24,"EndNodeId":21,"Properties":{}},{"Id":18,"Type":"TO_FINAL","StartNodeId":24,"EndNodeId":26,"Properties":{}}]}},{"p":{"Start":{"Id":0,"Labels":["Red"],"Properties":{"key":"someid"}},"End":{"Id":26,"Labels":["FINAL_NODE"],"Properties":{}},"Nodes":[{"Id":0,"Labels":["Red"],"Properties":{"key":"someid"}},{"Id":4,"Labels":["Teal"],"Properties":{}},{"Id":21,"Labels":["Red"],"Properties":{}},{"Id":23,"Labels":["Blue"],"Properties":{}},{"Id":26,"Labels":["FINAL_NODE"],"Properties":{}}],"Relationships":[{"Id":3,"Type":"TO_ACTIVE_DRAFT","StartNodeId":4,"EndNodeId":0,"Properties":{}},{"Id":9,"Type":"TO_ATL","StartNodeId":21,"EndNodeId":4,"Properties":{}},{"Id":13,"Type":"TO_ACTIVE_DRAFT","StartNodeId":23,"EndNodeId":21,"Properties":{}},{"Id":17,"Type":"TO_FINAL","StartNodeId":23,"EndNodeId":26,"Properties":{}}]}},{"p":{"Start":{"Id":0,"Labels":["Red"],"Properties":{"key":"someid"}},"End":{"Id":26,"Labels":["FINAL_NODE"],"Properties":{}},"Nodes":[{"Id":0,"Labels":["Red"],"Properties":{"key":"someid"}},{"Id":4,"Labels":["Teal"],"Properties":{}},{"Id":21,"Labels":["Red"],"Properties":{}},{"Id":22,"Labels":["Blue"],"Properties":{}},{"Id":26,"Labels":["FINAL_NODE"],"Properties":{}}],"Relationships":[{"Id":3,"Type":"TO_ACTIVE_DRAFT","StartNodeId":4,"EndNodeId":0,"Properties":{}},{"Id":9,"Type":"TO_ATL","StartNodeId":21,"EndNodeId":4,"Properties":{}},{"Id":12,"Type":"TO_ACTIVE_DRAFT","StartNodeId":22,"EndNodeId":21,"Properties":{}},{"Id":16,"Type":"TO_FINAL","StartNodeId":22,"EndNodeId":26,"Properties":{}}]}},{"p":{"Start":{"Id":0,"Labels":["Red"],"Properties":{"key":"someid"}},"End":{"Id":26,"Labels":["FINAL_NODE"],"Properties":{}},"Nodes":[{"Id":0,"Labels":["Red"],"Properties":{"key":"someid"}},{"Id":3,"Labels":["Teal"],"Properties":{}},{"Id":21,"Labels":["Red"],"Properties":{}},{"Id":25,"Labels":["Blue"],"Properties":{}},{"Id":26,"Labels":["FINAL_NODE"],"Properties":{}}],"Relationships":[{"Id":2,"Type":"TO_ACTIVE_DRAFT","StartNodeId":3,"EndNodeId":0,"Properties":{}},{"Id":8,"Type":"TO_ATL","StartNodeId":21,"EndNodeId":3,"Properties":{}},{"Id":15,"Type":"TO_ACTIVE_DRAFT","StartNodeId":25,"EndNodeId":21,"Properties":{}},{"Id":19,"Type":"TO_FINAL","StartNodeId":25,"EndNodeId":26,"Properties":{}}]}},{"p":{"Start":{"Id":0,"Labels":["Red"],"Properties":{"key":"someid"}},"End":{"Id":26,"Labels":["FINAL_NODE"],"Properties":{}},"Nodes":[{"Id":0,"Labels":["Red"],"Properties":{"key":"someid"}},{"Id":3,"Labels":["Teal"],"Properties":{}},{"Id":21,"Labels":["Red"],"Properties":{}},{"Id":24,"Labels":["Blue"],"Properties":{}},{"Id":26,"Labels":["FINAL_NODE"],"Properties":{}}],"Relationships":[{"Id":2,"Type":"TO_ACTIVE_DRAFT","StartNodeId":3,"EndNodeId":0,"Properties":{}},{"Id":8,"Type":"TO_ATL","StartNodeId":21,"EndNodeId":3,"Properties":{}},{"Id":14,"Type":"TO_ACTIVE_DRAFT","StartNodeId":24,"EndNodeId":21,"Properties":{}},{"Id":18,"Type":"TO_FINAL","StartNodeId":24,"EndNodeId":26,"Properties":{}}]}},{"p":{"Start":{"Id":0,"Labels":["Red"],"Properties":{"key":"someid"}},"End":{"Id":26,"Labels":["FINAL_NODE"],"Properties":{}},"Nodes":[{"Id":0,"Labels":["Red"],"Properties":{"key":"someid"}},{"Id":3,"Labels":["Teal"],"Properties":{}},{"Id":21,"Labels":["Red"],"Properties":{}},{"Id":23,"Labels":["Blue"],"Properties":{}},{"Id":26,"Labels":["FINAL_NODE"],"Properties":{}}],"Relationships":[{"Id":2,"Type":"TO_ACTIVE_DRAFT","StartNodeId":3,"EndNodeId":0,"Properties":{}},{"Id":8,"Type":"TO_ATL","StartNodeId":21,"EndNodeId":3,"Properties":{}},{"Id":13,"Type":"TO_ACTIVE_DRAFT","StartNodeId":23,"EndNodeId":21,"Properties":{}},{"Id":17,"Type":"TO_FINAL","StartNodeId":23,"EndNodeId":26,"Properties":{}}]}},{"p":{"Start":{"Id":0,"Labels":["Red"],"Properties":{"key":"someid"}},"End":{"Id":26,"Labels":["FINAL_NODE"],"Properties":{}},"Nodes":[{"Id":0,"Labels":["Red"],"Properties":{"key":"someid"}},{"Id":3,"Labels":["Teal"],"Properties":{}},{"Id":21,"Labels":["Red"],"Properties":{}},{"Id":22,"Labels":["Blue"],"Properties":{}},{"Id":26,"Labels":["FINAL_NODE"],"Properties":{}}],"Relationships":[{"Id":2,"Type":"TO_ACTIVE_DRAFT","StartNodeId":3,"EndNodeId":0,"Properties":{}},{"Id":8,"Type":"TO_ATL","StartNodeId":21,"EndNodeId":3,"Properties":{}},{"Id":12,"Type":"TO_ACTIVE_DRAFT","StartNodeId":22,"EndNodeId":21,"Properties":{}},{"Id":16,"Type":"TO_FINAL","StartNodeId":22,"EndNodeId":26,"Properties":{}}]}},{"p":{"Start":{"Id":0,"Labels":["Red"],"Properties":{"key":"someid"}},"End":{"Id":26,"Labels":["FINAL_NODE"],"Properties":{}},"Nodes":[{"Id":0,"Labels":["Red"],"Properties":{"key":"someid"}},{"Id":2,"Labels":["Teal"],"Properties":{}},{"Id":21,"Labels":["Red"],"Properties":{}},{"Id":25,"Labels":["Blue"],"Properties":{}},{"Id":26,"Labels":["FINAL_NODE"],"Properties":{}}],"Relationships":[{"Id":1,"Type":"TO_ACTIVE_DRAFT","StartNodeId":2,"EndNodeId":0,"Properties":{}},{"Id":7,"Type":"TO_ATL","StartNodeId":21,"EndNodeId":2,"Properties":{}},{"Id":15,"Type":"TO_ACTIVE_DRAFT","StartNodeId":25,"EndNodeId":21,"Properties":{}},{"Id":19,"Type":"TO_FINAL","StartNodeId":25,"EndNodeId":26,"Properties":{}}]}},{"p":{"Start":{"Id":0,"Labels":["Red"],"Properties":{"key":"someid"}},"End":{"Id":26,"Labels":["FINAL_NODE"],"Properties":{}},"Nodes":[{"Id":0,"Labels":["Red"],"Properties":{"key":"someid"}},{"Id":2,"Labels":["Teal"],"Properties":{}},{"Id":21,"Labels":["Red"],"Properties":{}},{"Id":24,"Labels":["Blue"],"Properties":{}},{"Id":26,"Labels":["FINAL_NODE"],"Properties":{}}],"Relationships":[{"Id":1,"Type":"TO_ACTIVE_DRAFT","StartNodeId":2,"EndNodeId":0,"Properties":{}},{"Id":7,"Type":"TO_ATL","StartNodeId":21,"EndNodeId":2,"Properties":{}},{"Id":14,"Type":"TO_ACTIVE_DRAFT","StartNodeId":24,"EndNodeId":21,"Properties":{}},{"Id":18,"Type":"TO_FINAL","StartNodeId":24,"EndNodeId":26,"Properties":{}}]}},{"p":{"Start":{"Id":0,"Labels":["Red"],"Properties":{"key":"someid"}},"End":{"Id":26,"Labels":["FINAL_NODE"],"Properties":{}},"Nodes":[{"Id":0,"Labels":["Red"],"Properties":{"key":"someid"}},{"Id":2,"Labels":["Teal"],"Properties":{}},{"Id":21,"Labels":["Red"],"Properties":{}},{"Id":23,"Labels":["Blue"],"Properties":{}},{"Id":26,"Labels":["FINAL_NODE"],"Properties":{}}],"Relationships":[{"Id":1,"Type":"TO_ACTIVE_DRAFT","StartNodeId":2,"EndNodeId":0,"Properties":{}},{"Id":7,"Type":"TO_ATL","StartNodeId":21,"EndNodeId":2,"Properties":{}},{"Id":13,"Type":"TO_ACTIVE_DRAFT","StartNodeId":23,"EndNodeId":21,"Properties":{}},{"Id":17,"Type":"TO_FINAL","StartNodeId":23,"EndNodeId":26,"Properties":{}}]}},{"p":{"Start":{"Id":0,"Labels":["Red"],"Properties":{"key":"someid"}},"End":{"Id":26,"Labels":["FINAL_NODE"],"Properties":{}},"Nodes":[{"Id":0,"Labels":["Red"],"Properties":{"key":"someid"}},{"Id":2,"Labels":["Teal"],"Properties":{}},{"Id":21,"Labels":["Red"],"Properties":{}},{"Id":22,"Labels":["Blue"],"Properties":{}},{"Id":26,"Labels":["FINAL_NODE"],"Properties":{}}],"Relationships":[{"Id":1,"Type":"TO_ACTIVE_DRAFT","StartNodeId":2,"EndNodeId":0,"Properties":{}},{"Id":7,"Type":"TO_ATL","StartNodeId":21,"EndNodeId":2,"Properties":{}},{"Id":12,"Type":"TO_ACTIVE_DRAFT","StartNodeId":22,"EndNodeId":21,"Properties":{}},{"Id":16,"Type":"TO_FINAL","StartNodeId":22,"EndNodeId":26,"Properties":{}}]}},{"p":{"Start":{"Id":0,"Labels":["Red"],"Properties":{"key":"someid"}},"End":{"Id":26,"Labels":["FINAL_NODE"],"Properties":{}},"Nodes":[{"Id":0,"Labels":["Red"],"Properties":{"key":"someid"}},{"Id":1,"Labels":["Teal"],"Properties":{}},{"Id":21,"Labels":["Red"],"Properties":{}},{"Id":25,"Labels":["Blue"],"Properties":{}},{"Id":26,"Labels":["FINAL_NODE"],"Properties":{}}],"Relationships":[{"Id":0,"Type":"TO_ACTIVE_DRAFT","StartNodeId":1,"EndNodeId":0,"Properties":{}},{"Id":6,"Type":"TO_ATL","StartNodeId":21,"EndNodeId":1,"Properties":{}},{"Id":15,"Type":"TO_ACTIVE_DRAFT","StartNodeId":25,"EndNodeId":21,"Properties":{}},{"Id":19,"Type":"TO_FINAL","StartNodeId":25,"EndNodeId":26,"Properties":{}}]}},{"p":{"Start":{"Id":0,"Labels":["Red"],"Properties":{"key":"someid"}},"End":{"Id":26,"Labels":["FINAL_NODE"],"Properties":{}},"Nodes":[{"Id":0,"Labels":["Red"],"Properties":{"key":"someid"}},{"Id":1,"Labels":["Teal"],"Properties":{}},{"Id":21,"Labels":["Red"],"Properties":{}},{"Id":24,"Labels":["Blue"],"Properties":{}},{"Id":26,"Labels":["FINAL_NODE"],"Properties":{}}],"Relationships":[{"Id":0,"Type":"TO_ACTIVE_DRAFT","StartNodeId":1,"EndNodeId":0,"Properties":{}},{"Id":6,"Type":"TO_ATL","StartNodeId":21,"EndNodeId":1,"Properties":{}},{"Id":14,"Type":"TO_ACTIVE_DRAFT","StartNodeId":24,"EndNodeId":21,"Properties":{}},{"Id":18,"Type":"TO_FINAL","StartNodeId":24,"EndNodeId":26,"Properties":{}}]}},{"p":{"Start":{"Id":0,"Labels":["Red"],"Properties":{"key":"someid"}},"End":{"Id":26,"Labels":["FINAL_NODE"],"Properties":{}},"Nodes":[{"Id":0,"Labels":["Red"],"Properties":{"key":"someid"}},{"Id":1,"Labels":["Teal"],"Properties":{}},{"Id":21,"Labels":["Red"],"Properties":{}},{"Id":23,"Labels":["Blue"],"Properties":{}},{"Id":26,"Labels":["FINAL_NODE"],"Properties":{}}],"Relationships":[{"Id":0,"Type":"TO_ACTIVE_DRAFT","StartNodeId":1,"EndNodeId":0,"Properties":{}},{"Id":6,"Type":"TO_ATL","StartNodeId":21,"EndNodeId":1,"Properties":{}},{"Id":13,"Type":"TO_ACTIVE_DRAFT","StartNodeId":23,"EndNodeId":21,"Properties":{}},{"Id":17,"Type":"TO_FINAL","StartNodeId":23,"EndNodeId":26,"Properties":{}}]}},{"p":{"Start":{"Id":0,"Labels":["Red"],"Properties":{"key":"someid"}},"End":{"Id":26,"Labels":["FINAL_NODE"],"Properties":{}},"Nodes":[{"Id":0,"Labels":["Red"],"Properties":{"key":"someid"}},{"Id":1,"Labels":["Teal"],"Properties":{}},{"Id":21,"Labels":["Red"],"Properties":{}},{"Id":22,"Labels":["Blue"],"Properties":{}},{"Id":26,"Labels":["FINAL_NODE"],"Properties":{}}],"Relationships":[{"Id":0,"Type":"TO_ACTIVE_DRAFT","StartNodeId":1,"EndNodeId":0,"Properties":{}},{"Id":6,"Type":"TO_ATL","StartNodeId":21,"EndNodeId":1,"Properties":{}},{"Id":12,"Type":"TO_ACTIVE_DRAFT","StartNodeId":22,"EndNodeId":21,"Properties":{}},{"Id":16,"Type":"TO_FINAL","StartNodeId":22,"EndNodeId":26,"Properties":{}}]}}]
[Дополнительное уточнение]
Более конкретный пример: если вы перемещаете животных, у вас есть источник рождения, а затем у вас есть несколько движений, пока вы не доберетесь до рынка. таким образом, график выглядит как начальный скриншот, где красные узлы - это определенное место, куда животное было перемещено, а бирюзовый и синий - разные типы графиков. Тем не менее, единственная информация, которую я точно знаю, это то, где она находится в данный момент (так что за красный узел), и я хочу добраться до источника рождения (зеленый узел). Количество движений и местоположений, в которых он находился, являются переменными. Возможно, он был перемещен один раз или мог быть перемещен x раз. Я склонен знать, что пути ограничены 3 помеченными отношениями. Поэтому, хотя мне нравится синтаксис во многих процедурах apoc, если я не могу управлять этим путем после его получения, то, возможно, мне просто нужно сделать что-то вроде
MATCH (f:Red {key:'someid'})
OPTIONAL MATCH (f)<-[:TO_ACTIVE_DRAFT|TO_ATL*]-()-[:SOURCE_FOR_INC]->(g:Green)
RETURN g
, но для меня приведенное выше вернет только f или g, а не путь, поэтому должно быть что-то вроде этого:
MATCH (f:Red {key:'someid'})
p = OPTIONAL MATCH (f)<-[:TO_ACTIVE_DRAFT|TO_ATL*]-()-[:SOURCE_FOR_INC]->(g:Green)
RETURN p
, который, как я полагаю, даст мне путь, но будет таким же сценарием, как и в случае с apoc, где я не могу преобразовать данные в группы ...