When writing the result back to the graph, we will have to use the .write procedure instead of .stream. In addition, an extra mandatory parameter is required – the name of the property that will be added to each node and hold the result of the algorithm (here, that is the PageRank score). This property is configured through the writeProperty configuration, so let's add it to our algoConfig dictionary:
algoConfig["writeProperty"] = "pr"
We can then use the same code to run this procedure, replacing gds.pageRank.stream with gds.pageRank.write:
with driver.session() as session:
result = session.run(
"CALL gds.pageRank.write($graphName, $algoConfig)",
graphName=graphName,
algoConfig=algoConfig,
)
If we check the content of the result this time, it only contains some statistics about the algorithm execution:
>>> result.single().data()
{'nodePropertiesWritten': 596,
'createMillis': 0,
...