Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
08-01-2021 03:10 AM
I follow this Link to use a graph generator to create a graph scaling to +10000 nodes and to execute the shortest path algorithm between two nodes.
How can I set the relationship property for all the nodes to be in a specific range?
This Link provides more options, but I don't know how to use it. Any help?
08-01-2021 04:23 PM
Hi @samasamaan
You can use "apoc.generate.er".
CALL apoc.generate.er(10,5,'TestLabel', 'TEST_REL_TYPE');
This command will create this graph.
10 Nodes
5 Relationships
'TestLabel' (Label)
'TEST_REL_TYPE' (Relationship)
Is it the answer you're looking for?
08-01-2021 09:30 PM
Hello
Ok but I want to set relationship property for all the edges in a specific range (min,max). This APOC doesn't provide such parameter.
08-02-2021 01:56 AM
Hi @samasamaan
There doesn't seem to be a specific range (min,max) for apoc.generate.
Sorry.
But, You can copy and create a new command from APOC 🙂
08-02-2021 02:43 PM
08-23-2021 03:12 AM
Hello @koji
Thanks for you help. I return back to use the queries in this link: https://neo4j.com/labs/apoc/4.1/graph-updates/graph-generators/
You said: But, You can copy and create a new command from APOC. How can I do this? please I want to create & set a relationship property to all the edges in a specific range.
08-23-2021 06:24 AM
Hi @samasamaan
You can clone APOC and add/modify the function.
Build & install the current development branch from source
git clone http://github.com/neo4j-contrib/neo4j-apoc-procedures cd neo4j-apoc-procedures
./gradlew shadow
cp build/libs/apoc-<version>-all.jar $NEO4J_HOME/plugins/
$NEO4J_HOME/bin/neo4j restart
08-24-2021 01:33 AM
Thanks but I didn't understand how to update an APOC.
Any help will be appreciated.
08-30-2021 12:47 PM
This how I solve the problem:
CALL apoc.generate.ba(100, 4, 'Node', 'connect')
merge (n)-[c:connect]->(m)
set c.cost=toInteger(rand() * 10)
CALL gds.graph.create('myGraph', 'Node', 'connect', {relationshipProperties: 'cost'})
CALL gds.shortestPath.dijkstra.stream('myGraph', {
CALL gds.shortestPath.dijkstra.stream('myGraph', {
sourceNode: 26,
targetNode: 31,
relationshipWeightProperty: 'cost'
})
YIELD index, sourceNode, targetNode, totalCost, nodeIds, costs, path
RETURN
index,
gds.util.asNode(sourceNode).name AS sourceNodeName,
gds.util.asNode(targetNode).name AS targetNodeName,
totalCost,
[nodeId IN nodeIds | gds.util.asNode(nodeId).name] AS nodeNames,
costs,
nodes(path) as path
ORDER BY index
Suggestions please.
All the sessions of the conference are now available online