@rimbu/graph
Version:
Immutable Graph data structures for TypeScript
51 lines (50 loc) • 3.14 kB
text/typescript
import type { Token } from '@rimbu/base';
import { NonEmptyBase } from '@rimbu/collection-types/map-custom';
import { OptLazy, OptLazyOr, TraverseState, type RelatedTo, type ToJSON } from '@rimbu/common';
import { Stream, type StreamSource } from '@rimbu/stream';
import type { ValuedGraphBase, ValuedGraphTypesContextImpl } from '@rimbu/graph/custom';
import type { Link, ValuedGraphElement, ValuedLink, WithGraphValues } from '../../common/index.mjs';
export declare class ValuedGraphNonEmpty<N, V, Tp extends ValuedGraphTypesContextImpl, TpG extends WithGraphValues<Tp, N, V> = WithGraphValues<Tp, N, V>> extends NonEmptyBase<ValuedGraphElement<N, V>> implements ValuedGraphBase.NonEmpty<N, V, 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: (entry: ValuedGraphElement<N, V>, index: number, halt: () => void) => void, options?: {
state?: TraverseState;
}): void;
stream(): Stream.NonEmpty<ValuedGraphElement<N, V>>;
get nodeSize(): number;
streamNodes(): Stream.NonEmpty<N>;
streamConnections(): Stream<ValuedLink<N, V>>;
hasNode<UN = N>(node: RelatedTo<N, UN>): boolean;
hasConnection<UN = N>(node1: RelatedTo<N, UN>, node2: RelatedTo<N, UN>): boolean;
getValue<UN, O>(node1: RelatedTo<N, UN>, node2: RelatedTo<N, UN>, otherwise?: OptLazy<O>): V | O;
getConnectionStreamFrom<UN = N>(node1: RelatedTo<N, UN>): Stream<ValuedLink<N, V>>;
getConnectionStreamTo<UN = N>(node: RelatedTo<N, UN>): Stream<ValuedLink<N, V>>;
getConnectionsFrom<UN = N>(node1: RelatedTo<N, UN>): TpG['linkConnections'];
isSink<UN = N>(node: RelatedTo<N, UN>): boolean;
isSource<UN = N>(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, value: V): TpG['nonEmpty'];
connectAll(links: StreamSource<WithGraphValues<Tp, N, V>['link']>): TpG['nonEmpty'];
modifyAt(node1: N, node2: N, options: {
ifNew?: OptLazyOr<V, Token>;
ifExists?: ((value: V, remove: Token) => V | Token) | V;
}): TpG['nonEmpty'];
disconnect<UN = N>(node1: RelatedTo<N, UN>, node2: RelatedTo<N, UN>): TpG['nonEmpty'];
disconnectAll<UN = N>(links: StreamSource<Link<RelatedTo<N, UN>>>): TpG['nonEmpty'];
removeUnconnectedNodes(): TpG['normal'];
mapValues<V2>(mapFun: (value: V, node1: N, node2: N) => V2): WithGraphValues<Tp, N, V2>['nonEmpty'];
toString(): string;
toJSON(): ToJSON<[N, (readonly [N, V])[]][]>;
toBuilder(): TpG['builder'];
}