/** * Graph Traversal Interfaces * * Types for traversal and pathfinding operations * Based on Ductape Graph API documentation (traversals.md, overview.md) */ import { TraversalDirection } from './enums'; import { INode, INodeFilter } from './node.interface'; import { IRelationship, IRelationshipFilter } from './relationship.interface'; /** * Path structure representing a sequence of nodes and relationships */ export interface IPath { /** Nodes in the path */ nodes: INode[]; /** Relationships connecting the nodes */ relationships: IRelationship[]; /** Path length (number of relationships) */ length: number; } /** * Options for graph traversal * As documented in traversals.md */ export interface ITraverseOptions { /** Starting node ID */ startNodeId: string | number; /** Traversal direction: OUTGOING, INCOMING, or BOTH */ direction?: TraversalDirection | 'OUTGOING' | 'INCOMING' | 'BOTH'; /** Relationship types to traverse */ relationshipTypes?: string[]; /** Maximum depth to traverse */ maxDepth?: number; /** Minimum depth to start from */ minDepth?: number; /** Filter for nodes in the traversal */ nodeFilter?: INodeFilter; /** Filter for relationships in the traversal */ relationshipFilter?: IRelationshipFilter; /** Maximum number of paths to return */ limit?: number; /** Session token inherited from a containing Feature execution. */ session?: string; } /** * Result of graph traversal * As documented in traversals.md */ export interface ITraverseResult { /** All discovered paths */ paths?: IPath[]; /** All discovered nodes */ nodes?: INode[]; /** All discovered relationships */ relationships?: IRelationship[]; /** Total count of paths */ count?: number; } /** * Options for shortest path finding * As documented in traversals.md */ export interface IShortestPathOptions { /** Starting node ID */ startNodeId: string | number; /** Target node ID */ endNodeId: string | number; /** Relationship types to consider */ relationshipTypes?: string[]; /** Property to use as weight (for weighted shortest path) */ weightProperty?: string; /** Maximum depth to search */ maxDepth?: number; /** Whether to respect relationship direction */ directed?: boolean; } /** * Result of shortest path finding * As documented in traversals.md */ export interface IShortestPathResult { /** The shortest path found (null if no path exists) */ path: IPath | null; /** Total weight (if using weighted path) */ totalWeight?: number; /** Path length (number of relationships) */ length?: number; /** Whether a path was found */ found?: boolean; } /** * Options for finding all paths * As documented in traversals.md */ export interface IAllPathsOptions { /** Starting node ID */ startNodeId: string | number; /** Target node ID */ endNodeId: string | number; /** Relationship types to consider */ relationshipTypes?: string[]; /** Minimum path depth */ minDepth?: number; /** Maximum path depth */ maxDepth?: number; /** Maximum number of paths to return */ limit?: number; /** Maximum number of paths to return (alias for limit) */ maxPaths?: number; /** Whether to respect relationship direction */ directed?: boolean; } /** * Result of finding all paths * As documented in traversals.md */ export interface IAllPathsResult { /** All paths found */ paths: IPath[]; /** Total count of paths */ count?: number; /** Total count of paths (alias for count) */ total?: number; } /** * Options for getting neighborhood * As documented in traversals.md */ export interface INeighborhoodOptions { /** Starting node ID */ nodeId: string | number; /** Depth of neighborhood to explore */ depth?: number; /** Traversal direction */ direction?: TraversalDirection | 'OUTGOING' | 'INCOMING' | 'BOTH'; /** Relationship types to consider */ relationshipTypes?: string[]; /** Filter for nodes */ nodeFilter?: INodeFilter; /** Maximum number of results */ limit?: number; } /** * Result of neighborhood exploration * As documented in traversals.md */ export interface INeighborhoodResult { /** All nodes in the neighborhood */ nodes: INode[]; /** All relationships in the neighborhood */ relationships: IRelationship[]; /** Depth of exploration */ depth?: number; } /** * Options for finding connected components * As documented in traversals.md */ export interface IConnectedComponentsOptions { /** Relationship types to consider */ relationshipTypes?: string[]; /** Node labels to filter by */ labels?: string[]; } /** * Connected component structure */ export interface IConnectedComponent { /** Nodes in the component */ nodes: INode[]; /** Component size */ size: number; } /** * Result of finding connected components * As documented in traversals.md */ export interface IConnectedComponentsResult { /** All connected components */ components: IConnectedComponent[]; /** Total number of components */ count: number; }