cancel
Showing results for 
Search instead for 
Did you mean: 

Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.

CollapsePath, multiple paths to one type

Hi,
I am using the collapsePath functionality to create specialised subgraphs.
There is a case when many paths map to a single mutateRelationshipType.
For example I would like to do something like:

    CALL gds.alpha.collapsePath.mutate(
    'jscgocwyqc',
    {
        relationshipTypes: [['repressor', 'repressed', 'activator', 'activated', 'template', 'product'],['repressor', 'repressed', 'activator']],
        mutateRelationshipType: 'Repression',
        allowSelfLoops: false
        ,nodeLabels: ['Protein']
    }
    ) YIELD relationshipsWritten

I.e. both of these relationshipType paths map to the same relationship,
If you run the collapsePath two times with the two lists you get the error:
Failed to invoke procedure gds.alpha.collapsePath.mutate: Caused by: java.lang.IllegalArgumentExcep
tion: Relationship type Repression already exists in the in-memory graph.

Any halp would be much appreciated.

3 REPLIES 3

collapsePath won't let you create the same relationship twice. If you want to run it more than once, then you would want to call them Repression1 and Repression2

For any algorithm you run, you can always specify that it should run on both relationships (Repression1 and Repression2`).

Hi thanks for your reply. Is there a reason for this? On a surface level it seems like multiple paths should be able to be reduced to the same relationship type.

It's implemented that way to prevent user error/confusion - people inadvertently overwriting relationships, and losing track of what they're analyzing. Relationships can be merged on graph load (Creating graphs - Neo4j Graph Data Science) but not once the graph has been projected.