Reputation: 467
I'm trying to visualise a graph based on a repeated pattern and apoc.path.subgraphAll seems to be the thing to use.
With the query:
MATCH (av:Architecture_View {`view identifier`:'SV-01'})
//pattern is (Architecture_View)-[:SUPPLIES]->(Architecture_Description_Tuple)-[:`SUPPLIED TO`]->(Architecture_View)
CALL apoc.path.subgraphAll(av,{
beginSequenceAtStart: true,
sequence: "`SUPPLIES`>,Architecture_Description_Tuple,`SUPPLIED TO`>,Architecture_View"})
YIELD nodes, relationships
RETURN nodes, relationships;
I simply get the start node (av) returned. No errors are returned.
If I simply manually run a query to iterate this pattern once
MATCH r=(av:Architecture_View {`view identifier`:'SV-01'})-[:SUPPLIES]-(adt:Architecture_Description_Tuple)-[:`SUPPLIED TO`]->(av2:Architecture_View)
RETURN r
I get a graph as expected.
Is there somethng wrong with the way in the statement which returns the apoc.path.subgraphAll result or the sequence definition?
Upvotes: 0
Views: 308
Reputation: 2905
If you're specifying beginSequenceAtStart
, the sequence pattern that you supply must include the starting node. In your case, the starting pattern begins from the first relationship out of the starting node.
For example, given the following test data:
MERGE (a: View { id: 1 })-[:SUPPLIES]->(b: DescriptionTuple { desc: 'description' })-[:SUPPLIED_TO]->(a2: View {id: 2 })
The following two queries will both return subgraph connecting a
to a2
- notice how beginSequenceAtStart
and the initial chunk of the sequence string are different in the two cases:
// beginSequenceAtStart false, start with the first relationship type
MATCH (a: View { id: 1 })
CALL apoc.path.subgraphAll(a, {
beginSequenceAtStart: false,
sequence: "SUPPLIES>,DescriptionTuple,SUPPLIED_TO>,View"
})
YIELD nodes, relationships
RETURN nodes, relationships
// beginSequenceAtStart true, begin with the first node label
MATCH (a: View { id: 1 })
CALL apoc.path.subgraphAll(a, {
beginSequenceAtStart: true,
sequence: "View,SUPPLIES>,DescriptionTuple,SUPPLIED_TO>,View"
})
YIELD nodes, relationships
RETURN nodes, relationships
Upvotes: 1