samasamaan
(Sama Samaan)
August 1, 2021, 10:10am
1
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?
koji
(Koji Annoura)
August 1, 2021, 11:23pm
2
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?
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.
koji
(Koji Annoura)
August 2, 2021, 8:56am
4
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 :)
samasamaan
(Sama Samaan)
August 23, 2021, 10:12am
6
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.
koji
(Koji Annoura)
August 23, 2021, 1:24pm
7
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
1 Like
samasamaan
(Sama Samaan)
August 24, 2021, 8:33am
8
Thanks but I didn't understand how to update an APOC.
Any help will be appreciated.
samasamaan
(Sama Samaan)
August 30, 2021, 7:47pm
9
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.