@rimbu/graph
Version:
Immutable Graph data structures for TypeScript
44 lines (43 loc) • 2.58 kB
text/typescript
import { TraverseState, type RelatedTo, type ToJSON } from '@rimbu/common';
import { Stream, type StreamSource } from '@rimbu/stream';
import { NonEmptyBase } from '@rimbu/collection-types/map-custom';
import type { GraphTypesContextImpl } from '@rimbu/graph/custom';
import type { GraphBase, GraphElement, Link, WithGraphValues } from '../../common/index.cjs';
export declare class GraphNonEmpty<N, Tp extends GraphTypesContextImpl, TpG extends WithGraphValues<Tp, N, any> = WithGraphValues<Tp, N, any>> extends NonEmptyBase<GraphElement<N>> implements GraphBase.NonEmpty<N, Tp> {
readonly isDirected: boolean;
readonly context: TpG['context'];
readonly linkMap: TpG['linkMapNonEmpty'];
readonly connectionSize: number;
_NonEmptyType: TpG['nonEmpty'];
constructor(isDirected: boolean, context: TpG['context'], linkMap: TpG['linkMapNonEmpty'], connectionSize: number);
copy(linkMap: TpG['linkMapNonEmpty'], connectionSize: number): TpG['nonEmpty'];
copyE(linkMap: TpG['linkMap'], connectionSize: number): TpG['normal'];
assumeNonEmpty(): any;
asNormal(): any;
forEach(f: (node: GraphElement<N>, index: number, halt: () => void) => void, options?: {
state?: TraverseState;
}): void;
stream(): Stream.NonEmpty<GraphElement<N>>;
get nodeSize(): number;
streamNodes(): Stream.NonEmpty<N>;
streamConnections(): Stream<WithGraphValues<Tp, N, any>['link']>;
hasNode<UN = N>(node: RelatedTo<N, UN>): boolean;
hasConnection<UN = N>(node1: RelatedTo<N, UN>, node2: RelatedTo<N, UN>): boolean;
getConnectionStreamFrom<UN = N>(node1: RelatedTo<N, UN>): Stream<Link<N>>;
getConnectionStreamTo<UN = N>(node: RelatedTo<N, UN>): any;
getConnectionsFrom<UN = N>(node1: RelatedTo<N, UN>): TpG['linkConnections'];
isSink<UN = N>(node: RelatedTo<N, UN>): boolean;
isSource<UN>(node: RelatedTo<N, UN>): boolean;
addNode(node: N): TpG['nonEmpty'];
addNodes(nodes: StreamSource<N>): TpG['nonEmpty'];
removeNode<UN = N>(node: RelatedTo<N, UN>): TpG['normal'];
removeNodes<UN>(nodes: StreamSource<RelatedTo<N, UN>>): TpG['normal'];
connect(node1: N, node2: N): TpG['nonEmpty'];
connectAll(links: StreamSource<WithGraphValues<Tp, N, any>['link']>): TpG['nonEmpty'];
disconnect<UN>(node1: RelatedTo<N, UN>, node2: RelatedTo<N, UN>): TpG['nonEmpty'];
disconnectAll<UN>(links: StreamSource<Link<RelatedTo<N, UN>>>): TpG['nonEmpty'];
removeUnconnectedNodes(): TpG['normal'];
toString(): string;
toJSON(): ToJSON<[N, [N][]][]>;
toBuilder(): TpG['builder'];
}