Noah's Pairwise Manifest

    @pipepack/graph
    TypeScript icon, indicating that this package has built-in type declarations

    0.1.0 • Public • Published

    graph

    Build Status Coverage Status Package Dependency Package DevDependency

    A graph data structure with pipepack related algorithm.

    Installing

    This library is distributed only via NPM.

    # npm
    npm install @pipepack/graph;
    # yarn
    yarn add @pipepack/graph;

    Then, use like below:

    // esm
    import { Graph } from '@pipepack/graph';
    // commonjs
    const { Graph } = require('@pipepack/graph');

    Serialization

    Serializes the graph with declaration below:

    type NodeID = string;
    type EdgeID = string;
    type EdgeWeight = string | number;
    
    interface GraphNode {
      id: NodeID;
    }
    
    interface GraphEdge {
      source: NodeID;
      target: NodeID;
      weight?: EdgeWeight;
    }
    
    interface Serialized {
      nodes: GraphNode[];
      edges: GraphEdge[];
    }
    const graph = new Graph();
    
    graph.addEdge('a', 'b');
    graph.addEdge('b', 'c');
    {
      "nodes": [{ "id": "a" }, { "id": "b" }, { "id": "c" }],
      "links": [
        { "source": "a", "target": "b", "weight": 1 },
        { "source": "b", "target": "c", "weight": 1 }
      ]
    }

    Licence

    MIT

    Install

    npm i @pipepack/graph

    DownloadsWeekly Downloads

    3

    Version

    0.1.0

    License

    ISC

    Unpacked Size

    19.3 kB

    Total Files

    14

    Last publish

    Collaborators

    • bornkiller