# Class DependencyGraph

Dependency graph for workflow steps.

- Defined in packages/nexus-agents/src/workflows/dependency-graph.ts:26

##### Index

### Constructors

constructor

### Methods

validateUniqueIds
addStep
buildReverseLinks
getStepIds
getNode
validateReferences
detectCycles
getExecutionOrder

## Constructors

### constructor

- new DependencyGraph(): DependencyGraph

  #### Returns DependencyGraph

## Methods

### `Static` validateUniqueIds

- validateUniqueIds(steps: WorkflowStep[]): Result<void, ParseError>

  Validates that all step IDs are unique.

  #### Parameters

  - steps: WorkflowStep[]

    Array of workflow steps

  #### Returns Result<void, ParseError>

  Result with void or ParseError for duplicates

  - Defined in packages/nexus-agents/src/workflows/dependency-graph.ts:100

### addStep

- addStep(step: WorkflowStep): void

  Adds a step to the graph.

  #### Parameters

  - step: WorkflowStep

    The workflow step to add

  #### Returns void

  - Defined in packages/nexus-agents/src/workflows/dependency-graph.ts:33

### buildReverseLinks

- buildReverseLinks(): void

  Builds the reverse dependency links (dependents).

  #### Returns void

  - Defined in packages/nexus-agents/src/workflows/dependency-graph.ts:45

### getStepIds

- getStepIds(): string[]

  Gets all step IDs in the graph.

  #### Returns string[]

  - Defined in packages/nexus-agents/src/workflows/dependency-graph.ts:59

### getNode

- getNode(id: string): GraphNode | undefined

  Gets a node by step ID.

  #### Parameters

  - id: string

  #### Returns GraphNode | undefined

  - Defined in packages/nexus-agents/src/workflows/dependency-graph.ts:66

### validateReferences

- validateReferences(): Result<void, ParseError>

  Validates that all dependency references exist.

  #### Returns Result<void, ParseError>

  Result with void or ParseError containing missing references

  - Defined in packages/nexus-agents/src/workflows/dependency-graph.ts:74

### detectCycles

- detectCycles(): Result<string[], ParseError>

  Detects circular dependencies using Kahn's algorithm.

  #### Returns Result<string[], ParseError>

  Result with topologically sorted step IDs or ParseError for cycles

  - Defined in packages/nexus-agents/src/workflows/dependency-graph.ts:157

### getExecutionOrder

- getExecutionOrder(): Result<string[], ParseError>

  Gets the execution order (topologically sorted step IDs).

  #### Returns Result<string[], ParseError>

  Result with sorted step IDs or ParseError

  - Defined in packages/nexus-agents/src/workflows/dependency-graph.ts:242