Closed schwab closed 5 years ago
@schwab // (:node_X)-[:relation_1]->(:nodeC)<-[:relation_2]-(:node_Y)
redis_graph = Graph('G', r)
node_X = Node(label='node_X')
nodeC = Node(label='nodeC')
node_Y = Node(label='node_Y')
redis_graph.add_node(node_X)
redis_graph.add_node(nodeC)
redis_graph.add_node(node_Y)
relation_1 = Edge(node_X, 'relation_1', nodeC)
relation_2 = Edge(node_Y, 'relation_2', nodeC)
redis_graph.add_edge(relation_1)
redis_graph.add_edge(relation_2)
If you commit this graph the pattern you're after will be formed.
If you're after performing matches, then currently the API doesn't abstract that, you'll have to use the query
function and pass in a query string.
Recall that:
MATCH (a:node_X)-[:relation_1]->(b:nodeC), (c:node_Y)-[:relation_2]->(b:nodeC)
is equivalent to: MATCH (a:node_X)-[:relation_1]->(b:nodeC)<-[:relation_2]-(c:node_Y)
is equivalent to: MATCH (a:node_X)-[:relation_1]->(b:nodeC) MATCH (c:node_Y)-[:relation_2]->(b:nodeC)
Got it. Then it sounds like putting some effort into our own query generator objects won't be a waste of time.
Currently, Edge only supports connections in the right direction since the edge str method only outputs the relationships in the format -[:relation]-> . This makes doing more complicated double relationships impossible using the current edge object. So, how can we express this MATCH?
(:node_X)-[:relation_1]->(:nodeC)<-[:relation_2]-(:node_Y)
?We are planning to implement our own expression builder for cases like this, but it would be nice if we could extend from the existing edge objects or know that if we do, it won't be outdated by a future release. What's the plan for this going forward?