# \[Algo] Cycle in Graph (directed)

<figure><img src="https://3743232000-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FHW2IQuh2PFpWJDvBz2FF%2Fuploads%2Fgit-blob-722f9fb8c398b0fb478a9eb95e767ff99a835b1c%2FScreenshot%202023-06-05%20at%2013.53.30.png?alt=media" alt=""><figcaption></figcaption></figure>

```javascript
const edges = [
  [1, 3],
  [2, 3, 4],
  [0],
  [],
  [2, 5],
  []
];

// true

function cycleInGraph(edges) {
  return true;
}
```

[Reference](https://algorithm.prettylog.com/overview/2.-data-structures/graph/detect-a-cycle-in-a-graph)
