Closed MattyCrowther closed 1 year ago
Hello @MattyCrowther and thanks for reaching out.
Let's see. So you want paths that traverse several (2, in your example) different chains of relationships to be collapsed into one single relationship type. And then you want to compute algorithms over the collapsed graph?
It seems to me like it would be equivalent to performing collapsePath
twice, and then using both of the mutated relationship types as input for the algorithm. For example:
CALL gds.alpha.collapsePath.mutate(
'jscgocwyqc',
{
relationshipTypes: ['repressor', 'repressed', 'activator', 'activated', 'template', 'product'],
mutateRelationshipType: 'Repression1',
allowSelfLoops: false,
nodeLabels: ['Protein']
}
) YIELD relationshipsWritten
and then
CALL gds.alpha.collapsePath.mutate(
'jscgocwyqc',
{
relationshipTypes: ['repressor', 'repressed', 'activator'],
mutateRelationshipType: 'Repression2',
allowSelfLoops: false,
nodeLabels: ['Protein']
}
) YIELD relationshipsWritten
and then followed by your algorithm, for example WCC:
CALL gds.wcc.stream('jscgocwyqc', {relationshipTypes: ['Repression1', 'Repression2']})
You mention that
Currently, I am creating unique types for each mutation but the resultant graph is difficult to work with
Where perhaps you are doing more or less exactly what I describe above? I would like to understand more what the difficult parts are; would you like to share some more detail on this?
Yes, so that is what I am currently doing I then create a new projection using https://neo4j.com/docs/graph-data-science/current/graph-project-subgraph/ to only use the mutateRelationships. From this, we would apply some procedures to the final projected graph. However, to do this computationally we have to remember that Repression1, Repression2 .... all equal Repression, and if we have more relationship types such as "Activation" this becomes more difficult. I am not saying it's not possible, it just seems I am working around the library as opposed to working with it.
I understand. I think the feature makes sense -- we'll add it to the backlog and take it into account when planning more work for collapsePath. Thank you so much for the feedback!
Hey @MattyCrowther , You will be pleased to know we implemented the feature you suggested, it will come out with the 2.2 alpha release that's due ~tomorrow. Happy hacking!
Hi, I submitted this within the forums and got an answer. However, Is this correct? A summary of my question: 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:
Essentially I would like to collapse multiple paths into a single mutatedType. However, clearly, the syntax above is invalid also if you run the collapsePath multiple times an error is returned. I feel like this is valid functionality because there are multiple steps within the mutations as the original projection changes the shape and these mutations change the shape once more. Currently, I am creating unique types for each mutation but the resultant graph is difficult to work with. Perhaps a parameter that allows this type of behaviour? https://community.neo4j.com/t/collapsepath-multiple-paths-to-one-type/56270