# How to use Shortest Path Queries in query python

**URL:** https://discuss.dgraph.io/t/how-to-use-shortest-path-queries-in-query-python/11305
**Category:** Dgraph
**Tags:** dgraph
**Created:** [November 5, 2020, 3:29am UTC](https://discuss.dgraph.io/t/how-to-use-shortest-path-queries-in-query-python/11305 "2020-11-05T03:29:53Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![Mickey248](https://avatars.discourse-cdn.com/v4/letter/m/c67d28/32.png) [@Mickey248](https://discuss.dgraph.io/u/Mickey248)
#### Post date: [November 5, 2020, 3:29am UTC](https://discuss.dgraph.io/t/how-to-use-shortest-path-queries-in-query-python/11305/1 "2020-11-05T03:29:53Z")

</div>

i can show uid 0xbb, 0xb6, 0xb9 in this case

 ![Screen Shot 2563-11-05 at 10.21.57](https://canada1.discourse-cdn.com/flex007/uploads/dgraph/original/2X/b/b5622589c99b81a0fa227bedd5645a0bf45f46d5.png)  
but I can not show in Shortest Path Queries  
 ![Screen Shot 2563-11-05 at 10.26.06](https://canada1.discourse-cdn.com/flex007/uploads/dgraph/original/2X/6/639d90730a199f89b4db1b64581ef4c03263a61d.png)  
how to show in Shortest Path Queries

---

<div class="post-metadata">

### Author: ![anand](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/anand/32/5674_2.png) [@anand](https://discuss.dgraph.io/u/anand)
#### Post date: [November 5, 2020, 5:08am UTC](https://discuss.dgraph.io/t/how-to-use-shortest-path-queries-in-query-python/11305/2 "2020-11-05T05:08:22Z")

</div>

Hi @Mickey248,  
I can see the shortest path for the documented [example](https://dgraph.io/docs/query-language/kshortest-path-quries/).

 ![image](https://canada1.discourse-cdn.com/flex007/uploads/dgraph/original/2X/2/205ab23817aba908df44a62fc4bb91c1c1b5a3ba.png)

Can you please share the JSON output from your query?

---

<div class="post-metadata">

### Author: ![Mickey248](https://avatars.discourse-cdn.com/v4/letter/m/c67d28/32.png) [@Mickey248](https://discuss.dgraph.io/u/Mickey248)
#### Post date: [November 10, 2020, 8:37am UTC](https://discuss.dgraph.io/t/how-to-use-shortest-path-queries-in-query-python/11305/3 "2020-11-10T08:37:43Z")

</div>

yeah, it is good. but now I need to show name in node pink how to show

---

<div class="post-metadata">

### Author: ![anand](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/anand/32/5674_2.png) [@anand](https://discuss.dgraph.io/u/anand)
#### Post date: [November 10, 2020, 9:59am UTC](https://discuss.dgraph.io/t/how-to-use-shortest-path-queries-in-query-python/11305/4 "2020-11-10T09:59:21Z")

</div>

Hi @Mickey248,  
The pink nodes appear in the `_path_` section of the response. This section only contains uids and no attribute information is provided. Hence the pink nodes have no name.  
The `_path_` response is provided for the convenience of the client. The uids in the `_path_` response can be looked up by client for additional attribute information. I understand this does not help in putting a name to the pink nodes. AFAIK, this is a constraint right now.

---

<div class="post-metadata">

### Author: ![Mickey248](https://avatars.discourse-cdn.com/v4/letter/m/c67d28/32.png) [@Mickey248](https://discuss.dgraph.io/u/Mickey248)
#### Post date: [November 10, 2020, 10:03am UTC](https://discuss.dgraph.io/t/how-to-use-shortest-path-queries-in-query-python/11305/5 "2020-11-10T10:03:20Z")

</div>

ok. thank you very much. In the future. it can to show? yes or no?

---

<div class="post-metadata">

### Author: ![yilong2001](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/yilong2001/32/5823_2.png) [@yilong2001](https://discuss.dgraph.io/u/yilong2001)
#### Post date: [November 10, 2020, 3:19pm UTC](https://discuss.dgraph.io/t/how-to-use-shortest-path-queries-in-query-python/11305/8 "2020-11-10T15:19:20Z")

</div>

It is ok for v20.07.2.

 ![image](https://canada1.discourse-cdn.com/flex007/uploads/dgraph/original/2X/3/391109416c56181cd9e451842f4107dbe0843785.png)  
Is there something different?

---

<div class="post-metadata">

### Author: ![anand](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/anand/32/5674_2.png) [@anand](https://discuss.dgraph.io/u/anand)
#### Post date: [November 11, 2020, 2:47pm UTC](https://discuss.dgraph.io/t/how-to-use-shortest-path-queries-in-query-python/11305/9 "2020-11-11T14:47:42Z")

</div>

Hi @Mickey248  
Could you please try this query? It tries to collect additional names, and I am able to see the names of additional nodes.

```auto
{

 A as var(func: eq(name, "Alice"))
 M as var(func: eq(name, "Mallory"))

 path as shortest(from: uid(A), to: uid(M), numpaths: 2) {
  friend
 }
 path(func: uid(path)) {
   name
   f as friend
 }
 mfriends(func: uid(f)) @recurse{
  name
  friend
 }
}

```

Output:  
 ![image](https://canada1.discourse-cdn.com/flex007/uploads/dgraph/original/2X/5/5d6ffd1ccfc7e4f962d46763fd5b795a1e8ea238.png)

This is a bit of a hack. It may add additional nodes to the view.
