import { NumberOps } from "./number-ops"; import * as G from "./graph"; import { Polynomial } from "./polynomial"; /** * This pair of functions describes how to turn your graph's vertices and edges into production numbers. * * 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 what you pass to production functions: * * const getters: GetPoly = { * each: (edge: Edge) => edge.each, * count: (vertex: string) => vertices.get(vertex), * } * * Production graphs can be any shape you like, any format you like, as long as your `GetPoly` functions correctly describe * how to count each node and how much each edge produces. */ export interface GetPoly { /** * How many children does each parent produce per second? */ each: (edge: E) => D; /** * How many of this thing exist at t=0? `null` or `undefined` if no such vertex exists. */ count: (vertex: V) => D | null | undefined; } /** * The simplest way to 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: * * const polynomials: ReadonlyMap> * = simpleGraphToPolynomials(vertices, edges) * * If you need a more flexible graph format, see also {@link customGraphToPolynomials}. */ export declare function simpleGraphToPolynomials(vertices: ReadonlyMap, edges: readonly E[]): ReadonlyMap>; export declare function simpleGraphToPolynomials(vertices: ReadonlyMap, edges: readonly E[], ops: NumberOps): ReadonlyMap>; /** * 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> * = customGraphToPolynomials(vertices, edges, { * ops: nativeNumberOps, * each: (edge: Edge) => edge.each, * count: (vertex: string) => vertices.get(vertex), * }) * * See also {@link graphPathsToPolynomials} for another way to construct these polynomials. * * See also {@link simpleGraphToPolynomials} for something simpler, with more restrictions on your graph's format. */ export declare function customGraphToPolynomials(verts: readonly V[], edges: readonly E[], ops: NumberOps, fn: GetPoly & G.GetEdge): ReadonlyMap>; export declare function customGraphToPolynomials(verts: readonly V[], edges: readonly E[], ops: NumberOps, fn: GetPoly): ReadonlyMap>; /** * Construct production polynomials from the set of paths produced by {@link Graph.allIncomingPaths}. * * If your application has the following graph... * * type Edge = {parent: string, child: string, each: number} * const vertices = new Map([['drone', 3], ['meat', 2]]) * const edges: readonly Edge[] = [{parent: 'drone', child: 'meat', each: 5}] * * ...here's how to get your polynomials: * * import {nativeNumberOps, Graph} from "@erosson/polynomial" * const paths = Graph.allIncomingPaths(edges, Array.from(vertices.keys()), { * from: (edge: Edge) => edge.parent, * to: (edge: Edge) => edge.child, * }) * const polynomials: ReadonlyMap> * = pathsToPolynomials(paths, nativeNumberOps, { * each: (edge: Edge) => edge.each, * count: (vertex: string) => vertices.get(vertex), * }) * * You probably want {@link customGraphToPolynomials} instead, unless you need to inspect graph paths for some reason. * * See also {@link simpleGraphToPolynomials} for something simpler, with more restrictions on your graph's format. */ export declare function graphPathsToPolynomials(paths: ReadonlyMap[]>, ops: NumberOps, fn: GetPoly): ReadonlyMap>;