Skip to content
This repository was archived by the owner on Apr 22, 2020. It is now read-only.
This repository was archived by the owner on Apr 22, 2020. It is now read-only.

Write total cost of shortest path to property #912

Open
@szarnyasg

Description

@szarnyasg

I am using the latest versions (Neo4j 3.5.8, Algorithm library 3.5.8.0).

Given a simple two-node graph:

CREATE ({VID: 1})-[:EDGE {weight: 0.2}]->({VID: 2})

I'd like to run an SSSP algorithm and save the total cost of the paths to property SSSP.

MATCH (startNode {VID: 1}), (endNode)
CALL algo.shortestPath(startNode, endNode, 'weight', {write: true, writeProperty: 'SSSP', direction: 'OUTGOING'} )
YIELD nodeCount, totalCost, loadMillis, evalMillis, writeMillis
RETURN endNode.VID, totalCost

The results are correct:

╒═════════════╤═══════════════════╕
│"endNode.VID"│"totalCost"        │
╞═════════════╪═══════════════════╡
│1            │-1.0               │
├─────────────┼───────────────────┤
│2            │0.20000000298023224│
└─────────────┴───────────────────┘

But the propery contains the traversal level and not the total cost:

MATCH (n)
RETURN n.VID, n.SSSP
╒═══════╤════════╕
│"n.VID"│"n.SSSP"│
╞═══════╪════════╡
│1      │0       │
├───────┼────────┤
│2      │1       │
└───────┴────────┘

Is there a way to write the total cost to the property?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions