Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
02-14-2021 03:21 PM
Main query
Is it possible to either...
Why?
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', {
relationshipTypes:['FOLLOWS','REPRESENTS'],
allowSelfLoops:false,
mutateRelationshipType:'META_FOLLOWS'})
Yield relationshipsWritten
The point of it is to collapse down the current relationship to a simplified version.
(a: USER)-[:REPRESENTS]->(:USER)-[:FOLLOWS]->(:USER)<-[:REPRESENTS]-(b:USER)
(a:USER)-[:META_FOLLOWS]->(b:USER)
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', {
META_FOLLOWS: {
properties:{
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.
Solved! Go to Solution.
02-15-2021 09:21 AM
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
.
02-15-2021 08:45 AM
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 ?)
02-15-2021 09:21 AM
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
.
02-16-2021 01:44 AM
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.
02-16-2021 05:54 AM
The best way to make a feature request is to open an issue our our github: Issues · neo4j/graph-data-science · GitHub
02-16-2021 02:27 PM
I think a possible feature could be a mechanism to attach and detach a Property SubGraph to existing node.
Thanks
Sameer G
08-11-2022 04:36 AM
Hi, Minyall
Did I understand correctly that you get parallel META_FOLLOWS relations between a pair of nodes? I asking because the "gds.alpha.collapsePaths" documentation says that only one connection is created between a pair of nodes.
Thanks in advance for your answer
All the sessions of the conference are now available online