cancel
Showing results for 
Search instead for 
Did you mean: 

Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.

Cypher query giving back multiple paths connecting the given multiple nodes (more than 2)

rakesh
Node Link

Hi All,

I'm new to Cypher queries and I'm looking for a query which would return all the paths connecting given multiple nodes. I found below algorithm in one of the old code and trying to understand what it's doing. Is there a page which explain how would these algorithms work? I looked around and found nothing to give more info about what are the parameters or fields would do in the below algorithm.

Example: Given Nodes: A, B, C, D Possible Paths: A->B->C->D, A->F->B->C->E->D

Old Algo I found

WITH DISTINCT z, a CALL algo.kShortestPaths.stream(a, z, 5, 'mileage', 
	{
		nodeQuery:'MATCH (n:EquipmentNode) RETURN id(n) AS id ', 
		relationshipQuery:'MATCH p = (n:EquipmentNode)-[r:CONNECTED_TO]-(m:EquipmentNode)
			WHERE ALL ( Q IN relationships(p)
			WHERE Q.totalChannels > 0 AND (Q.totalChannelsUsed < Q.totalChannels)  )
			RETURN id(n) AS source, id(m) AS target, r.mileage AS weight, r.trailName AS linkName, r.networkId AS linkNetworkId ', 
		maxDepth:75, 
		direction:'BOTH', 
		defaultValue:0.0, 
		write: false , 
		graph:'cypher', 
		path: true
	}
) YIELD path, index, nodeIds, costs
3 REPLIES 3

Hello @rakesh

I suppose you are using Neo4j 3.5 since algo.* was used by the old plugin Graph Algortihms. Since Neo4j 4.0, the plugin became Graph Data Science (GDS) library. Here is the latest documentation for this algorithm. You can also use this page to get more information about old configurations. You should upgrade Neo4j to at least version 4 since the support is almost over.

Regards,
Cobra

Thanks @Cobra! I will take a look at it. The above part is giving timeout in some searches so any pointers why that is happening?

error I get: Neo.ClientError.Transaction.TransactionTimedOut

The request may have taken too long, try to increase the RAM allocated to the database. Have a look at neo4j-admin memrec.