cancel
Showing results for 
Search instead for 
Did you mean: 

Relationship Projection with bridge node

Keith_gamble
Node Clone

I am trying to write a configuration map for gds.wcc.write that goes through a bridge node, with specified relationships.

I think that I need cypher projection, because native projection didnt seem to be able to handle the jump, but potentially I am missing something.

Here is the schema, I need to identify all Equipment connected by a leg
3X_c_e_ce57aace681f1900cfd58098fbe4e1970e43e406.png

Here is what I have

CALL gds.wcc.stream({
    nodeQuery: "MATCH (n) WHERE n:Equipment OR n:Leg OR n:OPCODE RETURN id(n) as id",
	relationshipQuery: "MATCH (s:Equipment)-[r1:DRAINS]->(l:Leg)-[r2:FEEDS]->(t:Equipment) RETURN id(s) AS source, id(t) AS target, id(l) as leg, id(r1) as feed, id(r2) as prod"}
)

Originally I was connecting Equipment directly next to Equipment with a different relationship, but now I need to add this Leg in the middle of things. Originally I could just execute this:

CALL gds.wcc.write({nodeProjection: "Equipment", relationshipProjection: "CONNECTS_TO",writeProperty: "community_id"}

Thanks for any help!

1 ACCEPTED SOLUTION

Hello Keith,

This will indeed create a projection with all your :Equipment and :Leg nodes, with the FEEDS and DRAINS relationships between them.

As for the orientation, this is configurable, and it maintains the original orientation by default. See the docs here.
This parameter only allows you to define the relationship orientation to its original orientation, or reverse it, or add both directions ; if you need a filter like "I only want the FEEDS rels that go from a Leg to an Equipment", then Cypher projection is the way to go. If you relationship is uni-directional anyway, then your solution is the right one.

Cheers !

View solution in original post

2 REPLIES 2

Keith_gamble
Node Clone

Actually I think that this did what I was looking for!

CALL gds.wcc.write({nodeProjection: ["Equipment", "Leg"], relationshipProjection: ["FEEDS", "DRAINS"],writeProperty: "community_id"})

It doesn't really specify the order of the connection though, so I am not sure if its 100% correct.

Hello Keith,

This will indeed create a projection with all your :Equipment and :Leg nodes, with the FEEDS and DRAINS relationships between them.

As for the orientation, this is configurable, and it maintains the original orientation by default. See the docs here.
This parameter only allows you to define the relationship orientation to its original orientation, or reverse it, or add both directions ; if you need a filter like "I only want the FEEDS rels that go from a Leg to an Equipment", then Cypher projection is the way to go. If you relationship is uni-directional anyway, then your solution is the right one.

Cheers !