import { Stream, type StreamSource } from '@rimbu/stream'; import { EmptyBase } from '@rimbu/collection-types/map-custom'; import type { VariantGraphBase } from '../index.mjs'; export interface GraphValues { readonly _N: N; readonly _V: V; } export type WithGraphValues = GraphValues & Tp; export interface GraphConnect extends VariantGraphBase { /** * Returns the graph with the given `node` added, if it was not yet present. * @param node - the node to add * @example * ```ts * const g = ArrowGraphHashed.of([1], [2, 3]) * g.addNode(4).stream().toArray() // => [[1], [2, 3], [4]] * g.addNode(1).stream().toArray() // ==> [[1], [2, 3]] * ``` */ addNode(node: N): WithGraphValues['nonEmpty']; /** * Returns the graph with the nodes from the given `nodes` `StreamSource` added. * @param nodes - a `StreamSource` containing the nodes to add * @example * ```ts * const g = ArrowGraphHashed.of([1], [2, 3]) * g.addNodes([4, 1]).stream().toArray() // => [[1], [2, 3], [4]] * g.addNodes([1, 2]).stream().toArray() // => [[1], [2, 3]] * ``` */ addNodes(nodes: StreamSource.NonEmpty): WithGraphValues['nonEmpty']; addNodes(nodes: StreamSource): WithGraphValues['normal']; /** * Returns the graph with the connections from the given `connections` `StreamSource` added. * @param connections - a `StreamSource` conntaining tuple representing the connections to add * @example * ```ts * const g = ArrowGraphHashed.of([1], [2, 3]) * g.connectAll([[1, 2], [3, 1]]).stream().toArray() // => [[1, 2], [2, 3], [3, 1]] * const g2 = ArrowValuedGraphHashed.of([1], [2, 3, 'a']) * g2.connectAll([[1, 2, 'b'], [2, 3, 'c']]).stream().toArray() * // => [[1, 2, 'b'], [2, 3, 'c']] * ``` */ connectAll(connections: StreamSource.NonEmpty['link']>): WithGraphValues['nonEmpty']; connectAll(connections: StreamSource['link']>): WithGraphValues['normal']; } export interface GraphConnectNonEmpty extends GraphConnect { /** * Returns the non-empty graph with the nodes from the given `nodes` `StreamSource` added. * @param nodes - a `StreamSource` containing the nodes to add * @example * ```ts * const g = ArrowGraphHashed.of([1], [2, 3]) * g.addNodes([4, 1]).stream().toArray() // => [[1], [2, 3], [4]] * g.addNodes([1, 2]).stream().toArray() // => [[1], [2, 3]] * ``` */ addNodes(nodes: StreamSource): WithGraphValues['nonEmpty']; /** * Returns the non-empty graph with the connections from the given `connections` `StreamSource` added. * @param connections - a `StreamSource` conntaining tuple representing the connections to add * @example * ```ts * const g = ArrowGraphHashed.of([1], [2, 3]) * g.connectAll([[1, 2], [3, 1]]).stream().toArray() // => [[1, 2], [2, 3], [3, 1]] * const g2 = ArrowValuedGraphHashed.of([1], [2, 3, 'a']) * g2.connectAll([[1, 2, 'b'], [2, 3, 'c']]).stream().toArray() * // => [[1, 2, 'b'], [2, 3, 'c']] * ``` */ connectAll(links: StreamSource['link']>): WithGraphValues['nonEmpty']; } export declare abstract class GraphEmptyBase extends EmptyBase { get nodeSize(): 0; get connectionSize(): 0; streamNodes(): Stream; streamConnections(): Stream; hasNode(): false; hasConnection(): false; isSink(): false; isSource(): false; removeNode(): any; removeNodes(): any; getConnectionStreamFrom(): Stream; getConnectionStreamTo(): Stream; disconnect(): any; disconnectAll(): any; removeUnconnectedNodes(): any; }