UNPKG

@snyk/dep-graph

Version:

Snyk dependency graph library

69 lines (68 loc) 2.27 kB
export interface GraphOptions { directed?: boolean; multigraph?: boolean; compound?: boolean; } type NodeId = string; type EdgeId = string; export interface Edge { v: NodeId; w: NodeId; /** The name that uniquely identifies a multi-edge. */ name?: string; } /** Map counting edges from the current node to neighbouring nodes */ type AdjacencyCounts = Record<NodeId, number>; export declare class Graph { _isDirected: any; _isMultigraph: any; _isCompound: any; _label: any; _defaultNodeLabelFn: any; _defaultEdgeLabelFn: any; _nodes: Record<NodeId, unknown>; _parent: any; _children: any; _preds: Record<NodeId, AdjacencyCounts>; _sucs: Record<NodeId, AdjacencyCounts>; _edgeObjs: Record<EdgeId, Edge>; _edgeLabels: Record<EdgeId, unknown>; constructor(opts: GraphOptions); isDirected(): boolean; isMultigraph(): boolean; isCompound(): boolean; setGraph(label: any): this; graph(): any; setDefaultNodeLabel(newDefault: any): this; nodeCount(): number; nodes(): string[]; sources(): NodeId[]; sinks(): NodeId[]; setNodes(vs: NodeId[], value?: unknown): Graph; setNode(v: NodeId, value?: unknown): Graph; node(v: NodeId): unknown; hasNode(v: string): boolean; removeNode(v: NodeId): Graph; setParent(v: any, parent?: any): this; _removeFromParentsChildList(v: any): void; parent(v: any): any; children(v: any): string[] | undefined; predecessors(v: NodeId): NodeId[]; successors(v: NodeId): NodeId[]; neighbors(v: NodeId): NodeId[]; isLeaf(v: NodeId): boolean; filterNodes(filter: (v: NodeId) => boolean): Graph; setDefaultEdgeLabel(newDefault: any): this; edgeCount(): number; edges(): Edge[]; setPath(vs: any, value: any): this; setEdge(v: string, w: string, label?: any, name?: string): Graph; setEdge(edge: Edge, label?: any): Graph; edge(v: NodeId, w?: NodeId, name?: string): unknown; hasEdge(v: NodeId, w: NodeId, name?: string): boolean; removeEdge(v: Edge | NodeId, w?: NodeId, name?: string): Graph; inEdges(v: NodeId, u?: NodeId): Edge[]; outEdges(v: NodeId, w?: NodeId): Edge[]; nodeEdges(v: NodeId, w?: NodeId): Edge[]; } export {};