Skip to content

Shortest path computes wrong path #4169

@campoy

Description

@campoy

What version of Dgraph are you using?

v1.1.0

Have you tried reproducing the issue with the latest release?

yes

What is the hardware spec (RAM, OS)?

n/a

Steps to reproduce the issue (command/config used to run Dgraph).

Given this data and assuming a name has an exact index:

{
  set {
    _:a <name> "A" .
    _:b <name> "B" .
    _:c <name> "C" .
    _:d <name> "D" .

    _:a <connects> _:b  (weight=10) .
    _:a <connects> _:c  (weight=1) .
    _:a <connects> _:d  (weight=10) .

    _:c <connects> _:a  (weight=10) .
    _:c <connects> _:b  (weight=10) .
    _:c <connects> _:d  (weight=1) .

    _:b <connects> _:a  (weight=10) .
    _:b <connects> _:c  (weight=10) .
    _:b <connects> _:d  (weight=10) .

    _:d <connects> _:a  (weight=10) .
    _:d <connects> _:b  (weight=1) .
    _:d <connects> _:c  (weight=10) .
  }
}

We try to get the shortest path from A to B using the weight facet for it and limiting to D depth.

{
  a as var(func: eq(name, "A"))
  b as var(func: eq(name, "B"))
  
  path as shortest(from: uid(a), to: uid(b), depth: D) {
    connects @facets(weight)
  }
  
  path(func: uid(path)) {
    uid
    name
  }
}

Expected behaviour and actual result.

This table explains what I expect to see vs what I got:

D expected path (cost) got path (cost) ok
0 N/A A - B (10)
1 A - B (10) A - C - D - B (3)
2 A - B (10) A - B (10) ✔️
> 3 A - C - D - B (3) A - B (3)

Metadata

Metadata

Assignees

Labels

area/querylang/algosRelated to graph algorithms, such as k-shortest path.priority/P1Serious issue that requires eventual attention (can wait a bit)status/acceptedWe accept to investigate/work on it.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions