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

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

Walks depth first from one vertex.

**Signature:**

```typescript
walk(vertex: T, callback?: GraphForeachCallback<T>, visited?: Map<T, boolean>): Graph<T>;
```

## Parameters


| Parameter | Type | Description |
| --- | --- | --- |
| vertex | T | Vertex to start from. |
| callback | [GraphForeachCallback](https://imqueue.org/api/pg-sequelize/latest/pg-sequelize.graphforeachcallback/)<T> | _(Optional)_ Called once per vertex reached; returning `false` prunes. |
| visited | Map<T, boolean> | _(Optional)_ Vertices already reached. A fresh map by default. |


**Returns:**

[Graph](https://imqueue.org/api/pg-sequelize/latest/pg-sequelize.graph/)<T>

This graph, for chaining.

## Remarks

Follows edges as far as they go, marking each vertex as it arrives and never arriving twice, which is what makes it safe on a cyclic graph. Passing a visited map of your own both continues an earlier walk and lets you exclude vertices by marking them before starting.

