Strata - v1.4.10
    Preparing search index...

    Interface NGraph<NodeData, LinkData>

    A graph data structure

    interface NGraph<NodeData = any, LinkData = any> {
        addLink: (from: NodeId, to: NodeId, data?: LinkData) => NLink<LinkData>;
        addNode: (node: NodeId, data?: NodeData) => NNode<NodeData>;
        beginUpdate: () => void;
        clear: () => void;
        endUpdate: () => void;
        forEachLink: (
            callbackPerLink: (link: NLink<LinkData>) => boolean | void | undefined,
        ) => void;
        forEachLinkedNode: (
            nodeId: NodeId,
            callbackPerNode: (
                otherNode: NNode<NodeData>,
                link: NLink<LinkData>,
            ) => void,
            oriented?: boolean,
        ) => void;
        forEachNode: (
            callbackPerNode: (
                node: NNode<NodeData>,
            ) => boolean | void | null | undefined,
        ) => void;
        getEdgeCount: () => number;
        getLink: (
            fromNodeId: NodeId,
            toNodeId: NodeId,
        ) => NLink<LinkData> | undefined;
        getLinkById: (linkId: string) => NLink<LinkData> | undefined;
        getLinkCount: () => number;
        getLinks: (nodeId: NodeId) => Set<NLink<LinkData>> | null;
        getLinksCount: () => number;
        getNode: (nodeId: NodeId) => NNode<NodeData> | undefined;
        getNodeCount: () => number;
        getNodesCount: () => number;
        hasLink: (
            fromNodeId: NodeId,
            toNodeId: NodeId,
        ) => NLink<LinkData> | undefined;
        hasNode: (nodeId: NodeId) => NNode<NodeData> | undefined;
        removeLink: (link: NLink<LinkData>) => boolean;
        removeNode: (nodeId: NodeId) => boolean;
        version: number;
    }

    Type Parameters

    • NodeData = any
    • LinkData = any
    Index

    Properties

    addLink: (from: NodeId, to: NodeId, data?: LinkData) => NLink<LinkData>

    Adds a new link to the graph. If link already exists and the graph is not a multigraph, then link's data is overwritten with a new data.

    When graph is a multigraph, then a new link is always added between the nodes.

    addNode: (node: NodeId, data?: NodeData) => NNode<NodeData>

    Adds a new node to the graph. If node with such id already exists its data is overwritten with the new data

    beginUpdate: () => void

    Suspend all notifications about graph changes until endUpdate is called.

    clear: () => void

    Removes all nodes and links from the graph.

    endUpdate: () => void

    Resumes all notifications about graph changes and fires graph 'changed' event in case there are any pending changes.

    forEachLink: (
        callbackPerLink: (link: NLink<LinkData>) => boolean | void | undefined,
    ) => void

    Iterates over every single link in the graph, passing the link to a callback. If callback function returns "true"-like value, enumeration stops.

    forEachLinkedNode: (
        nodeId: NodeId,
        callbackPerNode: (
            otherNode: NNode<NodeData>,
            link: NLink<LinkData>,
        ) => void,
        oriented?: boolean,
    ) => void

    Iterates over other node connected to the nodeId. If oriented is set to true, the callback will receive nodes on the link.toId end. Otherwise callback will receive nodes on either .fromId or .toId, depending on the nodeId argument.

    forEachNode: (
        callbackPerNode: (
            node: NNode<NodeData>,
        ) => boolean | void | null | undefined,
    ) => void

    Iterates over every single node in the graph, passing the node to a callback.

    If callback function returns "true"-like value, enumeration stops.

    getEdgeCount: () => number

    Synonym of getLinkCount()

    getLink: (fromNodeId: NodeId, toNodeId: NodeId) => NLink<LinkData> | undefined

    Returns a link between two nodes

    getLinkById: (linkId: string) => NLink<LinkData> | undefined

    Returns a link by its id

    getLinkCount: () => number

    Returns number of links (edges) in the graph

    getLinks: (nodeId: NodeId) => Set<NLink<LinkData>> | null

    Returns all links associated with this node

    getLinksCount: () => number

    Returns number of links (edges) in the graph

    getNode: (nodeId: NodeId) => NNode<NodeData> | undefined

    Returns a node by its identifier. Undefined value is returned if node with such identifer does not exist.

    getNodeCount: () => number

    Returns number of nodes in the graph

    getNodesCount: () => number

    Returns number of nodes in the graph

    hasLink: (fromNodeId: NodeId, toNodeId: NodeId) => NLink<LinkData> | undefined

    Checks if link is present in the graph

    hasNode: (nodeId: NodeId) => NNode<NodeData> | undefined

    Checks whether given node exists in the graph. Return the node or undefined if no such node exist.

    removeLink: (link: NLink<LinkData>) => boolean

    Removes a link from the graph. You'll need to pass an actual link instance to remove it. If you pass two arguments, the function assumes they represent from/to node ids, and removes the corresponding link.

    Returns true if link is found and removed. False otherwise.

    removeNode: (nodeId: NodeId) => boolean

    Removes node by node id. Returns true if node was removed, false otherwise (e.g. no such node exists in the graph)

    version: number

    Internal version of the library surfaced for duck-typing hints.