@alneas/task-graph API Reference
@alneas/task-graph API Reference
Section titled “@alneas/task-graph API Reference”INTERFACE TaskNode
Section titled “INTERFACE TaskNode”Task Graph & Dependency Analysis Types
Common type definitions for DAG analysis, CPM calculation, and graph adapters.
interface TaskNodeINTERFACE TaskEdge
Section titled “INTERFACE TaskEdge”Dependency edge between tasks (predecessor -> successor).
interface TaskEdgeINTERFACE BlockerAnalysis
Section titled “INTERFACE BlockerAnalysis”Bottleneck / blocker analysis result for a task.
interface BlockerAnalysisINTERFACE CriticalPathResult
Section titled “INTERFACE CriticalPathResult”Critical Path Method (CPM) schedule analysis result.
interface CriticalPathResultINTERFACE DelayImpact
Section titled “INTERFACE DelayImpact”Delay simulation (What-If analysis) impact result.
interface DelayImpactINTERFACE TaskGraphAdapter
Section titled “INTERFACE TaskGraphAdapter”Abstract task graph adapter interface.
Defines the contract shared across database adapters (OCI ADB, PostgreSQL, Neo4j) and the in-memory reference implementation.
interface TaskGraphAdapterFUNCTION buildAdjacencyList
Section titled “FUNCTION buildAdjacencyList”Builds adjacency lists (successors and predecessors) from dependency edges.
export function buildAdjacencyList(edges: TaskEdge[]):Parameters
Section titled “Parameters”| Parameter | Type | Required | Description |
|---|---|---|---|
edges |
TaskEdge[] |
Yes |
Returns
Section titled “Returns”- Type:
{ successors: Map<string, Array<{ targetId: string; lag: number; }>>; predecessors: Map<string, Array<{ targetId: string; lag: number; }>>; }
FUNCTION detectCycles
Section titled “FUNCTION detectCycles”Detects whether circular references (cycles) exist in the dependency graph.
export function detectCycles(tasks: TaskNode[], edges: TaskEdge[]): string[][]Parameters
Section titled “Parameters”| Parameter | Type | Required | Description |
|---|---|---|---|
tasks |
TaskNode[] |
Yes | |
edges |
TaskEdge[] |
Yes |
Returns
Section titled “Returns”- Type:
string[][] - Description: An array of detected cycle paths, or an empty array if acyclic.
FUNCTION topologicalSort
Section titled “FUNCTION topologicalSort”Executes topological sort on the task graph using Kahn’s algorithm.
export function topologicalSort(tasks: TaskNode[], edges: TaskEdge[]): string[]Parameters
Section titled “Parameters”| Parameter | Type | Required | Description |
|---|---|---|---|
tasks |
TaskNode[] |
Yes | |
edges |
TaskEdge[] |
Yes |
Returns
Section titled “Returns”- Type:
string[]
FUNCTION calculateCriticalPath
Section titled “FUNCTION calculateCriticalPath”Schedules tasks and determines the critical path using the Critical Path Method (CPM).
export function calculateCriticalPath( tasks: TaskNode[], edges: TaskEdge[],): CriticalPathResultParameters
Section titled “Parameters”| Parameter | Type | Required | Description |
|---|---|---|---|
tasks |
TaskNode[] |
Yes | |
edges |
TaskEdge[] |
Yes |
Returns
Section titled “Returns”- Type:
CriticalPathResult
FUNCTION analyzeBlockers
Section titled “FUNCTION analyzeBlockers”Analyzes blockers across tasks (centrality ranking by number of blocked downstream tasks).
export function analyzeBlockers(tasks: TaskNode[], edges: TaskEdge[]): BlockerAnalysis[]Parameters
Section titled “Parameters”| Parameter | Type | Required | Description |
|---|---|---|---|
tasks |
TaskNode[] |
Yes | |
edges |
TaskEdge[] |
Yes |
Returns
Section titled “Returns”- Type:
BlockerAnalysis[]
FUNCTION simulateDelayImpact
Section titled “FUNCTION simulateDelayImpact”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,): DelayImpactParameters
Section titled “Parameters”| Parameter | Type | Required | Description |
|---|---|---|---|
tasks |
TaskNode[] |
Yes | |
edges |
TaskEdge[] |
Yes | |
sourceTaskId |
string |
Yes | |
delayHours |
number |
Yes |
Returns
Section titled “Returns”- Type:
DelayImpact