Skip to content

Bellman-Ford stream command showing unclear Warnings in Neo4j logs. #355

Open
@nirajvora

Description

@nirajvora

Describe the bug
Running Bellman-Ford from arbitrary startNodes randomly WARNS with the following failure, and I just don't understand what's happening. For most sourceNodes that I specify this doesn't happen, but when it does happen I have no idea what it means and why it's happening:

dex-graph-neo4j  | 2025-05-01 23:36:35.197+0000 INFO  [neo4j.BoltWorker-5 [bolt-8 - /172.18.0.1:61776]] Bellman-Ford :: Start
dex-graph-neo4j  | 2025-05-01 23:36:35.197+0000 INFO  [neo4j.BoltWorker-5 [bolt-8 - /172.18.0.1:61776]] Bellman-Ford :: Relax 1 :: Start
dex-graph-neo4j  | 2025-05-01 23:36:35.198+0000 INFO  [neo4j.BoltWorker-5 [bolt-8 - /172.18.0.1:61776]] Bellman-Ford :: Relax 1 100%
dex-graph-neo4j  | 2025-05-01 23:36:35.198+0000 INFO  [neo4j.BoltWorker-5 [bolt-8 - /172.18.0.1:61776]] Bellman-Ford :: Relax 1 :: Failed
dex-graph-neo4j  | 2025-05-01 23:36:35.198+0000 INFO  [neo4j.BoltWorker-5 [bolt-8 - /172.18.0.1:61776]] Bellman-Ford :: Failed
dex-graph-neo4j  | 2025-05-01 23:36:35.198+0000 WARN  computation failed, halting metrics gathering
dex-graph-neo4j  | java.lang.ArrayIndexOutOfBoundsException: Index 199 out of bounds for length 199
dex-graph-neo4j  | 	at org.neo4j.gds.collections.ha.HugeLongArray$SingleHugeLongArray.set(HugeLongArray.java:282) ~[graph-data-science.jar:?]
dex-graph-neo4j  | 	at org.neo4j.gds.paths.bellmanford.BellmanFordTask.processNegativeCycle(BellmanFordTask.java:161) ~[graph-data-science.jar:?]
dex-graph-neo4j  | 	at org.neo4j.gds.paths.bellmanford.BellmanFordTask.processNode(BellmanFordTask.java:87) ~[graph-data-science.jar:?]
dex-graph-neo4j  | 	at org.neo4j.gds.paths.bellmanford.BellmanFordTask.relaxPhase(BellmanFordTask.java:134) ~[graph-data-science.jar:?]
dex-graph-neo4j  | 	at org.neo4j.gds.paths.bellmanford.BellmanFordTask.run(BellmanFordTask.java:168) ~[graph-data-science.jar:?]
dex-graph-neo4j  | 	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539) [?:?]
dex-graph-neo4j  | 	at java.util.concurrent.FutureTask.run(FutureTask.java:264) [?:?]
dex-graph-neo4j  | 	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136) [?:?]
dex-graph-neo4j  | 	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635) [?:?]
dex-graph-neo4j  | 	at java.lang.Thread.run(Thread.java:840) [?:?]
dex-graph-neo4j  | 	at org.neo4j.gds.core.concurrency.NamedThreadFactory$2.run(NamedThreadFactory.java:80) ~[graph-data-science.jar:?]

To Reproduce

CALL gds.bellmanFord.stream($graphName, {
               sourceNode: $startNodeId,
               relationshipWeightProperty: 'negLogRate'
           })
           YIELD index, sourceNode, targetNode, totalLength, nodeIds, costs, route, isNegativeCycle
           WHERE exp(-totalLength) > 1.001
           RETURN DISTINCT
   			totalLength, 
   			[nodeId IN nodeIds | gds.util.asNode(nodeId).name] AS assetNames, 
   			[nodeId IN nodeIds | gds.util.asNode(nodeId).id] AS assetIds,
   			[i IN range(0, size(costs)-2) | 
   				toString(
   					apoc.number.exact.sub(
   						apoc.number.format(costs[i+1], '#.##################'),
   						apoc.number.format(costs[i], '#.##################')
   					)
   				)
   			] AS edgeWeights

GDS version: 2.13
Neo4j version: 5.26.5
Operating system: Running the docker image image: neo4j:5.26.5 on my macbook air with M2 chip

Steps to reproduce the behavior:
Create any graph in neo4j with edgeweights. simply project the graph using the following call

		CALL gds.graph.project.cypher(
			$graphName,
			'MATCH (n:Node) RETURN id(n) AS id',
			'MATCH (s:Node)-[r:RELATIONSHIP]->(t:Node) 
			RETURN id(s) AS source, 
					id(t) AS target, 
					toFloat(r.negLogRate) AS negLogRate'
		)

Run the bellman-ford stream command shown above for every possible node in the graph as a starting point. Most will work fine but some will randomly WARN with the failure described above.

Expected behavior
No error or warning or at least a more clear understanding of why that particular bellman-ford call failed

Additional context
Most other calls with the exact same CALL gds.bellmanFord.stream command but just a different startnodeID don't fail. I just want to understand why this is randomly happening and if it is expected based on the algorithm or if something is wrong with how I'm projecting a graph.

Metadata

Metadata

Assignees

No one assigned

    Labels

    BUGSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions