Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

x/rimbu/graph/custom/common/interface/variant-graph-base.ts>VariantGraphBase

Rimbu is a TypeScript library focused on immutable, performant, and type-safe collections and other tools.
Go to Latest
namespace VariantGraphBase
import { VariantGraphBase } from "https://deno.land/x/rimbu@1.0.3/graph/custom/common/interface/variant-graph-base.ts";

Interfaces

Utility interface that provides higher-kinded types for this collection.

interface VariantGraphBase
implements FastIterable<[N] | WithGraphValues<Tp, N, V>["link"]>
import { type VariantGraphBase } from "https://deno.land/x/rimbu@1.0.3/graph/custom/common/interface/variant-graph-base.ts";

Properties

readonly
isDirected: boolean

Returns true if the graph is an arrow (directed) graph.

readonly
isEmpty: boolean

Returns true if the graph has no nodes.

readonly
nodeSize: number

Returns the amount of nodes in the graph.

readonly
connectionSize: number

Returns the amount of connections in the graph.

Methods

nonEmpty(): this is WithGraphValues<Tp, N, V>["nonEmpty"]

Returns true if there is at least one node in the collection, and instructs the compiler to treat the collection as a .NonEmpty type.

assumeNonEmpty(): WithGraphValues<Tp, N, V>["nonEmpty"]

Returns the collection as a .NonEmpty type

stream(): Stream<[N] | WithGraphValues<Tp, N, V>["link"]>

Returns a Stream containing all graph elements of this collection as single tuples for isolated nodes and 2-valued tuples of nodes for connections.

streamNodes(): Stream<N>

Returns a Stream containing all nodes of this collection.

streamConnections(): Stream<WithGraphValues<Tp, N, V>["link"]>

Returns a Stream containing all connections of this collection.

hasNode<UN = N>(node: RelatedTo<N, UN>): boolean

Returns true if the graph contains the given node.

hasConnection<UN = N>(node1: RelatedTo<N, UN>, node2: RelatedTo<N, UN>): boolean

Returns true if the graph has a connection between given node1 and node2.

getConnectionStreamFrom<UN = N>(node1: RelatedTo<N, UN>): Stream<WithGraphValues<Tp, N, V>["link"]>

Returns a Stream containing all the connetions from the given node1

getConnectionStreamTo<UN = N>(node2: RelatedTo<N, UN>): Stream<WithGraphValues<Tp, N, V>["link"]>

Returns a Stream containing all the connetions to the given node2

removeNode<UN = N>(node: RelatedTo<N, UN>): WithGraphValues<Tp, N, V>["normal"]

Returns the graph with the given node and all its connections removed.

removeNodes<UN = N>(nodes: StreamSource<RelatedTo<N, UN>>): WithGraphValues<Tp, N, V>["normal"]

Returns the graph with all nodes in given nodes stream removed, together with all their connections.

disconnect<UN = N>(node1: RelatedTo<N, UN>, node2: RelatedTo<N, UN>): WithGraphValues<Tp, N, V>["normal"]

Returns the graph with the connection between given node1 and node2 removed if it exists.

disconnectAll<UN = N>(links: StreamSource<Link<RelatedTo<N, UN>>>): WithGraphValues<Tp, N, V>["normal"]

Returns the graph with all connections in given links removed if they exist.

removeUnconnectedNodes(): WithGraphValues<Tp, N, V>["normal"]

Returns the graph with all isolated nodes removed.

toString(): string

Returns a string representation of this collection.

toJSON(): ToJSON<[N, WithGraphValues<Tp, N, V>["linkTarget"][]][]>

Returns a JSON representation of this collection.