Skip to content

@alneas/task-graph API Reference

Task Graph & Dependency Analysis Types

Common type definitions for DAG analysis, CPM calculation, and graph adapters.

interface TaskNode

Dependency edge between tasks (predecessor -> successor).

interface TaskEdge

Bottleneck / blocker analysis result for a task.

interface BlockerAnalysis

Critical Path Method (CPM) schedule analysis result.

interface CriticalPathResult

Delay simulation (What-If analysis) impact result.

interface DelayImpact

Abstract task graph adapter interface.

Defines the contract shared across database adapters (OCI ADB, PostgreSQL, Neo4j) and the in-memory reference implementation.

interface TaskGraphAdapter

Builds adjacency lists (successors and predecessors) from dependency edges.

export function buildAdjacencyList(edges: TaskEdge[]):
Parameter Type Required Description
edges TaskEdge[] Yes
  • Type: { successors: Map<string, Array<{ targetId: string; lag: number; }>>; predecessors: Map<string, Array<{ targetId: string; lag: number; }>>; }

Detects whether circular references (cycles) exist in the dependency graph.

export function detectCycles(tasks: TaskNode[], edges: TaskEdge[]): string[][]
Parameter Type Required Description
tasks TaskNode[] Yes
edges TaskEdge[] Yes
  • Type: string[][]
  • Description: An array of detected cycle paths, or an empty array if acyclic.

Executes topological sort on the task graph using Kahn’s algorithm.

export function topologicalSort(tasks: TaskNode[], edges: TaskEdge[]): string[]
Parameter Type Required Description
tasks TaskNode[] Yes
edges TaskEdge[] Yes
  • Type: string[]

Schedules tasks and determines the critical path using the Critical Path Method (CPM).

export function calculateCriticalPath(
tasks: TaskNode[],
edges: TaskEdge[],
): CriticalPathResult
Parameter Type Required Description
tasks TaskNode[] Yes
edges TaskEdge[] Yes
  • Type: CriticalPathResult

Analyzes blockers across tasks (centrality ranking by number of blocked downstream tasks).

export function analyzeBlockers(tasks: TaskNode[], edges: TaskEdge[]): BlockerAnalysis[]
Parameter Type Required Description
tasks TaskNode[] Yes
edges TaskEdge[] Yes
  • Type: BlockerAnalysis[]

Simulates the project-wide ripple effect of delaying a specific task (What-If analysis).

export function simulateDelayImpact(
tasks: TaskNode[],
edges: TaskEdge[],
sourceTaskId: string,
delayHours: number,
): DelayImpact
Parameter Type Required Description
tasks TaskNode[] Yes
edges TaskEdge[] Yes
sourceTaskId string Yes
delayHours number Yes
  • Type: DelayImpact