Iam searching for the right cypher query to get the first and last nodes of paths when selecting a node which is in between. The idea is to compress a large impact graph so that only the sources (only outgoing edges = green nodes) and the final consequences (only incoming edges = red nodes) as well as the selected node is displayed.
Here is an illustrative example graph:
Now, when selecting e.g node d
, i would like to receive node d
and the first node
and last node
of every path in which node d
is part of as well as the respective (new) relationships so that the output is the follwing graph:
Hence, Iam searching for a kind of collapsing where the start and end nodes are excluded.
Due to this answer I already know that is possible to create virtual graphs with apoc.create.vRelationship
.
But Iam struggling with the identification of the green start nodes
and red end nodes
as described above as well as the creation of the desired output.
Iam searching for a query where only the node in between (e.g node d
) is a parameter and the output is always like in the second image.
I appreciate every help or inspiration a lot, thank you in advance!