+1 vote
in Databases by (56.5k points)
Is there any function to find the shorted path between two nodes in a Neo4j graph?

1 Answer

+2 votes
by (348k points)
selected by
Best answer

Yes, Neo4j provides a built-in function "shortestPath()" to find the shortest path between two nodes in a graph. You can use this function in your Cypher queries to retrieve the shortest path.

Here's an example of how to use the shortestPath() function in a Cypher query:

MATCH path = ShortestPath((c1:Compound)-[*]-(c2:Compound))

WHERE c1.node_id = 'PUBCHEM_CID 2381' AND c2.node_id = 'PUBCHEM_CID 5281081'