# DFS, BFS and triangle count DQL queries

**URL:** <https://discuss.dgraph.io/t/dfs-bfs-and-triangle-count-dql-queries/19456>\
**Category:** Dgraph\
**Tags:** dql\
**Created:** [July 23, 2024, 3:19pm UTC](https://discuss.dgraph.io/t/dfs-bfs-and-triangle-count-dql-queries/19456 "2024-07-23T15:19:32Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![affeeal](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/affeeal/32/11662_2.png) [@affeeal](https://discuss.dgraph.io/u/affeeal)\
**Post date:** [July 23, 2024, 3:19pm UTC](https://discuss.dgraph.io/t/dfs-bfs-and-triangle-count-dql-queries/19456/1 "2024-07-23T15:19:32Z")

</div>

Hi! I am researching Dgraph as part of my work on evaluating the performance of graph databases. In particular, I need to run the following queries:

1. Traversing DFS and BFS with a selection of vertices at a given depth.
2. Counting all triangles in the graph without taking into account orientation.

I have studied the DQL documentation, but have not found the means to fully execute these queries. Do I understand correctly that the closest thing to performing BFS is recursive queries, and it is impossible to perform DFS and triangle counting in Dgraph?

---

<div class="post-metadata">

**Author:** ![matthewmcneely](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/matthewmcneely/32/4774_2.png) [@matthewmcneely](https://discuss.dgraph.io/u/matthewmcneely)\
**Post date:** [July 23, 2024, 4:23pm UTC](https://discuss.dgraph.io/t/dfs-bfs-and-triangle-count-dql-queries/19456/2 "2024-07-23T16:23:41Z")

</div>

Hi @affeeal,

Dgraph only has a few native graph functions (Dijkstra’s, recursive). I faced a similar challenge a while back and ended up using Python’s networkx package to perform graph analysis on a Dgraph cluster; notebook here: [vlg/notebook/graph-analysis-and-visualization/workshop.ipynb at matthewmcneely/jupyter-notebook · dgraph-io/vlg · GitHub](https://github.com/dgraph-io/vlg/blob/matthewmcneely/jupyter-notebook/notebook/graph-analysis-and-visualization/workshop.ipynb)
