# How can i get a speical node with its all accessible nodes

**URL:** <https://discuss.dgraph.io/t/how-can-i-get-a-speical-node-with-its-all-accessible-nodes/7203>\
**Category:** Dgraph\
**Tags:** mutation, kind:bug\
**Created:** [June 15, 2020, 6:13am UTC](https://discuss.dgraph.io/t/how-can-i-get-a-speical-node-with-its-all-accessible-nodes/7203 "2020-06-15T06:13:19Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![luke](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/luke/32/10557_2.png) [@luke](https://discuss.dgraph.io/u/luke)\
**Post date:** [June 15, 2020, 6:13am UTC](https://discuss.dgraph.io/t/how-can-i-get-a-speical-node-with-its-all-accessible-nodes/7203/1 "2020-06-15T06:13:19Z")

</div>

I want to get a node with its all accessible nodes,so i use **@recurse**.like **c** i will get (BEF) ,like j  
i will get(h) There are to problems  
1.with the result of **recurse** there has no edges showed in graph  
2.If I want to find multiple nodes at once, there is no way to distinguish results of **‘c’ and ‘j’**  
I have tried **recurse** with **~** but maybe dgraph don’t support it  
I wonder if there any better way to solve this problem or i should update my schema

```auto
#SCHEMA
{
    set {
        _:A <guid_to> _:g1 .
        _:g1 <guid_to> _:B .
        _:B <guid_to> _:g1 .
        _:g1 <guid_to> _:C .
        _:B <guid_to> _:E .
        _:E <guid_to> _:B .
        _:B <guid_to> _:g2 .
      	_:C <guid_to> _:g1 .
        _:g2 <guid_to> _:F .
        _:g3 <guid_to> _:H .
        _:H <guid_to> _:g3 .
        _:H <guid_to> _:J .
        _:J <guid_to> _:H .

        _:A <name> "a" .
        _:B <name> "b" .
        _:C <name> "c" .
        _:D <name> "d" .
        _:E <name> "e" .
        _:F <name> "f" .
     	  _:G <name> "g" .
        _:H <name> "h" .
        _:J <name> "j" .
        _:g1 <name> "g1" .
       	_:g1 <gtype> "g1" .
        _:g2 <name> "g2" .
      	_:g2 <gtype> "g2" .
    }
}

#QUERY
{
  node (func: eq(name, ["c","j"])) @recurse{
     gt as guid_to
    }
  
  exclude (func:has(gtype)){
    en as name
  }
	result (func: uid(gt)) @filter(NOT uid(en)){
    name
  }
  
}

```

![WechatIMG12](https://canada1.discourse-cdn.com/flex007/uploads/dgraph/original/2X/4/40e935a1f9011bddf861105304740de2eef5fecc.png)

---

<div class="post-metadata">

**Author:** ![luke](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/luke/32/10557_2.png) [@luke](https://discuss.dgraph.io/u/luke)\
**Post date:** [June 15, 2020, 6:36am UTC](https://discuss.dgraph.io/t/how-can-i-get-a-speical-node-with-its-all-accessible-nodes/7203/2 "2020-06-15T06:36:30Z")

</div>

somebody can help me 😊

---

<div class="post-metadata">

**Author:** ![Neeraj](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/neeraj/32/3104_2.png) [@Neeraj](https://discuss.dgraph.io/u/Neeraj)\
**Post date:** [June 15, 2020, 6:38am UTC](https://discuss.dgraph.io/t/how-can-i-get-a-speical-node-with-its-all-accessible-nodes/7203/3 "2020-06-15T06:38:05Z")

</div>

Hey @luke,  
I’m working on it.

---

<div class="post-metadata">

**Author:** ![Neeraj](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/neeraj/32/3104_2.png) [@Neeraj](https://discuss.dgraph.io/u/Neeraj)\
**Post date:** [June 15, 2020, 8:03am UTC](https://discuss.dgraph.io/t/how-can-i-get-a-speical-node-with-its-all-accessible-nodes/7203/6 "2020-06-15T08:03:41Z")

</div>

You can run this to get two connected components. You can ignore the nodes with predicate `gtype` while processing the resulting nodes.

```auto
{
  node(func:eq(name, ["c","j"])) @recurse {
    uid
    guid_to{
    }
  }
}

```

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

---

<div class="post-metadata">

**Author:** ![luke](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/luke/32/10557_2.png) [@luke](https://discuss.dgraph.io/u/luke)\
**Post date:** [June 15, 2020, 8:16am UTC](https://discuss.dgraph.io/t/how-can-i-get-a-speical-node-with-its-all-accessible-nodes/7203/7 "2020-06-15T08:16:21Z")

</div>

you are cool! it helps me a lot.Thanks

---

<div class="post-metadata">

**Author:** ![ahsan](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/ahsan/32/3517_2.png) [@ahsan](https://discuss.dgraph.io/u/ahsan)\
**Post date:** [June 15, 2020, 11:06am UTC](https://discuss.dgraph.io/t/how-can-i-get-a-speical-node-with-its-all-accessible-nodes/7203/9 "2020-06-15T11:06:44Z")

</div>

Hey @luke,

This can be another approach where you can get rid of the nodes having `gtype` predicate by running the following query:

```auto
{
  node(func:eq(name, ["c", "j"])) @recurse {
    u as guid_to {
    }
  }
  
  test(func: uid(u)) @filter(NOT has(gtype)) {
    uid
    name
  }
}

```

But this will not have connected components because if we exclude some nodes then we break the component. If you want the result for “c”, you can query only for “c” and if you don’t want to distinguish the results then may be you can query for a list of nodes.

---

<div class="post-metadata">

**Author:** ![luke](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/luke/32/10557_2.png) [@luke](https://discuss.dgraph.io/u/luke)\
**Post date:** [June 15, 2020, 12:33pm UTC](https://discuss.dgraph.io/t/how-can-i-get-a-speical-node-with-its-all-accessible-nodes/7203/10 "2020-06-15T12:33:10Z")

</div>

Thanks @ahsan  
I take this approach to solve my problem  
when i want to distinguish a list like [“c”,“j”,“k”] i use **for** to make multiple queries

```auto
{
  node (func: eq(name,["c","j"])) @recurse {
     gt as t.guid_to
    uid
  }
  result (func: uid(gt)) @filter(NOT has(gtype)){
    uid
   name
  }
}

```
