# Documentation: Matching closed paths/cycles

**URL:** https://discuss.dgraph.io/t/documentation-matching-closed-paths-cycles/8458
**Category:** Dgraph
**Tags:** area:documentation, dgraph
**Created:** [December 14, 2019, 4:10pm UTC](https://discuss.dgraph.io/t/documentation-matching-closed-paths-cycles/8458 "2019-12-14T16:10:11Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![diggy](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/diggy/32/3666_2.png) [@diggy](https://discuss.dgraph.io/u/diggy)
#### Post date: [December 14, 2019, 4:10pm UTC](https://discuss.dgraph.io/t/documentation-matching-closed-paths-cycles/8458/1 "2019-12-14T16:10:11Z")

</div>

**Moved from GitHub [dgraph/4417](https://github.com/dgraph-io/dgraph/issues/4417)**

_Posted by_ [imkleats](https://github.com/imkleats):

## Documentation

GraphQL+/- provides a very intuitive way to interface with a connected, acyclic graph (AKA trees). However, it isn’t apparent how to deal with cyclical patterns (matching any path that starts and ends on the same node). Additional documentation of how to match closed paths is warranted.

This issue comes from a post on the Discuss forum: [Problem about nodes filter according to an edge](http://discuss.hypermode.com/t/problem-about-nodes-filter-according-to-edge/5623)  
The question being posed is about how to query forum posts that fit in the following closed pattern:

```auto
match (f:Forum)-[hasMember {year > 4}]->(:Person)<-[hasCreator]-(p:Post)<-[containerOf]-(f)
return p

```

I’ve flagged this as a Documentation issue on the chance that Dgraph folks either know or can figure out a way to accomplish generalized cyclical pattern-matching using currently available methods. However, from my initial exploration, it is unclear whether the way UIDs are collected in var blocks even currently support modeling cyclical patterns; the following approach does not appear work:

```auto
eachGivenForum as var(type(forum)) @cascade {
  hasMember @facets(gt(year,4)) {
    matchingPosts as ~hasCreator {
      ~containerOf @filter(uid(eachGivenForum)) { # trying to filter to each indiv. Forum uid
        uid # this block is being evaluated for
      }
    }
  }
}

q(func: uid(matchingPosts)) { ... }

```

Being able to model and match cyclical patterns in a generalizable way is pretty important, so hopefully this can be resolved.
