# Graph.forEach() method · @imqueue/pg-sequelize

Source: https://imqueue.org/api/pg-sequelize/latest/pg-sequelize.graph.foreach/
Published: 2026-08-01
Author: @imqueue maintainers (https://github.com/imqueue)
Package: @imqueue/pg-sequelize 4.2.0 — generated reference, not hand-written

Visits every vertex once, depth first.

**Signature:**

```typescript
forEach(callback: GraphForeachCallback<T>): Graph<T>;
```

## Parameters


| Parameter | Type | Description |
| --- | --- | --- |
| callback | [GraphForeachCallback](https://imqueue.org/api/pg-sequelize/latest/pg-sequelize.graphforeachcallback/)<T> | Called once per vertex. |


**Returns:**

[Graph](https://imqueue.org/api/pg-sequelize/latest/pg-sequelize.graph/)<T>

This graph, for chaining.

## Remarks

Walks from each vertex in turn, sharing one visited set across all of them — so the callback sees each vertex exactly once no matter how many paths reach it, and a disconnected part of the graph is covered too. A callback returning `false` prunes that branch; the traversal moves on to the next vertex rather than stopping.

