In neo4j i'm using GDS' Yen's k-algo to get top 3 shortest path between two nodes.
but im having hard time projecting my graph into memory thus Yen's k alog not giving me my desired output.
CALL gds.graph.project(
'test1',
['A', 'B', 'C', 'D'],
{Director_In: {orientation: 'UNDIRECTED'}, Shareholder_In: {orientation: 'UNDIRECTED'}}
)
YIELD
graphName AS graph, nodeCount AS nodes, relationshipCount AS rels
this gives me result but with virtual relationship having nagative cost like PATH_0, PATH_1 PATH_2...
(some guy on discord suggested me to use Undirected
orientation)
but when i'm using cupher projection im getting no result..
CALL gds.graph.project.cypher(
'persons',
'MATCH (n) RETURN id(n) AS id',
'MATCH (n)-[r]->(m) RETURN id(n) AS source, id(m) AS target, type(r) AS type')
YIELD
graphName AS graph, nodeQuery, nodeCount AS nodes, relationshipQuery, relationshipCount AS rels
and below is my cypher query
MATCH (source:A {prop: 1}), (target:B {prop: 3})
CALL gds.shortestPath.yens.stream('persons', {
sourceNode: source,
targetNode: target,
k:4
})
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
PS:- when im using normal shortestPath
i get the desired result.
MATCH path = shortestPath((start:A)-[*]-(end:B))
where elementId(start) = "1:x:4" and elementId(end) = "124:x:123"
i get my desired output from the above query.
How should i project my graph so that i can get the desired result?
(also my graph is not weighted)