Construct production polynomials from the set of paths produced by 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}] Copy
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<string, Polynomial<number>> = pathsToPolynomials(paths, nativeNumberOps, { each: (edge: Edge) => edge.each, count: (vertex: string) => vertices.get(vertex), }) Copy
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<string, Polynomial<number>> = pathsToPolynomials(paths, nativeNumberOps, { each: (edge: Edge) => edge.each, count: (vertex: string) => vertices.get(vertex), })
You probably want customGraphToPolynomials instead, unless you need to inspect graph paths for some reason.
See also simpleGraphToPolynomials for something simpler, with more restrictions on your graph's format.
Generated using TypeDoc
Construct production polynomials from the set of paths produced by Graph.allIncomingPaths.
If your application has the following graph...
...here's how to get your polynomials:
You probably want customGraphToPolynomials instead, unless you need to inspect graph paths for some reason.
See also simpleGraphToPolynomials for something simpler, with more restrictions on your graph's format.