Aggregate Parallel Relationships after gds.alpha.collapsePaths

Main query
Is it possible to either...

  • a) Aggregate parallel relationships on an existing GDS graph projection after it has been created.
  • b) Create a new graph projection using the content of an existing one?

I have a projected graph...

CALL gds.graph.create('test','USER',{
     REPRESENTS: {type: 'REPRESENTS',orientation: 'NATURAL'},
     FOLLOWS: {type: 'FOLLOWS', orientation: 'NATURAL'}}) 
YIELD graphName, nodeCount,relationshipCount

and I have mutated it using gds.alpha.collapsePath.mutate

CALL gds.alpha.collapsePath.mutate('test', {
Yield relationshipsWritten

The point of it is to collapse down the current relationship to a simplified version.


After my original test graph has been mutated, and had the META_FOLLOWS relationship added, I wanted to aggregate all parallel relationships so that I would have distinct relationships between nodes, each with a weight property that was equal to the count of parallel relationships. If collapsePath had written directly to the database I (think i) would do the following..

CALL gds.graph.create('final_graph', 'USER', {
           weight:{property: '*', aggregation: 'COUNT'}

Is the only way ahead to manually stream out the META_FOLLOWS relationship from the first graph, save it to the DB and then run the second projection with the aggregation, or is there a way to do this all in one projection?

Any advice would be very helpful, thanks!

*NB for reasons I can't just export the projection to another database.

May be you can take a export dump of a data model in neo4j browser and then import it into another preconfigured instance.( If you have bloom installed ?)

1 Like

Right now, we don't have the option to have collapsePath output a relationship weight, or to re-aggregate relationships on an existing in memory graph, but those are both great feature requests!

For now, you can either write the new relationship back to the database & re-load or use gds.graph.export to dump the in-memory graph to a new database and load from that . Since it sounds like graph.export isn't an option, you'll want to use gds.graph.writeRelationship.

1 Like

Thanks Alicia,

I did try gds.graph.writeRelationship which did work, though the output of collapsePath for my project is a few million new relationships so it is rather slow going - may still be faster to do that than my current more manual cyper query which collapses the paths and aggregates the relationships so I'll have a go.

Is there a formal way to do feature requests? I think being able to re-aggregate existing in memory graphs would be a great addition given the number of mutate features in GDS.

The best way to make a feature request is to open an issue our our github: Issues · neo4j/graph-data-science · GitHub

1 Like

I think a possible feature could be a mechanism to attach and detach a Property SubGraph to existing node.
Sameer G