UNPKG

graph-builder

Version:

A graph builder library for modeling abstract graph structures.

42 lines (41 loc) 1.78 kB
import { BaseGraph } from "./BaseGraph"; import { ElementOrder } from "./ElementOrder"; import { EndpointPair } from "./EndpointPair"; /** * This class provides a skeletal implementation of {@link BaseGraph}. * * <p>The methods implemented in this class should not be overridden unless the subclass admits a * more efficient implementation. */ export declare abstract class AbstractBaseGraph<N> implements BaseGraph<N> { abstract nodes(): Set<N>; abstract isDirected(): boolean; abstract allowsSelfLoops(): boolean; abstract nodeOrder(): ElementOrder<N>; abstract adjacentNodes(node: N): Set<N>; abstract predecessors(node: N): Set<N>; abstract successors(node: N): Set<N>; /** * Returns the number of edges in this graph; used to calculate the size of {@link edges}. This * implementation requires O(|N|) time. Classes extending this one may manually keep track of the * number of edges as the graph is updated, and override this method for better performance. */ protected edgeCount(): number; /** * An implementation of {@link BaseGraph.edges} defined in terms of {@link nodes} and {@link * successors(Object)}. */ edges(): Set<EndpointPair<N>>; incidentEdges(node: N): Set<EndpointPair<N>>; degree(node: N): number; inDegree(node: N): number; outDegree(node: N): number; hasEdge(nodeU: N, nodeV: N): boolean; hasEdgeConnectingEndpoints(endpoints: EndpointPair<N>): boolean; /** * Throws `IllegalArgumentException` if the ordering of `endpoints` is not compatible * with the directionality of this graph. */ protected validateEndpoints(endpoints: EndpointPair<any>): void; protected isOrderingCompatible(endpoints: EndpointPair<N>): boolean; }