• Construct production polynomials from a graph of your unit production.

    If your application has the following graph...

    type Edge = {from: string, to: string, each: number}
    const vertices = new Map([['drone', 3], ['meat', 2]])
    const edges: readonly Edge[] = [{from: 'drone', to: 'meat', each: 5}]

    ...here's how to get your polynomials:

    import {nativeNumberOps} from "@erosson/polynomial"
    const polynomials: ReadonlyMap<string, Polynomial<number>>
    = customGraphToPolynomials(vertices, edges, {
    ops: nativeNumberOps,
    each: (edge: Edge) => edge.each,
    count: (vertex: string) => vertices.get(vertex),
    })

    See also graphPathsToPolynomials for another way to construct these polynomials.

    See also simpleGraphToPolynomials for something simpler, with more restrictions on your graph's format.

    Type Parameters

    • V

    • E

    • D

    Parameters

    Returns ReadonlyMap<V, Polynomial<D>>

  • Type Parameters

    • V

    • E extends {
          from: V;
          to: V;
      }

    • D

    Parameters

    Returns ReadonlyMap<V, Polynomial<D>>

Generated using TypeDoc