import type { RMap } from '@rimbu/collection-types'; import type { Stream, Streamable } from '@rimbu/stream'; import type { ArrowValuedGraphCreators, ValuedGraphElement, } from '@rimbu/graph/custom'; import { type ArrowValuedGraphBase, ValuedGraphContext, } from '@rimbu/graph/custom'; /** * A type-invariant immutable valued arrow (directed) graph. * See the [Graph documentation](https://rimbu.org/docs/collections/graph) and the [ArrowValuedGraph API documentation](https://rimbu.org/api/rimbu/graph/ArrowValuedGraph/interface) * @typeparam N - the node type * @typeparam V - the connection value type */ export interface ArrowValuedGraph extends ArrowValuedGraphBase {} export namespace ArrowValuedGraph { /** * A non-empty type-invariant immutable valued arrow (directed) graph. * See the [Graph documentation](https://rimbu.org/docs/collections/graph) and the [ArrowValuedGraph API documentation](https://rimbu.org/api/rimbu/graph/ArrowValuedGraph/interface) * @typeparam N - the node type * @typeparam V - the connection value type */ export interface NonEmpty extends ArrowValuedGraphBase.NonEmpty, Omit< ArrowValuedGraph, keyof ArrowValuedGraphBase.NonEmpty >, Streamable.NonEmpty> { /** * Returns a non-empty `Stream` containing all graph elements of this collection as single tuples for isolated nodes * and 3-valued tuples containing the source node, target node, and connection value for connections. * @example * ```ts * ArrowValuedGraphHashed.of([1, 2, 'a'], [2, 3, 'b']).stream().toArray() * // => [[1, 2, 'a'], [2, 3, 'b']] * ``` */ stream(): Stream.NonEmpty>; } /** * A mutable `ArrowValuedGraph` builder used to efficiently create new immutable instances. * See the [Graph documentation](https://rimbu.org/docs/collections/graph) and the [ArrowValuedGraph.Builder API documentation](https://rimbu.org/api/rimbu/graph/ArrowValuedGraph/Builder/interface) * @typeparam N - the node type * @typeparam V - the connection value type */ export interface Builder extends ArrowValuedGraphBase.Builder {} /** * The ArrowValuedGraph's Context instance that serves as a factory for all related immutable instances and builders. * @typeparam UN - the upper type limit for node types for which this context can create instances */ export interface Context extends ArrowValuedGraphBase.Context {} /** * Utility interface that provides higher-kinded types for this collection. */ export interface Types extends ArrowValuedGraphBase.Types { readonly normal: ArrowValuedGraph; readonly nonEmpty: ArrowValuedGraph.NonEmpty; readonly context: ArrowValuedGraph.Context; readonly builder: ArrowValuedGraph.Builder; } } export const ArrowValuedGraph: ArrowValuedGraphCreators = Object.freeze({ createContext(options: { linkMapContext: RMap.Context; linkConnectionsContext: RMap.Context; }): ArrowValuedGraph.Context { return Object.freeze( new ValuedGraphContext( true, 'ArrowValuedGraph', options.linkMapContext, options.linkConnectionsContext ) ); }, });