0
votes

I have a graph that contains mechanical parts that are composed of other parts, and I want to show a whole composition of a big part. All the relevant nodes in my graph have the "Structure" label, and when one part is composed of other parts there is a "PartProperty" relationship. So I need a query that has a starting point defined by a name such as "Vehicle" or "CombusionEngine" and then it should find all outgoing "PartProperty" relationships from this node. Some of the sub-parts also have sub-parts and some don't.

Here is an example of the composition:

When I just match the relationship I only get the first subelement and when I match the second level, the Elements without substructure will disappear.

1

1 Answers

0
votes

Here is a sample query that uses a variable-length relationship pattern to return the paths to all the parts (and sub-parts) of the specified start node:

MATCH path=(start:Structure)-[:PartProperty*]->()
WHERE start.name = "CombusionEngine"
RETURN path

And here is a variation that just returns all the distinct parts (and sub-parts):

MATCH (start:Structure)-[:PartProperty*]->(part)
WHERE start.name = "CombusionEngine"
RETURN DISTINCT part