@mark1russell7/highways 0.4.2 → 0.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (78) hide show
  1. package/README.md +59 -2
  2. package/build/index.d.ts +2333 -193
  3. package/build/index.d.ts.map +1 -1
  4. package/build/index.js +13042 -2334
  5. package/build/index.js.map +1 -1
  6. package/package.json +12 -1
  7. package/src/bench/exact/index.ts +258 -0
  8. package/src/bench/exact/optima-exact-v1-bounds.json +14409 -0
  9. package/src/bench/exact/optima-exact-v1.json +4809 -0
  10. package/src/bench/exact/solve.ts +129 -0
  11. package/src/bench/measures/index.ts +1 -0
  12. package/src/bench/measures/lanes.ts +304 -0
  13. package/src/bench/measures/levels.ts +86 -2
  14. package/src/bench/screen/activation.ts +3 -0
  15. package/src/bench/screen/bounds.ts +140 -0
  16. package/src/bench/screen/compare.ts +26 -0
  17. package/src/bench/screen/exact-set.ts +100 -0
  18. package/src/bench/screen/exercise.ts +290 -0
  19. package/src/bench/screen/forms.ts +25 -5
  20. package/src/bench/screen/gap.ts +316 -0
  21. package/src/bench/screen/hash.ts +7 -76
  22. package/src/bench/screen/index.ts +6 -0
  23. package/src/bench/screen/measures.ts +89 -1
  24. package/src/bench/screen/portfolio-pick.ts +20 -0
  25. package/src/bench/screen/screen.ts +78 -2
  26. package/src/bench/screen/set.ts +3 -2
  27. package/src/channels.ts +56 -0
  28. package/src/highways/areas/index.ts +160 -0
  29. package/src/highways/confluent/index.ts +154 -0
  30. package/src/highways/confluent/k23.test-util.ts +8 -0
  31. package/src/highways/consensus/index.ts +129 -0
  32. package/src/highways/crossbars/index.ts +184 -0
  33. package/src/highways/cubu/index.ts +26 -0
  34. package/src/highways/diffusion/index.ts +103 -0
  35. package/src/highways/divided/index.ts +111 -0
  36. package/src/highways/edge-paths/index.ts +155 -0
  37. package/src/highways/fdeb/index.ts +193 -0
  38. package/src/highways/fixtures.test-util.ts +71 -0
  39. package/src/highways/flow-clusters/index.ts +143 -0
  40. package/src/highways/frechet/index.ts +232 -0
  41. package/src/highways/growth/index.ts +148 -0
  42. package/src/highways/hdbscan/index.ts +250 -0
  43. package/src/highways/hierarchy/index.ts +140 -0
  44. package/src/highways/hough/index.ts +182 -0
  45. package/src/highways/hub-arcs/index.ts +181 -0
  46. package/src/highways/index.ts +79 -0
  47. package/src/highways/kdeeb/index.ts +355 -0
  48. package/src/highways/lanes/index.ts +189 -0
  49. package/src/highways/link-communities/index.ts +189 -0
  50. package/src/highways/mesh/index.ts +209 -0
  51. package/src/highways/mingle/index.ts +171 -0
  52. package/src/highways/mlseb/index.ts +204 -0
  53. package/src/highways/nested/index.ts +143 -0
  54. package/src/highways/p-hub/index.ts +248 -0
  55. package/src/highways/power/index.ts +117 -0
  56. package/src/highways/resistance/index.ts +159 -0
  57. package/src/highways/ridges/index.ts +328 -0
  58. package/src/highways/sbeb/index.ts +303 -0
  59. package/src/highways/scale-space/index.ts +135 -0
  60. package/src/highways/snap.ts +110 -0
  61. package/src/highways/soft-keys/index.ts +114 -0
  62. package/src/highways/spectral/index.ts +391 -0
  63. package/src/highways/spiral/index.ts +205 -0
  64. package/src/highways/territories/index.ts +150 -0
  65. package/src/highways/trace.ts +153 -0
  66. package/src/highways/traclus/index.ts +296 -0
  67. package/src/index.ts +2 -0
  68. package/src/portfolio/bands.ts +33 -0
  69. package/src/portfolio/fit.ts +29 -0
  70. package/src/portfolio/index.ts +6 -0
  71. package/src/portfolio/key.ts +98 -0
  72. package/src/portfolio/members.ts +171 -0
  73. package/src/portfolio/router.ts +133 -0
  74. package/src/portfolio/sets.ts +28 -0
  75. package/src/routers/shared.ts +56 -3
  76. package/src/strategies/builtins.ts +376 -1
  77. package/src/strategies/schemas.ts +460 -1
  78. package/src/visibility.ts +5 -0
package/build/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import { ExerciseEvidence, HashOptions, MeasureSpec, Member, MemberStatus, MemberTrace, OutputGroup, PickSpec, Portfolio, PortfolioKey, PortfolioLevel, PortfolioOptions, PortfolioPick, PortfolioTrace, RECORD_EPS, SelectCandidate, SelectLevel, Selection, Verdict, canonicalJson, compareMeasure, exercised, minEffectOf, outputGroups, outputHash, pickMoves, portfolio, selectBest, sha256Hex } from "@mark1russell7/layout-contract";
1
2
  /** A point in the plane. */
2
3
  export interface Point {
3
4
  readonly x: number;
@@ -734,6 +735,8 @@ export declare class CornerGraph {
734
735
  constructor(nodes: readonly Node[], obstacles: Obstacles, options: CornerGraphOptions);
735
736
  /** This method gives the number of links of the graph. */
736
737
  get linkCount(): number;
738
+ /** This method gives the corners that link to the corner `i`, in the order of their indexes. A corner that is not in the graph gives an empty list. */
739
+ neighbours(i: number): readonly number[];
737
740
  /** This method gives the index of the corner nearest to `p`, seen or not, or -1 when the graph has no corner near it. */
738
741
  nearest(p: Point): number;
739
742
  /** This method gives at most `k` corners that `p` can see, nearest first. The corner `self` does not count. */
@@ -783,6 +786,19 @@ export declare class SoftGraph {
783
786
  */
784
787
  path(from: Point, to: Point, cost: (n: Node) => number): Point[];
785
788
  }
789
+ /** The largest distance that `channelWidth` looks on each side of a link. A wider channel counts as this width on that side. */
790
+ export declare const CHANNEL_REACH = 64;
791
+ /**
792
+ * This function gives the distance from `p` along the unit direction `d` to the box, or `Infinity` when the ray does not meet the box.
793
+ * A point inside the box gives 0. The function uses the slab test.
794
+ */
795
+ export declare function rayToBox(p: Point, d: Point, box: Box): number;
796
+ /**
797
+ * This function gives the width of the channel of the link from `a` to `b`. The width is the free space between the nearest boxes on the two sides.
798
+ * It measures the width at five points of the link, and gives the smallest. Each side counts up to `reach`.
799
+ * A link of length 0 gives the free space across the x axis at its point.
800
+ */
801
+ export declare function channelWidth(obstacles: Obstacles, a: Point, b: Point, reach?: number): number;
786
802
  /** The options of a way finder. */
787
803
  export interface WayOptions {
788
804
  /** The distance from a box to the corners of the graph. The default is 5. */
@@ -1043,6 +1059,20 @@ interface SharedOptions extends WayOptions {
1043
1059
  * With `snell`, the route meets the run at the angle `acos(d)`, with `d` the cost share of the run for the route (NAT-035).
1044
1060
  */
1045
1061
  readonly merge?: ShareMerge;
1062
+ /**
1063
+ * The pull of the busy links of the pass before (HWY-005, Winding Roads). With a value above 0 and two passes or more, each later pass routes each edge again from no ways.
1064
+ * A link then costs `len / (1 + reuse * u)^reuseExponent`, with `u` the edges of the key on it in the pass before. The default is 0: the later passes are rip-up passes.
1065
+ */
1066
+ readonly reuse?: number;
1067
+ /** The exponent of the pull of `reuse`. The default is 1. */
1068
+ readonly reuseExponent?: number;
1069
+ /**
1070
+ * The cost of a lane that does not fit in its channel (HWY-016). One more edge on a link with `f` edges of the key costs `capacity * max(0, (f + 1) * laneWidth - width)` more.
1071
+ * `width` is the free space across the link (`channelWidth`). The default is 0: the router does not read the channels.
1072
+ */
1073
+ readonly capacity?: number;
1074
+ /** The width of one lane, for `capacity`. The default is 4. */
1075
+ readonly laneWidth?: number;
1046
1076
  /** The benchmark skips a fixture with more nodes. */
1047
1077
  readonly maxNodes?: number;
1048
1078
  }
@@ -2619,6 +2649,16 @@ export declare function positionStability(levels: readonly Level[]): number;
2619
2649
  * A result without such a level gives 1. The cost is `n log n`, with a sample above 1500 items.
2620
2650
  */
2621
2651
  export declare function orderStability(graph: Graph, levels: readonly Level[]): number;
2652
+ /**
2653
+ * This function gives the link agreement of the levels with groups (Z9 of MEAS0).
2654
+ * `la = mean over links of hausdorff(link, routes of its edges outside the two items) / u`, with `u` the argument `unit`.
2655
+ * The edges of a link are the edges between a node of one item and a node of the other item, in either direction.
2656
+ *
2657
+ * The function samples each polyline at points `u / 4` apart, with at most 64 points for each polyline. It keeps the points outside the boxes of the two items.
2658
+ * A link without such points on both sides does not count. It gives `undefined` when no link counts.
2659
+ * The value has no unit, and lower is better. The cost is quadratic in the points of each link.
2660
+ */
2661
+ export declare function linkAgreement(graph: Graph, levels: readonly Level[], routes: readonly Route[], unit: number): number | undefined;
2622
2662
  /** A grouping of the nodes: a map from the id of each node to the id of its group. */
2623
2663
  export type Grouping = ReadonlyMap<string, string>;
2624
2664
  /** This function gives the grouping of one level: each node goes to the id of its item. */
@@ -2787,6 +2827,92 @@ export interface HighwayEdits {
2787
2827
  * `follow` routes each plan with the way options of the strategy. The same graph, strategy, options and seed give the same values.
2788
2828
  */
2789
2829
  export declare function highwayEdits(graph: Graph, strategy: Strategy<"highway", object>, options: object | undefined, edits: number, seed?: number): HighwayEdits;
2830
+ /**
2831
+ * The lane width of the lane measures, in units of the board. The room bench opens the lanes at the same width (`spacing` of `measureBoard`).
2832
+ * R12 also uses it as the smallest correct distance between two parallel legs.
2833
+ */
2834
+ export declare const MEASURE_LANE_WIDTH = 4;
2835
+ /** The routes of a result with each shared segment open: one lane for each edge. */
2836
+ export interface OpenLanes {
2837
+ /** The segments of the result. The shared segments are the runs and the trunks of the bundles. */
2838
+ readonly graph: SegmentGraph;
2839
+ /** The lane route of each edge, from `laneRoutes`. Without a shared segment, the lane routes are the routes. */
2840
+ readonly lanes: readonly Route[];
2841
+ /** The distance between two lanes. */
2842
+ readonly width: number;
2843
+ }
2844
+ /** This function opens each shared segment of a result: each edge of a run or of a trunk gets its own lane, `width` apart. */
2845
+ export declare function openLanes(result: Result, width?: number): OpenLanes;
2846
+ /**
2847
+ * This function gives the lane separation of the routes (R12 of MEAS0): the share of the ink that runs too near a parallel leg of other edges.
2848
+ *
2849
+ * A leg is a drawn segment of `S`, and a leg that several routes share counts one time, as in B1. Two legs are near when four things are true.
2850
+ * The sets of their edges are different. They are within `maxAngle` degrees of parallel. Their projections overlap. Their distance is less than `near`.
2851
+ *
2852
+ * `ns = Σ_s length(the part of s that the projections of its near legs cover) / ink(S)`. Each part counts one time, so the scale is 0 to 1.
2853
+ * Lower is better. Routes without ink give 0. A grid of buckets finds the near legs, so the cost is `n log n` for an even density.
2854
+ */
2855
+ export declare function routeSeparation(routes: readonly Route[], near?: number, maxAngle?: number): number;
2856
+ /**
2857
+ * This function gives the orthogonality of the routes (R14 of MEAS0): `orth = Σ L(legs within maxAngle degrees of an axis) / Σ_e L(r_e)`.
2858
+ * Each route counts its own legs, also on a shared segment. The scale is 0 to 1, and higher is better for an orthogonal style.
2859
+ * Routes without length give 1. The cost is linear.
2860
+ */
2861
+ export declare function orthogonality(routes: readonly Route[], maxAngle?: number): number;
2862
+ /**
2863
+ * This function counts the lane crossings of the segments of a result (B5 of MEAS0): the pairs of edges whose lane order flips.
2864
+ * Along the route of each edge `e`, it takes the shared segments in order. On each one, another edge `f` is on the left or on the right of `e`, in the way of `e`.
2865
+ *
2866
+ * A pair `(e, f)` counts one time when the side of `f` changes from one shared segment of both edges to the next one.
2867
+ * Lower is better. A result without shared segments gives 0. The cost is the sum of the squares of the edge counts of the shared segments.
2868
+ */
2869
+ export declare function laneCrossings(graph: SegmentGraph): number;
2870
+ /**
2871
+ * This function gives the occupied area of the routes (B7 of MEAS0): `moa = cells that S touches / cells that the straight lines touch`.
2872
+ * The cells are squares of side `unit` from the origin, and `unit` is `u` of the board (`boardUnit`). The straight line of an edge joins the two ends of its route.
2873
+ * The scale is a ratio, and lower is better. Routes without a straight line give 1. The cost is linear in the cells.
2874
+ */
2875
+ export declare function occupiedArea(routes: readonly Route[], unit: number): number;
2876
+ /** The run profile of a result (B8 of MEAS0). */
2877
+ export interface RunProfile {
2878
+ /** The number of shared segments: the runs and the trunks of the bundles with two edges or more. */
2879
+ readonly runs: number;
2880
+ /** The median of the edges of each shared segment. It is 0 without a shared segment. */
2881
+ readonly median: number;
2882
+ /** The most edges of one shared segment. It is 0 without a shared segment. */
2883
+ readonly max: number;
2884
+ }
2885
+ /** This function gives the run profile of a result (B8 of MEAS0): the shared segments, and the median and the most edges of each. The cost is linear. */
2886
+ export declare function runProfile(graph: SegmentGraph): RunProfile;
2887
+ /** The lane fidelity of a result (B9 of MEAS0). */
2888
+ export interface LaneFidelity {
2889
+ /** The median of `lf(e)` over the edges with a shared segment. */
2890
+ readonly median: number;
2891
+ /** The largest `lf(e)`. */
2892
+ readonly max: number;
2893
+ /** The number of edges with a shared segment. */
2894
+ readonly edges: number;
2895
+ }
2896
+ /**
2897
+ * This function gives the lane fidelity (B9 of MEAS0): `lf(e) = frechet(lane(e), r_e) / (width · k / 2)` for each edge `e` with a shared segment.
2898
+ * `lane(e)` is the lane route of `openLanes`, `r_e` is the route, and `k` is the edge count of the widest shared segment of `e`.
2899
+ * `frechet` is the discrete Fréchet distance of the points. A value of 1 or less is correct, and lower is better.
2900
+ * It gives `undefined` when no edge has a shared segment. The cost is quadratic in the points of each route.
2901
+ */
2902
+ export declare function laneFidelity(routes: readonly Route[], open: OpenLanes): LaneFidelity | undefined;
2903
+ /**
2904
+ * This function counts the lane routes that go through a box that is not one of their ends (M4 of MEAS0).
2905
+ * It is the count `laneThrough` of the room bench (`measureBoard`), for the lanes of any result. Lower is better. The cost is `n log n`.
2906
+ */
2907
+ export declare function lanesThrough(graph: Graph, open: OpenLanes): number;
2908
+ /**
2909
+ * This function gives the area of a result (M1 of MEAS0) for a router: the growth of the board that the open lanes need.
2910
+ * The value is the area of the bounding box of the boxes and the lane routes. The function divides it by the area of the bounding box of the boxes.
2911
+ *
2912
+ * It is the room form `area(open) / area(packed)` with the boxes as they are. The scale is a ratio of 1 or more, and lower is better.
2913
+ * A board without area gives 1. The cost is linear.
2914
+ */
2915
+ export declare function laneArea(graph: Graph, open: OpenLanes): number;
2790
2916
  /** The names of the proposed hard rules of MEAS0. The suite counts them. It does not apply them as rules yet. */
2791
2917
  export declare const PROPOSED_RULES: readonly string[];
2792
2918
  /** The options of `runSuite`. */
@@ -3211,94 +3337,34 @@ export declare const STRETCH_DEFAULTS: Readonly<StretchOptions>;
3211
3337
  export declare function stretchPlan(input: HighwayInput, plan: HighwayPlan, options: Readonly<StretchOptions>, way?: WayOptions): HighwayPlan;
3212
3338
  /** The gate `stretch` (HWY-048): an edge joins a highway only when its route stays in a budget of its route alone. */
3213
3339
  export declare const stretchGate: Gate<StretchOptions>;
3214
- /** The end of the edges that gets a field: the target of a fan-in, or the source of a fan-out. */
3215
- type FieldEnd = "target" | "source";
3216
- /** The options of the highway strategy `flow-field` (EDA-046 with HWY-037 of the notes). */
3217
- interface FlowFieldOptions extends Pick<WayOptions, "margin" | "k"> {
3218
- /** An end with this number of edges or more on one side of its box gets a field. The default is 2. */
3219
- readonly minFanIn: number;
3220
- /** The end that gets a field. The default is `target`. */
3221
- readonly end: FieldEnd;
3222
- }
3223
- /** The default options of the strategy `flow-field`. */
3224
- export declare const FLOW_FIELD_DEFAULTS: Readonly<Required<Omit<FlowFieldOptions, "margin" | "k">>>;
3225
- /**
3226
- * This function gives the highways of a flow field for each target (EDA-046, HWY-037).
3227
- * The edges into one side of one box make a fan. The root of the fan is the point out of the median plug of the fan.
3228
- * Each edge of the fan goes the shortest way from the point out of its other plug to the root, through the corner graph.
3229
- * The shortest ways to one root make a tree, so they merge like streams and do not cross. Each stretch that two ways share is one highway.
3230
- * With the end `source`, the same holds for the edges out of one side of one box.
3231
- */
3232
- export declare function flowFieldPlan(input: HighwayInput, o: Readonly<FlowFieldOptions>): HighwayPlan;
3233
- /** The options of the highway strategy `keys`: the options of the router `trunks`, without the name and the limit of the benchmark. */
3234
- type KeysOptions = Omit<TrunksOptions, "name" | "maxNodes">;
3235
- /**
3236
- * This function gives the highways that the router `trunks` decides. A rule gives each edge a key.
3237
- * The edges from one plug with one key share a trunk to a split point. The edges that go on together share a run past it.
3238
- * Each trunk and each run becomes one highway. The function does not change the router: it reads its bundles and its runs.
3239
- */
3240
- export declare function keysPlan(input: HighwayInput, options: KeysOptions): HighwayPlan;
3241
- /**
3242
- * The plan that a post step changes. `none` is the empty plan: `follow` then routes each edge as the router `corners` does.
3243
- * `shared-ways` and `corridors` are the plans of those highway strategies, with their defaults.
3244
- */
3245
- type HighwayBase = "none" | "shared-ways" | "corridors";
3246
- /** The values of `HighwayBase`. */
3247
- export declare const HIGHWAY_BASES: readonly HighwayBase[];
3248
- /** This function gives the plan of a base. */
3249
- export declare function basePlan(input: HighwayInput, base: HighwayBase): HighwayPlan;
3250
- /** The options of the highway strategy `level-links` (HWY-056 with WILD-034 of the notes). */
3251
- interface LevelHighwayOptions {
3252
- /** The plan of the edges that do not ride a level link. The default is `shared-ways`. */
3253
- readonly from: HighwayBase;
3254
- /** The depth of the level in the tree of sections. Depth 1 is the level below the root. The default is 1. */
3255
- readonly depth: number;
3256
- /** A level link becomes a highway when this number of edges or more ride it. The default is 2. */
3340
+ /** The options of the highway strategy `diffusion` (HWY-020 of the note on highways). */
3341
+ interface DiffusionOptions extends Pick<WayOptions, "margin" | "k"> {
3342
+ /** The share of the density that each step of the diffusion takes from the links next to a link. The default is 0.25. */
3343
+ readonly a: number;
3344
+ /** The number of steps of the diffusion. The default is 3. */
3345
+ readonly steps: number;
3346
+ /** The weight of the density in the cost of a link. The default is 1. */
3347
+ readonly lambda: number;
3348
+ /** The power of the discount of a dense link. The default is 1. */
3349
+ readonly gamma: number;
3350
+ /** A highway has this number of edges or more. The default is 2. */
3257
3351
  readonly minSize: number;
3258
- /** An edge rides the link only when its way along the link is this many times its first route, or shorter. The default is 1.5. */
3259
- readonly stretch: number;
3260
- }
3261
- /** The default options of the strategy `level-links`. */
3262
- export declare const LEVEL_HIGHWAY_DEFAULTS: Readonly<LevelHighwayOptions>;
3263
- /**
3264
- * This function gives a highway for each link of a zoom level, with the edges between its two items (HWY-056, WILD-034).
3265
- * The level is the cut of the tree of sections at `depth`. The link goes around the boxes of the other items (`levelLinks`).
3266
- * The spine is the link without a margin at each end, so it stays off the boxes of the two items. It must stay out of each box.
3267
- * The edges between the two items, in each direction, ride the spine. The ramps go through the corner graph inside the items.
3268
- *
3269
- * An edge rides only when the ramps (as straight lines) and the spine are `stretch` times its first route, or shorter.
3270
- * A link with fewer than `minSize` such edges is not a highway. The other edges keep their highways of the plan `from`.
3271
- * Thus a zoom from the level to the routes shows the same lines, which open into lanes.
3272
- */
3273
- export declare function levelHighwayPlan(input: HighwayInput, o: Readonly<LevelHighwayOptions>): HighwayPlan;
3274
- /** The options of the highway strategy `meet` (HWY-050 of the note on highways). */
3275
- interface MeetOptions {
3276
- /** The plan whose merge points and split points the strategy moves. The default is `shared-ways`. */
3277
- readonly from: HighwayBase;
3278
- /** A first route meets the spine where it is this distance from the spine, or nearer. The default is 8: two lanes of 4. */
3279
- readonly near: number;
3280
- /** A first route meets the spine only where it runs at this angle to the spine, or less, in degrees. The default is 45. */
3281
- readonly maxTurn: number;
3282
- /** A member keeps its places when the stretch where its first route meets the spine is shorter than this length. The default is 10. */
3283
- readonly minRun: number;
3284
3352
  }
3285
- /** The default options of the strategy `meet`. */
3286
- export declare const MEET_DEFAULTS: Readonly<MeetOptions>;
3353
+ /** The default options of the strategy `diffusion`. */
3354
+ export declare const DIFFUSION_DEFAULTS: Readonly<Required<Omit<DiffusionOptions, "margin" | "k">>>;
3287
3355
  /**
3288
- * This function gives a member with its merge point and its split point where its first route meets the spine and parts from it (HWY-050).
3289
- * The function samples the stretch of the member on the spine, at steps of `near / 2` or less.
3290
- * A sample meets the route when the route is `near` or nearer, and its nearest leg runs at `maxTurn` or less to the spine.
3291
- * The new merge point is the first sample that meets the route, in the direction of the member. The new split point is the last one.
3292
- * So the edge joins the spine late and leaves it early. The places only move inward.
3293
- * The member keeps its places when no sample meets the route, or when the met stretch is shorter than `minRun`.
3356
+ * This function gives the density of the edges on the links of the corner graph after the diffusion, as a share of the largest density.
3357
+ * The density of a link starts as the number of first ways on it. Each step mixes it with the mean density of the links that share a corner with it:
3358
+ * `rho_{k+1}(l) = (1 - a) rho_k(l) + a mean(rho_k(l'))`. The key of a link is `i * M + j` for the corners `i < j` of a graph of `M` corners.
3294
3359
  */
3295
- export declare function meetMember(spine: readonly Point[], member: HighwayMember, route: readonly Point[] | undefined, o: Readonly<MeetOptions>): HighwayMember;
3360
+ export declare function linkDensity(neighbours: (i: number) => readonly number[], corners: number, use: ReadonlyMap<number, number>, a: number, steps: number): Map<number, number>;
3296
3361
  /**
3297
- * This function gives the highways of the plan `from`, with merge points and split points where the routes meet and part (HWY-050).
3298
- * The first route of each edge is the route of `input.routes`, or its route without highways.
3299
- * Each member gets the places of `meetMember`. The spines and the trips do not change.
3362
+ * This function gives the highways of the route-aware bundling on the corner graph (HWY-020).
3363
+ * The first ways of the edges give the density of each link. A diffusion along the graph smooths it.
3364
+ * Then each edge takes a shortest way where a dense link costs less: `cost(l) = len(l) / (1 + lambda rho(l))^gamma`, with `rho` from 0 to 1.
3365
+ * Each stretch that `minSize` ways or more share after the second pass is one highway. The highways stay on the links of the corner graph.
3300
3366
  */
3301
- export declare function meetPlan(input: HighwayInput, o: Readonly<MeetOptions>): HighwayPlan;
3367
+ export declare function diffusionPlan(input: HighwayInput, o: Readonly<DiffusionOptions>): HighwayPlan;
3302
3368
  /**
3303
3369
  * The spine of a group of edges. With `shared`, the edges of each group go through the router `shared` with the group as their key.
3304
3370
  * Each stretch that they share is a highway. With `trunk`, each group gets one trunk between two terminals, with a leg from each plug.
@@ -3334,93 +3400,188 @@ export declare function weberPoint(points: readonly Point[], iterations?: number
3334
3400
  * A terminal is the Weber point of the points out of the plugs at one end of the group. A terminal in a box moves to the nearest of those points.
3335
3401
  */
3336
3402
  export declare function groupedPlan(input: HighwayInput, groups: ReadonlyMap<string, EdgeGroup>, o: Readonly<GroupedOptions>): HighwayPlan;
3337
- /** The options of the highway strategy `od-cells` (EDA-033 with WILD-032 of the notes). */
3338
- interface OdCellOptions {
3339
- /** The depth of the cells in the tree of sections. Depth 1 is the level below the root. The default is 2. */
3340
- readonly level: number;
3341
- /** A pair of cells with this number of edges or more gets a trunk. The default is 3. */
3342
- readonly minGroup: number;
3343
- /** An edge rides the trunk only when each of its legs is this share of the span or shorter. The default is 0.3. */
3344
- readonly legMax: number;
3345
- /** The spine of each pair of cells. The default is `trunk`. */
3403
+ /** The linkage of the hierarchical clustering: the distance of two clusters from the distances of their edges. */
3404
+ type Linkage = "average" | "complete" | "single";
3405
+ /** The values of `Linkage`. */
3406
+ export declare const LINKAGES: readonly Linkage[];
3407
+ /** The options of the highway strategy `flow-clusters` (HWY-023 of the note on highways). */
3408
+ interface FlowClusterOptions {
3409
+ /** Two clusters join while their distance is this value or less. The distance is a share of the length of the shorter edge. The default is 0.3. */
3410
+ readonly tau: number;
3411
+ /** The linkage. The default is `average`. */
3412
+ readonly linkage: Linkage;
3413
+ /** With `true`, the source of one edge only compares with the source of the other edge. The default is `false`. */
3414
+ readonly directed: boolean;
3415
+ /** A cluster with this number of edges or more gets highways. The default is 2. */
3416
+ readonly minSize: number;
3417
+ /** The spine of each cluster. The default is `trunk`: one flow line from one area to the other area. */
3346
3418
  readonly spine: GroupSpine;
3347
3419
  }
3348
- /** The default options of the strategy `od-cells`. */
3349
- export declare const OD_CELL_DEFAULTS: Readonly<OdCellOptions>;
3420
+ /** The default options of the strategy `flow-clusters`. */
3421
+ export declare const FLOW_CLUSTER_DEFAULTS: Readonly<FlowClusterOptions>;
3350
3422
  /**
3351
- * This function gives the groups of the edges by the pair of the cells of their two nodes (EDA-033, WILD-032).
3352
- * The cells are the items of the zoom level at the depth `level`. The edges of one pair of cells, in either direction, are one group.
3353
- * An edge inside one cell is in no group.
3423
+ * This function gives the flow distance of two edges (Zhu and Guo 2014): `max(|s_e - s_f|, |t_e - t_f|) / min(len e, len f)`.
3424
+ * Without `directed`, it is the smaller value of the two directions of `f`, and `flip` is `true` when the opposite direction is smaller.
3354
3425
  */
3355
- export declare function odGroups(input: HighwayInput, o: Readonly<OdCellOptions>): Map<string, EdgeGroup>;
3426
+ export declare function flowDistance(s1: Point, t1: Point, s2: Point, t2: Point, directed: boolean): {
3427
+ d: number;
3428
+ flip: boolean;
3429
+ };
3356
3430
  /**
3357
- * This function gives the highways of the consolidation by origin and destination cells (EDA-033, WILD-032).
3358
- * Carriers merge the loads from one region to another into one truck between two terminals. Thus each pair of cells with `minGroup` edges or more gets one trunk.
3359
- * The terminals are the Weber points of the plugs in each cell. An edge with a leg longer than `legMax` times the span goes alone.
3431
+ * This function clusters the points of a distance matrix with the chain of nearest neighbours. The linkage is reducible, so the chain gives the same tree as the greedy order.
3432
+ * The clusters join while their distance is `tau` or less. The function gives the cluster of each point, as the index of a point of the cluster.
3360
3433
  */
3361
- export declare function odCellPlan(input: HighwayInput, o: Readonly<OdCellOptions>): HighwayPlan;
3362
- /** The line of each edge that QuickBundles compares: its first route, or the straight line between its plugs. */
3363
- type BundleLine = "routes" | "lines";
3364
- /** The order of the edges in the one pass: the order of the graph, or the longest line first. */
3365
- type BundleOrder = "input" | "length";
3366
- /** The options of the highway strategy `quickbundles` (HWY-026 of the note on highways). */
3367
- interface QuickBundlesOptions {
3368
- /** An edge joins a cluster when its distance to the centroid is this value or less, in units of the board. The default is 3. */
3369
- readonly theta: number;
3370
- /** The number of points of each line after the resampling. The default is 12. */
3371
- readonly points: number;
3372
- /** The line of each edge. The default is `routes`. */
3373
- readonly line: BundleLine;
3374
- /** The order of the edges. The default is `input`, so an added edge does not change the clusters before it. */
3375
- readonly order: BundleOrder;
3376
- /** A cluster with this number of edges or more gets highways. The default is 2. */
3434
+ export declare function chainClusters(n: number, d: Float64Array, tau: number, linkage: Linkage): Int32Array;
3435
+ /**
3436
+ * This function gives the flow clusters of the edges (HWY-023). It clusters the edges as points in 4D, with the cut at `tau`.
3437
+ * Each edge of a cluster gets the key of the cluster. It gets `flip` when it goes opposite to the first edge of the cluster.
3438
+ */
3439
+ export declare function flowClusters(input: HighwayInput, o: Readonly<FlowClusterOptions>): Map<string, EdgeGroup>;
3440
+ /**
3441
+ * This function gives the highways of the flow clusters (HWY-023). The clusters of `flowClusters` with `minSize` edges or more get highways.
3442
+ * With the spine `trunk`, each cluster gets one trunk from one area to the other area. With `shared`, the edges of a cluster share their ways.
3443
+ */
3444
+ export declare function flowClusterPlan(input: HighwayInput, o: Readonly<FlowClusterOptions>): HighwayPlan;
3445
+ /** The options of the highway strategy `edge-paths` (HWY-012 of the note on highways). */
3446
+ interface EdgePathOptions extends Pick<WayOptions, "margin" | "k"> {
3447
+ /** An edge takes a path of other edges only when the path is this many times its own length or less. The default is 2. */
3448
+ readonly distortion: number;
3449
+ /** The weight of a link in the search is its length to this power. A larger power prefers paths of many short links. The default is 2. */
3450
+ readonly power: number;
3451
+ /** A highway has this number of edges or more. The default is 2. */
3377
3452
  readonly minSize: number;
3378
- /** The spine of each cluster. The default is `shared`. */
3453
+ }
3454
+ /** The default options of the strategy `edge-paths`. */
3455
+ export declare const EDGE_PATH_DEFAULTS: Readonly<Required<Omit<EdgePathOptions, "margin" | "k">>>;
3456
+ /** One step of the path of an edge: the edge of the step and `true` when the path goes from its target to its source. */
3457
+ interface PathStep {
3458
+ readonly edge: string;
3459
+ readonly back: boolean;
3460
+ }
3461
+ /**
3462
+ * This function gives the edge paths of the graph (Wallinger and others 2022). The edges go in the order of their lengths, the longest first.
3463
+ * An edge looks for the shortest path of other edges between its nodes, with the weight `length ^ power`. A path is good when its length is `distortion` times the length of the edge or less.
3464
+ * The edges of a good path lock: they keep their own ways. An edge with a good path leaves the graph of the search. The map holds the path of each such edge.
3465
+ */
3466
+ export declare function edgePaths(input: HighwayInput, o: Readonly<Pick<EdgePathOptions, "distortion" | "power">>): Map<string, PathStep[]>;
3467
+ /**
3468
+ * This function gives the highways of the edge paths (HWY-012). An edge with a good path follows the ways of the edges of its path.
3469
+ * Each edge of the path keeps its own way through the corner graph. So the ways share their links, and each shared stretch is a highway.
3470
+ */
3471
+ export declare function edgePathPlan(input: HighwayInput, o: Readonly<EdgePathOptions>): HighwayPlan;
3472
+ /** The distance of two edges: 1 less their compatibility of FDEB, or the flow distance in 4D of HWY-023. */
3473
+ type EdgeDistance = "compatibility" | "flow";
3474
+ /** The values of `EdgeDistance`. */
3475
+ export declare const EDGE_DISTANCES: readonly EdgeDistance[];
3476
+ /** The options of the highway strategy `hdbscan` (HWY-028 of the note on highways). */
3477
+ interface HdbscanOptions {
3478
+ /** A cluster has this number of edges or more. The default is 3. */
3479
+ readonly minClusterSize: number;
3480
+ /** The core distance of an edge is the distance to its neighbour of this rank. The default is 3. */
3481
+ readonly minSamples: number;
3482
+ /** The distance of two edges. The default is `compatibility`. */
3483
+ readonly distance: EdgeDistance;
3484
+ /** The spine of each cluster. The default is `trunk`: one trunk from one area to the other area. */
3379
3485
  readonly spine: GroupSpine;
3380
3486
  }
3381
- /** The default options of the strategy `quickbundles`. */
3382
- export declare const QUICKBUNDLES_DEFAULTS: Readonly<QuickBundlesOptions>;
3383
- /** This function gives `k` points at equal steps of length along a polyline, from its first point to its last point. */
3384
- export declare function resample(line: readonly Point[], k: number): Point[];
3487
+ /** The default options of the strategy `hdbscan`. */
3488
+ export declare const HDBSCAN_DEFAULTS: Readonly<HdbscanOptions>;
3385
3489
  /**
3386
- * This function gives the MDF distance of two lines with the same number of points. It is the mean distance of their points.
3387
- * The function compares the points in the same direction and in the opposite direction, and keeps the smaller mean.
3388
- * `flip` is `true` when the opposite direction is smaller.
3490
+ * This function gives the compatibility of two edges of FDEB (Holten and van Wijk 2009): `Ca Cs Cp Cv`, from 0 to 1.
3491
+ * `Ca` is the angle, `Cs` the scale, `Cp` the position and `Cv` the visibility. The direction of an edge does not change the value.
3389
3492
  */
3390
- export declare function mdf(p: readonly Point[], q: readonly Point[]): {
3391
- d: number;
3392
- flip: boolean;
3393
- };
3493
+ export declare function compatibility(p0: Point, p1: Point, q0: Point, q1: Point): number;
3394
3494
  /**
3395
- * This function gives the clusters of QuickBundles (Garyfallidis 2012) as groups of edges.
3396
- * In one pass, each edge joins the cluster with the nearest centroid when the MDF distance is `theta` units or less. Else it starts a cluster.
3397
- * The centroid is the running mean of the lines of the cluster, each in the direction of the centroid.
3495
+ * This function gives the HDBSCAN clusters of the points of a distance matrix (Campello, Moulavi and Sander 2013). The value -1 is noise.
3496
+ * The core distance of a point is the distance to its `minSamples`-th nearest point. The mutual reachability is `max(core(a), core(b), d(a, b))`.
3497
+ * The minimum spanning tree of the mutual reachability gives the tree of the clusters. A split with two parts of `minClusterSize` or more gives two clusters.
3498
+ * The selection keeps the clusters with the largest stability, `sum (lambda_leave - lambda_birth)`, with `lambda = 1 / distance`. The root is not a cluster.
3398
3499
  */
3399
- export declare function quickBundles(input: HighwayInput, o: Readonly<QuickBundlesOptions>): Map<string, EdgeGroup>;
3500
+ export declare function hdbscanLabels(n: number, d: Float64Array, minClusterSize: number, minSamples: number): Int32Array;
3400
3501
  /**
3401
- * This function gives the highways of QuickBundles (HWY-026). The clusters of `quickBundles` with `minSize` edges or more get highways.
3402
- * With the spine `shared`, the edges of each cluster share their ways through the corner graph. With `trunk`, each cluster gets one trunk.
3502
+ * This function gives the HDBSCAN clusters of the edges (HWY-028). The edges that are noise get no group.
3503
+ * Each edge of a cluster gets `flip` when it goes opposite to the first edge of the cluster.
3403
3504
  */
3404
- export declare function quickBundlesPlan(input: HighwayInput, o: Readonly<QuickBundlesOptions>): HighwayPlan;
3405
- /** The options of the highway strategy `road-classes` (HWY-034 with EDA-050 of the notes). */
3406
- interface RoadClassOptions extends Pick<WayOptions, "margin" | "k"> {
3407
- /** A link is a highway link when its use is at this quantile of the use of the links, or higher. The default is 0.9. */
3408
- readonly quantile: number;
3409
- /** A highway link has this number of edges or more on it, and a highway has this number of edges or more. The default is 2. */
3505
+ export declare function hdbscanClusters(input: HighwayInput, o: Readonly<HdbscanOptions>): Map<string, EdgeGroup>;
3506
+ /**
3507
+ * This function gives the highways of the HDBSCAN clusters (HWY-028). The clusters that live over a long range of densities are the highways.
3508
+ * The number of highways is not fixed, and the noise edges stay alone.
3509
+ */
3510
+ export declare function hdbscanPlan(input: HighwayInput, o: Readonly<HdbscanOptions>): HighwayPlan;
3511
+ /** One edge that snaps to a line: the points where it joins and leaves the line, and its place along its own way. */
3512
+ interface SnapMember {
3513
+ readonly edge: string;
3514
+ /** The point on the line where the edge joins it. */
3515
+ readonly from: Point;
3516
+ /** The point on the line where the edge leaves it. */
3517
+ readonly to: Point;
3518
+ /** The place of the join along the edge, from 0 at the source to 1 at the target. It orders the highways of one edge. */
3519
+ readonly at: number;
3520
+ }
3521
+ /** A straight line that a finder gives as the place of a highway, with the edges that snap to it. */
3522
+ interface SnapLine {
3523
+ readonly key: string;
3524
+ readonly a: Point;
3525
+ readonly b: Point;
3526
+ readonly members: readonly SnapMember[];
3527
+ }
3528
+ /** The options of `snapPlan`. */
3529
+ interface SnapOptions extends Pick<WayOptions, "margin" | "k"> {
3530
+ /** A highway has this number of edges or more. The value is 2 or more. */
3410
3531
  readonly minSize: number;
3411
- /** The second pass gives each highway link this discount, as a share of its length. The default is 0.5. */
3412
- readonly discount: number;
3413
3532
  }
3414
- /** The default options of the strategy `road-classes`. */
3415
- export declare const ROAD_CLASS_DEFAULTS: Readonly<Required<Omit<RoadClassOptions, "margin" | "k">>>;
3533
+ /** This function gives the line `u d + rho n` of the direction angle `theta`, with `d = (cos, sin)` and the normal `n = (-sin, cos)`. */
3534
+ export declare function linePoint(theta: number, rho: number, u: number): Point;
3535
+ /**
3536
+ * This function gives the highways of straight lines in the free space. Each line becomes a spine through the corner graph between its two ends.
3537
+ * An end inside a box moves to the nearest corner of the graph.
3538
+ * Each member joins the spine at the place nearest to its point `from`, and leaves it at the place nearest to its point `to`.
3539
+ * A member whose part of the spine is shorter than the margin does not ride. A spine with fewer than `minSize` members is not a highway.
3540
+ * An edge on several highways takes them in the order of `at`.
3541
+ */
3542
+ export declare function snapPlan(input: HighwayInput, lines: readonly SnapLine[], o: Readonly<SnapOptions>): HighwayPlan;
3543
+ /** This function gives the points of a spine from the place `on` to the place `off`, backward when `on` is larger. */
3544
+ export declare function spinePart(spine: readonly Point[], on: number, off: number): Point[];
3545
+ /** The options of the highway strategy `hough` (HWY-024 of the note on highways). */
3546
+ interface HoughOptions extends Pick<WayOptions, "margin" | "k"> {
3547
+ /** The width of the votes in the angle, in degrees. An edge joins a peak within this angle. The default is 8. */
3548
+ readonly dTheta: number;
3549
+ /** The width of the votes in the offset, in units of the board. An edge joins a peak when its middle is this near to the line. The default is 12. */
3550
+ readonly dRho: number;
3551
+ /** A peak with fewer edges than this number is not a corridor. The default is 3. */
3552
+ readonly minVotes: number;
3553
+ /** With `true`, the peaks are only horizontal or vertical lines. The default is `false`. */
3554
+ readonly orthogonal: boolean;
3555
+ }
3556
+ /** The default options of the strategy `hough`. */
3557
+ export declare const HOUGH_DEFAULTS: Readonly<Required<Omit<HoughOptions, "margin" | "k">>>;
3558
+ /** A peak of the votes: its angle, its offset and the sum of its votes. */
3559
+ interface HoughPeak {
3560
+ readonly theta: number;
3561
+ readonly rho: number;
3562
+ readonly votes: number;
3563
+ }
3416
3564
  /**
3417
- * This function gives the highways of the road classes (HWY-034, EDA-050). It counts how many first ways use each link of the corner graph.
3418
- * The links with a use at the quantile `quantile` or higher, and at least `minSize`, are the highway links.
3419
- * They are the main roads of a road map.
3420
- * A second pass routes each edge again, with the discount on the highway links, so more edges join them.
3421
- * Each stretch of highway links that `minSize` ways or more share after the second pass is one highway.
3565
+ * This function gives the peaks of the votes of the lines (Duda and Hart 1972). Each line votes for its angle and its offset, with a weight of its length.
3566
+ * A vote spreads as a Gaussian with the widths `dTheta / 2` and `dRho / 2`. The accumulator has bins of 1 degree and of `dRho / 4`.
3567
+ * A peak is a bin with a larger sum than each other bin within `dTheta` and `dRho`. The peaks come in the order of their votes.
3422
3568
  */
3423
- export declare function roadClassPlan(input: HighwayInput, o: Readonly<RoadClassOptions>): HighwayPlan;
3569
+ export declare function houghPeaks(lines: readonly {
3570
+ theta: number;
3571
+ mid: Point;
3572
+ len: number;
3573
+ }[], o: Readonly<Pick<HoughOptions, "dTheta" | "dRho" | "orthogonal">>): HoughPeak[];
3574
+ /**
3575
+ * This function gives the corridors of the votes (HWY-024). Each edge joins the first peak with an angle within `dTheta` and its middle within `dRho` of the line.
3576
+ * The corridor runs over the common span of the projections of its edges on the line. Each edge snaps to the ends of that span.
3577
+ * A member that makes the span shorter than four margins leaves, while the peak keeps `minVotes` edges.
3578
+ */
3579
+ export declare function houghLines(input: HighwayInput, o: Readonly<HoughOptions>): SnapLine[];
3580
+ /**
3581
+ * This function gives the highways of the Hough votes (HWY-024). The peaks of the votes of the straight lines of the edges are corridors.
3582
+ * Each corridor is a spine through the corner graph, and its edges ride it over their common span.
3583
+ */
3584
+ export declare function houghPlan(input: HighwayInput, o: Readonly<HoughOptions>): HighwayPlan;
3424
3585
  /** A generator of candidate highways: a highway strategy with its defaults. */
3425
3586
  type CandidateSource = "corridors" | "quickbundles" | "wspd" | "road-classes" | "flow-field" | "od-cells" | "shared-ways";
3426
3587
  /** The values of `CandidateSource`. */
@@ -3455,41 +3616,1458 @@ export declare function candidateScore(h: Highway, routes: ReadonlyMap<string, r
3455
3616
  * swaps in a candidate. The swap occurs when the net gain of the candidate is more than the sum of the selected candidates in conflict with it.
3456
3617
  */
3457
3618
  export declare function selectPlan(input: HighwayInput, o: Readonly<SelectOptions>): HighwayPlan;
3458
- /** The options of the highway strategy `shared-ways`: the options of the router `shared`, without the name and the limit of the benchmark. */
3459
- type SharedWaysOptions = Omit<SharedOptions, "name" | "maxNodes">;
3460
- /**
3461
- * This function gives the highways that the router `shared` decides. The edges of one key go one by one through the corner graph.
3462
- * A link that the key uses already costs less, so the ways of a key come together. Each stretch that two edges or more share becomes one highway.
3463
- * The function does not change the router: it reads its runs.
3464
- */
3465
- export declare function sharedWaysPlan(input: HighwayInput, options: SharedWaysOptions): HighwayPlan;
3466
- /** The ends of the edges that get stubs: the source ends, the target ends, or both. */
3467
- type StubEnds = "source" | "target" | "both";
3468
- /** The options of the highway strategy `stubs` (HWY-015 with WILD-005 of the notes). */
3469
- interface StubOptions {
3470
- /** The plan that the stubs go into. The default is `shared-ways`. */
3471
- readonly from: HighwayBase;
3472
- /** The ends of one side of a box whose directions are in a window of this angle share a stub, in degrees. The default is 30. */
3473
- readonly omega: number;
3474
- /** The length of a stub is this share of the distance to the nearest other end. The default is 0.25. */
3475
- readonly sigma: number;
3476
- /** The ends that get stubs. The default is `both`. */
3477
- readonly ends: StubEnds;
3478
- /** A stub has this number of edges or more. The default is 2. */
3619
+ /** A generator of candidate arcs: `runs` (the shared stretches of the first ways of all edges) or a generator of the strategy `select`. */
3620
+ type ArcSource = "runs" | CandidateSource;
3621
+ /** The values of `ArcSource`. */
3622
+ export declare const ARC_SOURCES: readonly ArcSource[];
3623
+ /** The options of the highway strategy `hub-arcs` (HWY-042 of the note on highways). */
3624
+ interface HubArcOptions {
3625
+ /** The largest number of arcs (highways). The default is 12. */
3626
+ readonly q: number;
3627
+ /** The cost of a length on an arc against a length off the arcs, from 0 to 1. The default is 0.5. */
3628
+ readonly alpha: number;
3629
+ /** An edge rides an arc only when its legs plus its part of the arc are this many times its first route or less. The default is 1.25. */
3630
+ readonly stretch: number;
3631
+ /** The number of passes of the local search with one swap. The default is 1. */
3632
+ readonly swaps: number;
3633
+ /** An arc with fewer edges than this number is not a highway. The default is 2. */
3479
3634
  readonly minSize: number;
3635
+ /** The generators of the candidate arcs. The default is `runs`, `corridors` and `road-classes`. */
3636
+ readonly generators: readonly ArcSource[];
3480
3637
  }
3481
- /** The default options of the strategy `stubs`. */
3482
- export declare const STUB_DEFAULTS: Readonly<StubOptions>;
3638
+ /** The default options of the strategy `hub-arcs`. */
3639
+ export declare const HUB_ARC_DEFAULTS: Readonly<HubArcOptions>;
3640
+ /** This function gives the candidate arcs: the spines of the plans of the generators, without the copies, with the longest first. */
3641
+ export declare function candidateArcs(input: HighwayInput, generators: readonly ArcSource[]): Point[][];
3483
3642
  /**
3484
- * This function gives the highways of the plan `from`, with a stub at the ends of the edges (HWY-015, WILD-005).
3485
- * The ends on one side of one box are sorted by the direction of their other node. A run of ends in a window of `omega` makes a group.
3486
- * Each group of `minSize` ends or more shares one plug and one stub along the normal of the side. Then the edges fan out.
3487
- *
3488
- * The length of the stub is `sigma` times the distance to the nearest other node, and half that distance at most.
3643
+ * This function gives the highways of the hub arc location (Campbell, Ernst and Krishnamoorthy 2005). It chooses at most `q` arcs from the candidates.
3644
+ * An edge on an arc costs its two legs plus `alpha` times its part of the arc. An edge off the arcs costs its first route.
3645
+ * The greedy step adds the arc that saves the most cost. Then each swap pass changes one chosen arc for one other arc while the saving grows.
3646
+ * Each edge rides the arc that saves the most for it.
3647
+ */
3648
+ export declare function hubArcPlan(input: HighwayInput, o: Readonly<HubArcOptions>): HighwayPlan;
3649
+ /**
3650
+ * The plan that a post step changes. `none` is the empty plan: `follow` then routes each edge as the router `corners` does.
3651
+ * `shared-ways` and `corridors` are the plans of those highway strategies, with their defaults.
3652
+ */
3653
+ type HighwayBase = "none" | "shared-ways" | "corridors";
3654
+ /** The values of `HighwayBase`. */
3655
+ export declare const HIGHWAY_BASES: readonly HighwayBase[];
3656
+ /** This function gives the plan of a base. */
3657
+ export declare function basePlan(input: HighwayInput, base: HighwayBase): HighwayPlan;
3658
+ /** The side of the road that the traffic keeps to. */
3659
+ type TrafficRule = "right" | "left";
3660
+ /** The values of `TrafficRule`. */
3661
+ export declare const TRAFFIC_RULES: readonly TrafficRule[];
3662
+ /** The options of the highway strategy `divided` (HWY-011 of the notes). */
3663
+ interface DividedOptions extends Pick<WayOptions, "margin" | "k"> {
3664
+ /** The plan that the strategy divides. The default is `shared-ways`. */
3665
+ readonly from: HighwayBase;
3666
+ /** The side of the road of the traffic. With `right`, the edges of each direction keep to the right of the spine. The default is `right`. */
3667
+ readonly rule: TrafficRule;
3668
+ /** The gap between the two carriageways, in lanes. The default is 1. */
3669
+ readonly gap: number;
3670
+ /** The width of one lane, in units of the board. The default is 4. */
3671
+ readonly laneWidth: number;
3672
+ /** A highway divides only when each direction has this number of edges or more. The default is 2. */
3673
+ readonly minSize: number;
3674
+ }
3675
+ /** The default options of the strategy `divided`. */
3676
+ export declare const DIVIDED_DEFAULTS: Readonly<Required<Omit<DividedOptions, "margin" | "k">>>;
3677
+ /**
3678
+ * This function gives the polyline at the distance `offset` from `line`, with the same number of points. A positive offset is on the right of the line.
3679
+ * The y axis points down, so the right of the direction `(dx, dy)` is `(-dy, dx)`. Each inner point moves along the bisector of its two legs (a miter join).
3680
+ */
3681
+ export declare function offsetLine(line: readonly Point[], offset: number): Point[];
3682
+ /**
3683
+ * This function divides one highway into two carriageways, one for each direction (HWY-011, divided edge bundling of Selassie, Heller and Heer 2011).
3684
+ * Each carriageway is a copy of the spine at an offset to the side of its traffic. The offset is half the lanes of that side plus half the gap.
3685
+ * When an offset spine is not clear of the boxes, the function tries one half and one quarter of the offset. It gives `undefined` when none fits.
3686
+ */
3687
+ export declare function divideHighway(h: Highway, finder: WayFinder, o: Readonly<Omit<DividedOptions, "from" | "margin" | "k">>): Highway[] | undefined;
3688
+ /**
3689
+ * This function gives the highways of the plan `from`, with each highway of two-way traffic divided into two carriageways (HWY-011).
3690
+ * The edges of each direction get their own spine on the side of the rule `rule`. Thus the two directions do not cross in the lanes.
3691
+ * A highway with fewer than `minSize` edges in one direction, or without the room for the offsets, stays as it is.
3692
+ */
3693
+ export declare function dividedPlan(input: HighwayInput, o: Readonly<DividedOptions>): HighwayPlan;
3694
+ /** The trees of sections that the strategy `hierarchy` can use. */
3695
+ type HierarchyGroups = "quadtree" | "kd" | "cut";
3696
+ /** The values of `HierarchyGroups`. */
3697
+ export declare const HIERARCHY_GROUPS: readonly HierarchyGroups[];
3698
+ /** The options of the highway strategy `hierarchy` (HWY-001 of the notes). */
3699
+ interface HierarchyOptions extends Pick<WayOptions, "margin" | "k"> {
3700
+ /** The tree of sections. The default is `quadtree`. */
3701
+ readonly group: HierarchyGroups;
3702
+ /** A section with more nodes splits. The default is 8. */
3703
+ readonly cap: number;
3704
+ /** The pull of the hubs, from 0 to 1 (Holten 2006). The value 0 gives the straight line, and 1 goes through each hub. The default is 0.85. */
3705
+ readonly beta: number;
3706
+ /** The largest number of hubs on each side of the lowest common section. `Infinity` uses all of them. The default is `Infinity`. */
3707
+ readonly hubs: number;
3708
+ /** The side of the grid that the hubs snap to, in units of the board. The default is 8. */
3709
+ readonly snap: number;
3710
+ /** A highway has this number of edges or more. The default is 2. */
3711
+ readonly minSize: number;
3712
+ }
3713
+ /** The default options of the strategy `hierarchy`. */
3714
+ export declare const HIERARCHY_DEFAULTS: Readonly<Required<Omit<HierarchyOptions, "margin" | "k">>>;
3715
+ /**
3716
+ * This function gives the control points of one edge. They are the sections from the leaf of the source up to the lowest common section, then down to the target leaf.
3717
+ * The lowest common section is not in the chain (Holten 2006), so the edges do not all meet at the hub of the root.
3718
+ * `hubs` limits the sections on each side. The sections nearest to the common section stay.
3719
+ */
3720
+ export declare function controlChain(from: readonly Section[], to: readonly Section[], hubs: number): Section[];
3721
+ /**
3722
+ * This function gives the highways of the hierarchical edge bundling (HWY-001, Holten 2006).
3723
+ * The tree of sections gives a hub to each section. Each edge goes near the hubs of the sections between its two leaves.
3724
+ * The waypoint of a hub is `beta hub + (1 - beta) p`, with `p` the point of the straight line at the same share of the chain.
3725
+ * The waypoints snap to a grid of side `snap`, and the ways go through the corner graph. The stretches that `minSize` ways share become highways.
3726
+ */
3727
+ export declare function hierarchyPlan(input: HighwayInput, o: Readonly<HierarchyOptions>): HighwayPlan;
3728
+ /** The options of the highway strategy `fdeb` (HWY-002 with RULE-002 of the notes). */
3729
+ interface FdebOptions extends Pick<WayOptions, "margin" | "k"> {
3730
+ /** Two edges attract each other when their compatibility is this value or more. The default is 0.6. */
3731
+ readonly compatibility: number;
3732
+ /** The spring constant that keeps each edge smooth. The default is 0.1. */
3733
+ readonly spring: number;
3734
+ /** The number of cycles. Each cycle doubles the points of each edge and halves the step. The default is 5. */
3735
+ readonly cycles: number;
3736
+ /** The number of steps of the first cycle. Each later cycle has two thirds of the steps of the cycle before it. The default is 50. */
3737
+ readonly iterations: number;
3738
+ /** The weight of the push of the boxes (RULE-002). The value 0 turns it off. The default is 1. */
3739
+ readonly repulsion: number;
3740
+ /**
3741
+ * The stretch budget of each edge (RULE-002). An edge whose polyline is longer than this value times its straight line gets no pull.
3742
+ * `Infinity` sets no budget. The default is 1.25.
3743
+ */
3744
+ readonly pullLimit: number;
3745
+ /** The side of the grid that the points of the edges snap to after the cycles, in units of the board. The default is 8. */
3746
+ readonly snap: number;
3747
+ /** A highway has this number of edges or more. The default is 2. */
3748
+ readonly minSize: number;
3749
+ }
3750
+ /** The default options of the strategy `fdeb`. */
3751
+ export declare const FDEB_DEFAULTS: Readonly<Required<Omit<FdebOptions, "margin" | "k">>>;
3752
+ /**
3753
+ * This function gives the polylines of the force-directed edge bundling (HWY-002, Holten and van Wijk 2009), with the box field of RULE-002.
3754
+ * Each edge starts as the straight line between its two points out of the plugs. Each cycle doubles its points.
3755
+ * In each step, a point moves by `step` times the mean pull to the matching points of its partners. The springs to its two neighbours also move it.
3756
+ * The boxes push the points, and after each cycle a point in a box moves out of it. An edge over its stretch budget gets no pull in that step.
3757
+ */
3758
+ export declare function fdebLines(input: HighwayInput, finder: WayFinder, o: Readonly<FdebOptions>): Map<string, Point[]>;
3759
+ /**
3760
+ * This function gives the highways of the force-directed edge bundling (HWY-002 with RULE-002).
3761
+ * The points of the bundled polylines snap to a grid of side `snap`, so the points of one bundle come together.
3762
+ * Each edge then goes through its points along the corner graph, and the stretches that `minSize` edges share become highways.
3763
+ */
3764
+ export declare function fdebPlan(input: HighwayInput, o: Readonly<FdebOptions>): HighwayPlan;
3765
+ /** The options of the highway strategy `mesh` (HWY-004 of the notes). */
3766
+ interface MeshOptions extends Pick<WayOptions, "margin" | "k"> {
3767
+ /** The side of a cell of the mesh, in units of the boxes: the median of the smaller side of each box. The default is 4. */
3768
+ readonly cell: number;
3769
+ /** A cluster of crossings on one segment of the mesh has at most about this number of edges. The default is 8. */
3770
+ readonly capacity: number;
3771
+ /** Two clusters nearer than this value, in units of the boxes, become one. The default is 1. */
3772
+ readonly merge: number;
3773
+ /** The largest angle in degrees between a line and the main direction of a cell. A line with a larger angle does not cross the mesh there. The default is 45. */
3774
+ readonly angle: number;
3775
+ /** A highway has this number of edges or more. The default is 2. */
3776
+ readonly minSize: number;
3777
+ }
3778
+ /** The default options of the strategy `mesh`. */
3779
+ export declare const MESH_DEFAULTS: Readonly<Required<Omit<MeshOptions, "margin" | "k">>>;
3780
+ /** This function gives the median of the smaller side of each box of the graph, or 1 for a graph without boxes. */
3781
+ export declare function boxUnit(graph: Graph): number;
3782
+ /** This function gives the clusters of the values by a 1D k-means with `k` centres, then joins the centres nearer than `merge`. The result gives the centre of each value. */
3783
+ export declare function clusters1d(values: readonly number[], k: number, merge: number): number[];
3784
+ /**
3785
+ * This function gives the waypoints of the control mesh (HWY-004, GBEC of Cui, Zhou, Qu, Wong and Li 2008).
3786
+ * A grid of cells covers the board. The main direction of each cell is the peak of a histogram of the angles of the straight lines through it.
3787
+ * The segment of the mesh in a cell goes through its middle, across that direction. The crossings of the lines with the segment form clusters by a 1D k-means.
3788
+ * The centre of the cluster of each crossing is a waypoint of its edge. The waypoints of an edge are in the order of the edge.
3789
+ */
3790
+ export declare function meshWaypoints(input: HighwayInput, finder: WayFinder, o: Readonly<MeshOptions>): Map<string, Point[]>;
3791
+ /**
3792
+ * This function gives the highways of the control mesh (HWY-004). Each edge goes through the centres of its clusters on the mesh, along the corner graph.
3793
+ * The centres of one cluster are one point, so the edges of a cluster share the ways between them. The stretches that `minSize` ways share become highways.
3794
+ */
3795
+ export declare function meshPlan(input: HighwayInput, o: Readonly<MeshOptions>): HighwayPlan;
3796
+ /**
3797
+ * The way to compute the density from the sample points. `direct` adds a Gaussian at each sample point (KDEEB).
3798
+ * `separable` counts the points in the cells and blurs the counts along x, then along y (CUBu). `fft` blurs the counts with a product of Fourier transforms (FFTEB).
3799
+ */
3800
+ type DensityKernel = "direct" | "separable" | "fft";
3801
+ /** The values of `DensityKernel`. */
3802
+ export declare const DENSITY_KERNELS: readonly DensityKernel[];
3803
+ /** The lines that make the first density: the straight lines of the edges, or their first routes. */
3804
+ type DensitySource = "lines" | "routes";
3805
+ /** The options of the highway strategy `kdeeb` (RULE-028 with HWY-006 of the notes). */
3806
+ interface KdeebOptions extends Pick<WayOptions, "margin" | "k"> {
3807
+ /** The lines of the first density. The default is `lines`. */
3808
+ readonly source: DensitySource;
3809
+ /** The side of a cell of the density image, in units of the board. The default is 8. A large board gets larger cells, up to 512 cells on a side. */
3810
+ readonly cell: number;
3811
+ /** The width of the kernel at the first step, in units of the board. The default is 24. */
3812
+ readonly bandwidth: number;
3813
+ /** Each step multiplies the width of the kernel by this value. The default is 0.7. */
3814
+ readonly decay: number;
3815
+ /** The number of steps. The default is 10. */
3816
+ readonly steps: number;
3817
+ /** The share of the Laplacian smoothing of each polyline after each step, from 0 to 1. The default is 0.5. */
3818
+ readonly smoothing: number;
3819
+ /** With this option, the density is 0 in the boxes, so no ridge forms over a box (RULE-028). The default is `true`. */
3820
+ readonly mask: boolean;
3821
+ /** The side of the grid that the points of the edges snap to after the steps, in units of the board. The default is 8. */
3822
+ readonly snap: number;
3823
+ /** A highway has this number of edges or more. The default is 2. */
3824
+ readonly minSize: number;
3825
+ }
3826
+ /** The default options of the strategy `kdeeb`. */
3827
+ export declare const KDEEB_DEFAULTS: Readonly<Required<Omit<KdeebOptions, "margin" | "k">>>;
3828
+ /** The settings of the advection that the strategies `kdeeb` and `cubu` share. */
3829
+ interface AdvectionSettings {
3830
+ /** The way to compute the density. */
3831
+ readonly kernel: DensityKernel;
3832
+ /** The spacing of the sample points after each step, in units of the board. The value 0 keeps the points where they are. */
3833
+ readonly resample: number;
3834
+ }
3835
+ /** A grid of cells over the board: its size, the side of a cell, and the place of its first cell. */
3836
+ interface DensityGrid {
3837
+ readonly w: number;
3838
+ readonly h: number;
3839
+ readonly cell: number;
3840
+ readonly x0: number;
3841
+ readonly y0: number;
3842
+ }
3843
+ /** This function gives the fast Fourier transform of a row of `n` complex values in place, with `n` a power of 2. `inverse` gives the inverse without the division by `n`. */
3844
+ export declare function fft(re: Float64Array, im: Float64Array, inverse?: boolean): void;
3845
+ /** This function gives the density of the points on the grid with the kernel `kernel` of the width `bandwidth` in units of the board. */
3846
+ export declare function pointDensity(points: readonly Point[], g: DensityGrid, bandwidth: number, kernel: DensityKernel): Float64Array;
3847
+ /**
3848
+ * This function gives the polylines of the density bundling (KDEEB, Hurter, Ersoy and Telea 2012). The ends of each polyline stay.
3849
+ * In each step, the sample points of all edges make a density. Each inner point moves `h / 4` up the gradient of the density, with `h` the width of the kernel.
3850
+ * The width then shrinks by `decay`, so the edges gather into ridges. A Laplacian smoothing keeps each polyline smooth.
3851
+ * With `mask`, the density is 0 in the boxes (RULE-028), and a point in a box moves out of it.
3852
+ */
3853
+ export declare function kdeebLines(input: HighwayInput, finder: WayFinder, o: Readonly<KdeebOptions>, settings: Readonly<AdvectionSettings>): Map<string, Point[]>;
3854
+ /** This function gives the highways of the bundled polylines of `kdeebLines`. The points snap to a grid of side `snap`, and the ways go through the corner graph. */
3855
+ export declare function densityPlan(input: HighwayInput, o: Readonly<KdeebOptions>, settings: Readonly<AdvectionSettings>, key: string): HighwayPlan;
3856
+ /**
3857
+ * This function gives the highways of the density bundling with a mask of the free space (RULE-028 with HWY-006).
3858
+ * The kernel is direct: each sample point adds a Gaussian. The final ridges of the polylines become the highways.
3859
+ */
3860
+ export declare function kdeebPlan(input: HighwayInput, o: Readonly<KdeebOptions>): HighwayPlan;
3861
+ /** The options of the highway strategy `cubu` (HWY-007 of the notes). */
3862
+ interface CubuOptions extends KdeebOptions {
3863
+ /** The way to compute the density: `separable` (CUBu) or `fft` (FFTEB). The default is `separable`. */
3864
+ readonly kernel: Exclude<DensityKernel, "direct">;
3865
+ /** The spacing of the sample points after each step, in units of the board. The value 0 keeps the points. The default is 8. */
3866
+ readonly resample: number;
3867
+ }
3868
+ /** The default options of the strategy `cubu`. */
3869
+ export declare const CUBU_DEFAULTS: Readonly<Required<Omit<CubuOptions, "margin" | "k">>>;
3870
+ /**
3871
+ * This function gives the highways of the fast density bundling (HWY-007: CUBu of van der Zwan, Codreanu and Telea 2016, and FFTEB of Lhuillier, Hurter and Telea 2017).
3872
+ * The steps are those of `kdeeb`, with the mask of the boxes. The density comes from the counts of the cells, blurred by a separable kernel or by a Fourier transform.
3873
+ * The sample points of each edge are spaced again after each step.
3874
+ */
3875
+ export declare function cubuPlan(input: HighwayInput, o: Readonly<CubuOptions>): HighwayPlan;
3876
+ /** The local fit of the moving least squares: a line, or a parabola in the frame of the line. */
3877
+ type MlsFit = "line" | "parabola";
3878
+ /** The values of `MlsFit`. */
3879
+ export declare const MLS_FITS: readonly MlsFit[];
3880
+ /** The options of the highway strategy `mlseb` (HWY-008 of the notes). */
3881
+ interface MlsebOptions extends Pick<WayOptions, "margin" | "k"> {
3882
+ /** The first lines of the edges: their straight lines, or their first routes. The default is `lines`. */
3883
+ readonly source: DensitySource;
3884
+ /** The radius of the fit at the first step, as a multiple of `boardUnit`: the median short side of the boxes. The default is 2. */
3885
+ readonly radius: number;
3886
+ /** Each step multiplies the radius by this value. The default is 0.8. */
3887
+ readonly decay: number;
3888
+ /** The number of steps. The default is 6. */
3889
+ readonly steps: number;
3890
+ /** The local fit. The default is `line`. */
3891
+ readonly fit: MlsFit;
3892
+ /** The weight of the angle, from 0 to 1. With 1, a sample at a right angle to the point has no weight. The default is 1. */
3893
+ readonly angleWeight: number;
3894
+ /** The spacing of the sample points of each edge, in units of the board. The default is 8. */
3895
+ readonly spacing: number;
3896
+ /** The side of the grid that the points of the edges snap to after the steps, in units of the board. The default is 8. */
3897
+ readonly snap: number;
3898
+ /** A highway has this number of edges or more. The default is 2. */
3899
+ readonly minSize: number;
3900
+ }
3901
+ /** The default options of the strategy `mlseb`. */
3902
+ export declare const MLSEB_DEFAULTS: Readonly<Required<Omit<MlsebOptions, "margin" | "k">>>;
3903
+ /** One sample point of an edge, with the unit tangent of its edge there. */
3904
+ interface Sample {
3905
+ readonly p: Point;
3906
+ readonly tx: number;
3907
+ readonly ty: number;
3908
+ }
3909
+ /**
3910
+ * This function gives the point of the moving least squares fit at the point `p`. The weight of a sample `q` is `exp(-|q-p|^2 / r^2)`.
3911
+ * The angle term multiplies it by `1 - a + a |cos|`, with `cos` the cosine of the angle between the two tangents.
3912
+ * The fit `line` gives the projection of `p` on the weighted line of the samples. The fit `parabola` fits `s = c0 + c1 t + c2 t^2` in the frame of that line.
3913
+ * Without weight, the function gives `p`.
3914
+ */
3915
+ export declare function mlsPoint(p: Point, t: {
3916
+ tx: number;
3917
+ ty: number;
3918
+ }, near: readonly Sample[], r: number, angleWeight: number, fit: MlsFit): Point;
3919
+ /**
3920
+ * This function gives the polylines of the moving least squares bundling (MLSEB, Wu, Zeng, Zhu and Yu 2017). The ends of each polyline stay.
3921
+ * In each step, each inner point moves to the local fit of the samples of all edges within the radius. Then the radius shrinks by `decay`.
3922
+ * A move is at most the radius. A point in a box moves out of it.
3923
+ */
3924
+ export declare function mlsebLines(input: HighwayInput, finder: WayFinder, o: Readonly<MlsebOptions>): Map<string, Point[]>;
3925
+ /**
3926
+ * This function gives the highways of the moving least squares bundling (HWY-008). The points of `mlsebLines` snap to a grid of side `snap`.
3927
+ * The ways go through the corner graph, and each stretch that `minSize` ways share is a highway.
3928
+ */
3929
+ export declare function mlsebPlan(input: HighwayInput, o: Readonly<MlsebOptions>): HighwayPlan;
3930
+ /** The clusterer that gives the groups of edges: QuickBundles (HWY-026) with its defaults, or the collection of each edge. */
3931
+ type SkeletonGroups = "quickbundles" | "keys";
3932
+ /** The values of `SkeletonGroups`. */
3933
+ export declare const SKELETON_GROUPS: readonly SkeletonGroups[];
3934
+ /** The point that each sample point moves toward: the nearest point of the skeleton of its group, or of the mean polyline of its group. */
3935
+ type SkeletonTarget = "skeleton" | "mean";
3936
+ /** The values of `SkeletonTarget`. */
3937
+ export declare const SKELETON_TARGETS: readonly SkeletonTarget[];
3938
+ /** The options of the highway strategy `sbeb` (HWY-009 of the notes). */
3939
+ interface SbebOptions extends Pick<WayOptions, "margin" | "k"> {
3940
+ /** The clusterer of the groups. The default is `quickbundles`. */
3941
+ readonly group: SkeletonGroups;
3942
+ /** The first lines of the edges: their straight lines, or their first routes. The default is `lines`. */
3943
+ readonly source: DensitySource;
3944
+ /** The radius of the shape of a group, as a multiple of `boardUnit`. The default is 1.5. */
3945
+ readonly radius: number;
3946
+ /** The share of the distance to the target that a point moves in one step, from 0 to 1. The default is 0.5. */
3947
+ readonly attraction: number;
3948
+ /** The number of steps. The default is 4. */
3949
+ readonly steps: number;
3950
+ /** The share of the Laplacian smoothing of each polyline after each step, from 0 to 1. The default is 0.5. */
3951
+ readonly smoothing: number;
3952
+ /** The target of the points. The default is `skeleton`. */
3953
+ readonly target: SkeletonTarget;
3954
+ /** The side of a cell of the image of the shape, in units of the board. A large shape gets larger cells, up to 256 cells on a side. The default is 4. */
3955
+ readonly cell: number;
3956
+ /** The side of the grid that the points of the edges snap to after the steps, in units of the board. The default is 8. */
3957
+ readonly snap: number;
3958
+ /** A group with this number of edges or more moves, and a highway has this number of edges or more. The default is 2. */
3959
+ readonly minSize: number;
3960
+ }
3961
+ /** The default options of the strategy `sbeb`. */
3962
+ export declare const SBEB_DEFAULTS: Readonly<Required<Omit<SbebOptions, "margin" | "k">>>;
3963
+ /** This function gives the group of each edge: the clusters of QuickBundles, or the collection of the edge. An edge without a collection has no group with `keys`. */
3964
+ export declare function skeletonGroups(input: HighwayInput, group: SkeletonGroups): Map<string, EdgeGroup>;
3965
+ /** This function gives the first line of each edge. The line goes from a point at `margin` out of the source plug to a point at `margin` out of the target plug. */
3966
+ export declare function firstLines(input: HighwayInput, finder: WayFinder, source: DensitySource, spacing: number): Map<string, Point[]>;
3967
+ /** The image of the shape of a group and its skeleton. */
3968
+ interface ShapeSkeleton {
3969
+ readonly grid: DensityGrid;
3970
+ /** The distance of each cell to the nearest cell outside the shape, in cells. A cell outside the shape has 0. */
3971
+ readonly depth: Float64Array;
3972
+ /** The value is 1 for each cell of the skeleton. */
3973
+ readonly skeleton: Uint8Array;
3974
+ }
3975
+ /**
3976
+ * This function gives the shape of a group and its skeleton (its medial axis). The shape is the union of the disks of radius `radius` along the lines, minus the boxes.
3977
+ * The depth is a chamfer distance transform with the steps 1 and √2. A cell is on the skeleton when two conditions are true.
3978
+ * Its depth is half of `radius` or more. Its depth is a ridge along one of the four pairs of opposite neighbours.
3979
+ * A ridge is not lower than the two neighbours, and it is higher than one of them.
3980
+ */
3981
+ export declare function shapeSkeleton(lines: readonly (readonly Point[])[], finder: WayFinder, radius: number, cell: number): ShapeSkeleton;
3982
+ /** This function gives the middle of the skeleton cell nearest to `p`, within `reach` in units of the board, or `undefined`. */
3983
+ export declare function nearestSkeleton(s: ShapeSkeleton, p: Point, reach: number): Point | undefined;
3984
+ /** This function gives the mean polyline of lines in one direction, with `k` points. */
3985
+ export declare function meanLine(lines: readonly (readonly Point[])[], k: number): Point[];
3986
+ /** This function gives the point of a polyline nearest to `p`. */
3987
+ export declare function nearestOnLine(line: readonly Point[], p: Point): Point;
3988
+ /** This function gives the groups with `min` edges or more, as lists of edges. The groups are in the order of their first edges. */
3989
+ export declare function bigGroups(groups: ReadonlyMap<string, EdgeGroup>, min: number): {
3990
+ key: string;
3991
+ edges: {
3992
+ edge: string;
3993
+ flip: boolean;
3994
+ }[];
3995
+ }[];
3996
+ /**
3997
+ * This function gives the polylines of the skeleton-based edge bundling (SBEB, Ersoy, Hurter, Paulovich, Cantareiro and Telea 2011). The ends of each polyline stay.
3998
+ * In each step, each group of `minSize` edges or more draws its shape, and each inner point moves the share `attraction` toward its target.
3999
+ * The share falls to 0 at the distance `2 radius`. A Laplacian smoothing keeps each polyline smooth, and a point in a box moves out of it.
4000
+ * The edges outside such a group do not move.
4001
+ */
4002
+ export declare function sbebLines(input: HighwayInput, finder: WayFinder, o: Readonly<SbebOptions>): Map<string, Point[]>;
4003
+ /**
4004
+ * This function gives the highways of the skeleton-based edge bundling (HWY-009). The points of `sbebLines` snap to a grid of side `snap`.
4005
+ * The ways go through the corner graph, and each stretch that `minSize` ways share is a highway.
4006
+ */
4007
+ export declare function sbebPlan(input: HighwayInput, o: Readonly<SbebOptions>): HighwayPlan;
4008
+ /** The rule of the half width of an area: the spread of the edges of the group, or the number of its lanes. */
4009
+ type AreaWidth = "spread" | "count";
4010
+ /** The values of `AreaWidth`. */
4011
+ export declare const AREA_WIDTHS: readonly AreaWidth[];
4012
+ /** The options of the highway strategy `areas` (HWY-010 of the notes). */
4013
+ interface AreaOptions extends Pick<WayOptions, "margin" | "k"> {
4014
+ /** The clusterer of the groups. The default is `quickbundles`. */
4015
+ readonly group: SkeletonGroups;
4016
+ /** The lines of the edges that make the shape: their straight lines, or their first routes. The default is `lines`. */
4017
+ readonly source: DensitySource;
4018
+ /** The radius of the shape of a group, as a multiple of `boardUnit`. The default is 1.5. */
4019
+ readonly radius: number;
4020
+ /** The rule of the half width of the area. The default is `spread`. */
4021
+ readonly width: AreaWidth;
4022
+ /** The width of one lane for the rule `count`, in units of the board. The default is 4. */
4023
+ readonly laneWidth: number;
4024
+ /** The side of a cell of the image of the shape, in units of the board. The default is 4. */
4025
+ readonly cell: number;
4026
+ /** A highway has this number of edges or more. The default is 2. */
4027
+ readonly minSize: number;
4028
+ }
4029
+ /** The default options of the strategy `areas`. */
4030
+ export declare const AREA_DEFAULTS: Readonly<Required<Omit<AreaOptions, "margin" | "k">>>;
4031
+ /**
4032
+ * This function gives the longest path of the largest part of a skeleton, as the middles of its cells. The neighbours of a cell are its 8 neighbours.
4033
+ * The function finds the cell farthest from a first cell, then the cell farthest from that cell. A skeleton without cells gives an empty list.
4034
+ */
4035
+ export declare function skeletonPath(s: ShapeSkeleton): Point[];
4036
+ /**
4037
+ * This function gives the highways of the image-based edge bundles (HWY-010, Telea and Ersoy 2010). Each group of edges is one area with one spine.
4038
+ * The spine goes through the corner graph between the two ends of the longest path of the skeleton of the shape of the group.
4039
+ * The area is the skeleton path with a half width. With `spread`, the half width is the 90th percentile of the distances of the points to the path.
4040
+ * With `count`, it is the number of lanes times half of `laneWidth`. The half width is at least the margin.
4041
+ * An edge joins the spine where its line first goes into the area. It leaves the spine where its line last comes out of the area.
4042
+ */
4043
+ export declare function areaPlan(input: HighwayInput, o: Readonly<AreaOptions>): HighwayPlan;
4044
+ /** The edges that one group can hold: the edges of one collection, or each edge. */
4045
+ type GroupScope = "collection" | "all";
4046
+ /** The values of `GroupScope`. */
4047
+ export declare const GROUP_SCOPES: readonly GroupScope[];
4048
+ /** The options of the highway strategy `confluent` (HWY-013 of the notes). */
4049
+ interface ConfluentOptions extends Pick<WayOptions, "margin" | "k"> {
4050
+ /** A biclique `K(A, B)` becomes a track when `|A| |B|` is this value or more. The default is 4. */
4051
+ readonly minBiclique: number;
4052
+ /** The edges of one track. With `collection`, a track holds the edges of one collection, and an edge without a collection is on no track. The default is `all`. */
4053
+ readonly scope: GroupScope;
4054
+ /** The spine of each track. The default is `trunk`: one trunk from the merge junction to the split junction. */
4055
+ readonly spine: GroupSpine;
4056
+ /** An edge rides the trunk only when each of its legs is this share of the trunk or shorter. `Infinity` sets no limit. The default is 1. */
4057
+ readonly legMax: number;
4058
+ }
4059
+ /** The default options of the strategy `confluent`. */
4060
+ export declare const CONFLUENT_DEFAULTS: Readonly<Required<Omit<ConfluentOptions, "margin" | "k">>>;
4061
+ /** The edges between pairs of nodes of one scope: for each node, its neighbours and the edges to each of them. */
4062
+ interface NodeLinks {
4063
+ /** The key of the scope. */
4064
+ readonly key: string;
4065
+ /** For each node, the edges to each neighbour, by the id of the neighbour. */
4066
+ readonly links: Map<string, Map<string, string[]>>;
4067
+ }
4068
+ /** This function gives the links of each scope. A loop (an edge from a node to itself) is not a link. The order of the maps follows the order of the edges. */
4069
+ export declare function nodeLinks(graph: Graph, scope: GroupScope): NodeLinks[];
4070
+ /** A biclique: the two sets of nodes, with a link from each node of `a` to each node of `b`. */
4071
+ interface Biclique {
4072
+ readonly a: readonly string[];
4073
+ readonly b: readonly string[];
4074
+ }
4075
+ /**
4076
+ * This function gives the bicliques of a greedy search (HWY-013). Each search starts at one node `x` with `A = {x}` and `B` its neighbours.
4077
+ * It then adds to `A` the node that gives the largest `|A| |B|`, with `B` cut to the common neighbours, while the product grows.
4078
+ * The best biclique of all starts with `|A| |B| >= min` becomes a track, its links go away, and the search repeats.
4079
+ * The nodes of `A` and `B` are apart. The largest set is `b`.
4080
+ */
4081
+ export declare function greedyBicliques(links: Map<string, Map<string, string[]>>, min: number): Biclique[];
4082
+ /**
4083
+ * This function gives the group of each edge of a set of bicliques. The edges of one biclique are one group, with the key `<prefix><scope>/<index>`.
4084
+ * An edge from a node of `b` to a node of `a` has `flip`. Thus each trunk goes from the side `a` to the side `b`.
4085
+ */
4086
+ export declare function bicliqueGroups(graph: Graph, scope: NodeLinks, bicliques: readonly Biclique[], prefix: string, into: Map<string, EdgeGroup>): void;
4087
+ /**
4088
+ * This function gives the highways of the confluent drawing (HWY-013, Dickerson, Eppstein, Goodrich and Meng 2005).
4089
+ * Each biclique `K(A, B)` of the greedy search is one track. The track merges the edges near the side `A` and splits them near the side `B`.
4090
+ * The junctions are the Weber points of the ends, as in the spine `trunk` of `groupedPlan`.
4091
+ */
4092
+ export declare function confluentPlan(input: HighwayInput, o: Readonly<ConfluentOptions>): HighwayPlan;
4093
+ /** The rule of a module: the nodes with the same neighbours (`exact`), or with near neighbours by the Jaccard index (`near`). */
4094
+ type ModuleRule = "exact" | "near";
4095
+ /** The values of `ModuleRule`. */
4096
+ export declare const MODULE_RULES: readonly ModuleRule[];
4097
+ /** The options of the highway strategy `power` (HWY-014 of the notes). */
4098
+ interface PowerOptions extends Pick<WayOptions, "margin" | "k"> {
4099
+ /** The rule of the modules. The default is `exact`. */
4100
+ readonly modules: ModuleRule;
4101
+ /** With the rule `near`, a node joins a module at this Jaccard index or more with the first node of the module. The default is 0.8. */
4102
+ readonly jaccard: number;
4103
+ /** A power edge saves the number of its edges less 1. It becomes a highway when it saves this number of edges or more. The default is 2. */
4104
+ readonly minSaved: number;
4105
+ /** The edges of one power edge. With `collection`, a power edge holds the edges of one collection. The default is `all`. */
4106
+ readonly scope: GroupScope;
4107
+ /** The spine of each power edge. The default is `trunk`. */
4108
+ readonly spine: GroupSpine;
4109
+ /** An edge rides the trunk only when each of its legs is this share of the trunk or shorter. `Infinity` sets no limit. The default is 1. */
4110
+ readonly legMax: number;
4111
+ }
4112
+ /** The default options of the strategy `power`. */
4113
+ export declare const POWER_DEFAULTS: Readonly<Required<Omit<PowerOptions, "margin" | "k">>>;
4114
+ /** This function gives the Jaccard index of two sets: the size of their common part over the size of their union. Two empty sets give 1. */
4115
+ export declare function jaccardIndex(a: ReadonlySet<string>, b: ReadonlySet<string>): number;
4116
+ /**
4117
+ * This function gives the module of each node. With `exact`, the nodes with the same set of neighbours are one module.
4118
+ * With `near`, the nodes go in the order of their degree, the largest first. A node joins the first module whose first node has a Jaccard index of `jaccard` or more with it.
4119
+ * The function gives the modules as lists of nodes, each in the order of the ids.
4120
+ */
4121
+ export declare function modulesOf(links: ReadonlyMap<string, ReadonlyMap<string, readonly string[]>>, rule: ModuleRule, jaccard: number): string[][];
4122
+ /**
4123
+ * This function gives the highways of the edge compression with modules and power graphs (HWY-014, Dwyer, Henry Riche, Marriott and Mears 2013).
4124
+ * The edges between two modules are one power edge. With modules of the rule `exact`, each node of one module links to each node of the other.
4125
+ * A power edge that saves `minSaved` edges or more is one highway from module to module.
4126
+ * Its trunk goes between the Weber points of the two ends.
4127
+ * The search does not nest modules, so it finds no power edge inside a power edge.
4128
+ */
4129
+ export declare function powerPlan(input: HighwayInput, o: Readonly<PowerOptions>): HighwayPlan;
4130
+ /** The options of the highway strategy `crossbars` (HWY-022 of the notes). */
4131
+ interface CrossbarOptions extends Pick<WayOptions, "margin" | "k"> {
4132
+ /** The plan that gets the bundled crossings. Only the edges outside its highways can be on a crossbar. The default is `shared-ways`. */
4133
+ readonly from: HighwayBase;
4134
+ /** Two segments are parallel when the angle between them is this value or less, in degrees. The default is 15. */
4135
+ readonly tolerance: number;
4136
+ /** Each side of a crossbar has this number of edges or more. The default is 2. */
4137
+ readonly minBar: number;
4138
+ /** The crossings of one crossbar are this distance or nearer to its first crossing, as a multiple of `boardUnit`. The default is 3. */
4139
+ readonly reach: number;
4140
+ }
4141
+ /** The default options of the strategy `crossbars`. */
4142
+ export declare const CROSSBAR_DEFAULTS: Readonly<Required<Omit<CrossbarOptions, "margin" | "k">>>;
4143
+ /** One crossing of two routes: the edges, the point and the unit directions of the two segments there. */
4144
+ interface RouteCrossing {
4145
+ readonly e: string;
4146
+ readonly f: string;
4147
+ readonly p: Point;
4148
+ readonly de: Point;
4149
+ readonly df: Point;
4150
+ }
4151
+ /** This function gives each crossing of two routes of the list, in the order of the list. */
4152
+ export declare function routeCrossings(routes: readonly {
4153
+ readonly edge: string;
4154
+ readonly points: readonly Point[];
4155
+ }[]): RouteCrossing[];
4156
+ /** A crossbar: two sets of edges, with a crossing of each edge of `p` with each edge of `q` near one place. */
4157
+ interface Crossbar {
4158
+ readonly p: readonly string[];
4159
+ readonly q: readonly string[];
4160
+ /** The mean point of the crossings of the crossbar. */
4161
+ readonly at: Point;
4162
+ /** The mean direction of the side `p`, and of the side `q`. */
4163
+ readonly dp: Point;
4164
+ readonly dq: Point;
4165
+ }
4166
+ /**
4167
+ * This function gives the crossbars of a greedy search (HWY-022, after Fink, Hershberger, Suri and Verbeek 2016).
4168
+ * The search starts at each crossing in order. It grows the two sides while each new edge crosses each edge of the other side near the start, at the same angles.
4169
+ * A crossbar with `minBar` edges or more on each side is kept. Each edge is on one crossbar at most.
4170
+ */
4171
+ export declare function greedyCrossbars(crossings: readonly RouteCrossing[], reach: number, tolDeg: number, minBar: number): Crossbar[];
4172
+ /**
4173
+ * This function gives the highways of the bundled crossings (HWY-022). The edges outside the highways of the plan `from` keep their routes after `follow`.
4174
+ * Each crossbar of those routes gives two highways, one for each side. Each spine is a line through the mean crossing, along the mean direction of its side.
4175
+ * It is `2 reach` long, and it goes through the corner graph. So each side crosses the other side at one place, as a bundle.
4176
+ * An edge joins the spine near the point of its route nearest to one end of the line. It leaves the spine near the other end.
4177
+ */
4178
+ export declare function crossbarPlan(input: HighwayInput, o: Readonly<CrossbarOptions>): HighwayPlan;
4179
+ /** The options of the highway strategy `frechet` (HWY-027 of the notes). */
4180
+ interface FrechetOptions extends Pick<WayOptions, "margin" | "k"> {
4181
+ /** Two parts of routes are one bundle when their discrete Fréchet distance is this value or less, as a multiple of `boardUnit`. The default is 1. */
4182
+ readonly eps: number;
4183
+ /** A bundle has this number of edges or more, with the reference edge. The default is 2. */
4184
+ readonly minSize: number;
4185
+ /** The reference part of a bundle is this length or longer, as a multiple of `boardUnit`. The default is 2. */
4186
+ readonly minLength: number;
4187
+ /** The distance between two samples of a route, as a multiple of `boardUnit`. The default is 0.5. */
4188
+ readonly step: number;
4189
+ /** A search starts at each sample of this number along each route. The default is 2. */
4190
+ readonly stride: number;
4191
+ }
4192
+ /** The default options of the strategy `frechet`. */
4193
+ export declare const FRECHET_DEFAULTS: Readonly<Required<Omit<FrechetOptions, "margin" | "k">>>;
4194
+ /** This function gives the points of a polyline at equal distances of `step` or less, with its first and its last point. */
4195
+ export declare function samplesOf(line: readonly Point[], step: number): Point[];
4196
+ /** The cells of one row of the free space that a monotone path reaches. Each cell is a sorted index of the other curve. */
4197
+ type Row = readonly number[];
4198
+ /**
4199
+ * This function gives the next row of the free space of the discrete Fréchet distance. The curve `q` has a free start and a free end.
4200
+ * A cell `(j, b)` is free when the distance of `p[j]` to `q[b]` is `eps` or less.
4201
+ * A path reaches a free cell from `(j - 1, b)`, `(j - 1, b - 1)` or `(j, b - 1)`.
4202
+ */
4203
+ export declare function nextRow(prev: Row, pj: Point, q: readonly Point[], eps: number): number[];
4204
+ /**
4205
+ * This function tells if a part of `q` has a discrete Fréchet distance of `eps` or less to the whole of `p`. The part of `q` is free to start and to end anywhere.
4206
+ * It uses the rows of `nextRow`.
4207
+ */
4208
+ export declare function partWithin(p: readonly Point[], q: readonly Point[], eps: number): boolean;
4209
+ /** One bundle of the search: the reference edge, the part of its samples, and the other edges with their sense. */
4210
+ interface FrechetBundle {
4211
+ readonly edge: string;
4212
+ readonly from: number;
4213
+ readonly to: number;
4214
+ readonly length: number;
4215
+ /** The other edges. `back` is true when the edge goes along the reference part in the reverse sense. */
4216
+ readonly members: readonly {
4217
+ readonly edge: string;
4218
+ readonly back: boolean;
4219
+ }[];
4220
+ }
4221
+ /**
4222
+ * This function gives the bundles of the search (HWY-027, after Buchin, Buchin, Gudmundsson, Löffler and Luo 2011, in a simple exact form).
4223
+ * For each reference route and each start sample (at each `stride`), it grows the reference part one sample at a time.
4224
+ * It keeps the other routes, in both senses, with a part at a discrete Fréchet distance of `eps` or less.
4225
+ * It stops when fewer than `minSize - 1` routes remain.
4226
+ * Each start gives the part with the best score: the number of edges times the length.
4227
+ * The search uses the discrete distance on samples only. It does not use the continuous distance or the full free space diagram.
4228
+ */
4229
+ export declare function frechetBundles(samples: ReadonlyMap<string, readonly Point[]>, eps: number, minSize: number, minLength: number, stride: number): FrechetBundle[];
4230
+ /**
4231
+ * This function gives the highways of the subtrajectory clusters of the first routes (HWY-027). The samples of each route leave out its two end points.
4232
+ * The bundles go in the order of their score, the best first. A bundle keeps the members whose part of the route is not on a bundle already.
4233
+ * The spine of a highway is the reference part. Each member rides the whole spine, in its own sense.
4234
+ */
4235
+ export declare function frechetPlan(input: HighwayInput, o: Readonly<FrechetOptions>): HighwayPlan;
4236
+ /** The options of the highway strategy `spectral` (HWY-029 of the note on highways). */
4237
+ interface SpectralOptions {
4238
+ /** Two edges are a pair of the graph only when their compatibility is this value or more. The default is 0.5. */
4239
+ readonly c0: number;
4240
+ /** The number of clusters of each part of the graph. The value 0 lets the largest eigengap choose it. The default is 0. */
4241
+ readonly clusters: number;
4242
+ /** The eigengap chooses at most this number of clusters in each part of the graph. The default is 16. */
4243
+ readonly kMax: number;
4244
+ /** A cluster with this number of edges or more gets highways. The default is 2. */
4245
+ readonly minSize: number;
4246
+ /** The spine of each cluster. The default is `trunk`: one trunk from one area to the other area. */
4247
+ readonly spine: GroupSpine;
4248
+ }
4249
+ /** The default options of the strategy `spectral`. */
4250
+ export declare const SPECTRAL_DEFAULTS: Readonly<SpectralOptions>;
4251
+ /** The ends of one edge of the board. */
4252
+ interface EdgeEnds {
4253
+ readonly edge: string;
4254
+ readonly s: Point;
4255
+ readonly t: Point;
4256
+ }
4257
+ /** This function gives the ends of each edge of the input: the points of its two plugs. */
4258
+ export declare function edgeEnds(input: HighwayInput): EdgeEnds[];
4259
+ /**
4260
+ * This function gives the eigenvalues and the eigenvectors of a symmetric matrix of `n` rows (the Householder steps and the QL steps of JAMA).
4261
+ * The values are in increasing order. The column `j` of `vectors` (the values `vectors[i * n + j]`) is the unit vector of the value `j`.
4262
+ */
4263
+ export declare function symmetricEigen(n: number, a: Float64Array): {
4264
+ values: Float64Array;
4265
+ vectors: Float64Array;
4266
+ };
4267
+ /**
4268
+ * This function puts the rows of a matrix of `n` rows and `k` columns into `k` clusters (the steps of Lloyd).
4269
+ * The first centre is row 0. Each next centre is the row farthest from the centres that exist. The result is the cluster of each row.
4270
+ */
4271
+ export declare function kMeans(n: number, k: number, rows: Float64Array, iterations?: number): Int32Array;
4272
+ /**
4273
+ * This function gives the spectral clusters of the points of a weight matrix (von Luxburg 2007, with the normalization of Ng, Jordan and Weiss).
4274
+ * Each connected part of the graph is one problem. `L_sym = I - D^-1/2 W D^-1/2`.
4275
+ * The number of clusters `k` of a part is `clusters`, or the place of the largest gap of the first `kMax + 1` eigenvalues.
4276
+ * The first `k` eigenvectors, with each row at the length 1, go into `kMeans`. The result is the cluster of each point, and -1 for a point with no pair.
4277
+ */
4278
+ export declare function spectralLabels(n: number, w: Float64Array, o: Readonly<Pick<SpectralOptions, "clusters" | "kMax">>): Int32Array;
4279
+ /** This function gives the matrix of the compatibility of the pairs of edges, with 0 for a pair below `c0`. Then a `scale` changes the value of each pair that stays. */
4280
+ export declare function compatibilityMatrix(ends: readonly EdgeEnds[], c0: number, scale?: (i: number, j: number) => number): Float64Array;
4281
+ /**
4282
+ * This function gives the edge groups of the clusters of the edges of one matrix. Each edge of a cluster gets `flip` when it goes opposite to the first edge of the cluster.
4283
+ * An edge with the label -1 gets no group.
4284
+ */
4285
+ export declare function labelGroups(ends: readonly EdgeEnds[], labels: Int32Array, prefix: string, groups: Map<string, EdgeGroup>): void;
4286
+ /** This function splits the edges into blocks of at most `BLOCK` edges, in the order of their sources. A small graph is one block. */
4287
+ export declare function edgeBlocks<T extends EdgeEnds>(ends: readonly T[]): T[][];
4288
+ /** This function gives the spectral clusters of the edges (HWY-029). A pair of edges is in the graph when its compatibility of FDEB is `c0` or more. */
4289
+ export declare function spectralClusters(input: HighwayInput, o: Readonly<SpectralOptions>): Map<string, EdgeGroup>;
4290
+ /**
4291
+ * This function gives the highways of the spectral clusters of the compatibility graph (HWY-029). The eigengap gives the number of highways of each part.
4292
+ * The clusters with `minSize` edges or more get highways.
4293
+ */
4294
+ export declare function spectralPlan(input: HighwayInput, o: Readonly<SpectralOptions>): HighwayPlan;
4295
+ /** The options of the highway strategy `resistance` (HWY-021 of the note on highways). */
4296
+ interface ResistanceOptions extends SpectralOptions {
4297
+ /** The number of random projections of the estimate of the resistance. The default is 16. */
4298
+ readonly projections: number;
4299
+ /** The weight of the resistance, from 0 to 1. A pair with `C >= c0` gets the weight `C (1 - weight R_e R_f)`. The default is 0.5. */
4300
+ readonly weight: number;
4301
+ /** With `true`, an edge with a resistance of 0.99 or more (a bridge) gets no pair. The default is `false`. */
4302
+ readonly sparsify: boolean;
4303
+ }
4304
+ /** The default options of the strategy `resistance`. */
4305
+ export declare const RESISTANCE_DEFAULTS: Readonly<ResistanceOptions>;
4306
+ /**
4307
+ * This function gives an estimate of the effective resistance of each edge of the graph (Spielman and Srivastava 2011).
4308
+ * It takes `k` random vectors `q` of the values `±1/√k` on the edges. It solves `L z = Bᵀ q` for each vector. Then `R(u, v) ≈ Σ (z_u - z_v)²`.
4309
+ * The value is from 0 to 1. A loop and an edge with an unknown node get 0. Parallel edges share the current, so each gets a lower value.
4310
+ */
4311
+ export declare function edgeResistance(graph: Graph, projections: number): Map<string, number>;
4312
+ /**
4313
+ * This function gives the clusters of the edges with the compatibility scaled by the resistance (HWY-021).
4314
+ * The compatibility of a pair is `C (1 - weight R_e R_f)`. A pair of two bridges thus gets a lower value. Then the spectral clusters of `spectral` apply.
4315
+ */
4316
+ export declare function resistanceClusters(input: HighwayInput, o: Readonly<ResistanceOptions>): Map<string, EdgeGroup>;
4317
+ /**
4318
+ * This function gives the highways of the spectral clusters of the compatibility graph with the weights of the effective resistance (HWY-021).
4319
+ * The clusters with `minSize` edges or more get highways.
4320
+ */
4321
+ export declare function resistancePlan(input: HighwayInput, o: Readonly<ResistanceOptions>): HighwayPlan;
4322
+ /** The options of the highway strategy `link-communities` (HWY-030 of the note on highways). */
4323
+ interface LinkCommunityOptions {
4324
+ /** The cut of the tree of the edges. The value 0 cuts at the best partition density. A value above 0 keeps the joins with this similarity or more. The default is 0. */
4325
+ readonly threshold: number;
4326
+ /** A community with this number of edges or more gets highways, after the check of the geometry. The default is 2. */
4327
+ readonly minSize: number;
4328
+ /** The largest distance of an end of an edge to the Weber point of its end of the community, in units of the board. The default is 6. */
4329
+ readonly spread: number;
4330
+ /** The spine of each community. The default is `shared`. */
4331
+ readonly spine: GroupSpine;
4332
+ }
4333
+ /** The default options of the strategy `link-communities`. */
4334
+ export declare const LINK_COMMUNITY_DEFAULTS: Readonly<LinkCommunityOptions>;
4335
+ /** The ends of one edge as node indices. */
4336
+ interface LinkEdge {
4337
+ readonly u: number;
4338
+ readonly v: number;
4339
+ }
4340
+ /**
4341
+ * This function gives the link communities of the edges: the single linkage of the edges by their similarity.
4342
+ * With `threshold` 0, the cut is at the level of the best partition density `D = (2/M) Σ m_c (m_c - n_c + 1) / ((n_c - 2)(n_c - 1))`.
4343
+ * When the best `D` is above 0, the first level with it applies. When it is 0 (a forest), the last level applies.
4344
+ * The result is the community of each edge, as the index of an edge of the community. A loop is alone.
4345
+ */
4346
+ export declare function linkCommunities(n: number, edges: readonly LinkEdge[], threshold: number): Int32Array;
4347
+ /**
4348
+ * This function gives the edge groups of the link communities (HWY-030). The hub of a community is its node with the most edges.
4349
+ * Each edge goes from its end at the hub, or else in the direction of the hub edges. The check of the geometry removes each edge with an end
4350
+ * farther than `spread` units from the Weber point of that end of the community. A community with fewer than `minSize` edges after the check gets no group.
4351
+ */
4352
+ export declare function linkCommunityGroups(input: HighwayInput, o: Readonly<LinkCommunityOptions>): Map<string, EdgeGroup>;
4353
+ /** This function gives the highways of the link communities of the line graph (HWY-030). Each community that passes the check of the geometry gets highways. */
4354
+ export declare function linkCommunityPlan(input: HighwayInput, o: Readonly<LinkCommunityOptions>): HighwayPlan;
4355
+ /** The characteristic points of the territories: the plugs, the bends of the first routes, or both. */
4356
+ type TerritoryPoints = "plugs" | "bends" | "both";
4357
+ /** The values of `TerritoryPoints`. */
4358
+ export declare const TERRITORY_POINTS: readonly TerritoryPoints[];
4359
+ /** The options of the highway strategy `territories` (HWY-033 of the note on highways). */
4360
+ interface TerritoryOptions {
4361
+ /** The radius of a group of points, in units of the board. The default is 4. */
4362
+ readonly radius: number;
4363
+ /** A flow between two cells becomes a highway when this number of edges or more cross it. The default is 2. */
4364
+ readonly minSize: number;
4365
+ /** The characteristic points. The default is `both`. */
4366
+ readonly points: TerritoryPoints;
4367
+ }
4368
+ /** The default options of the strategy `territories`. */
4369
+ export declare const TERRITORY_DEFAULTS: Readonly<TerritoryOptions>;
4370
+ /**
4371
+ * This function puts points into groups of the radius `r` (Andrienko and Andrienko 2011). Each point joins the group with the nearest centre within `r`.
4372
+ * Else it starts a new group. The centre of a group is the mean of its points. A second pass puts each point into the group of its nearest centre.
4373
+ * The result is the centres of the groups that keep points.
4374
+ */
4375
+ export declare function pointGroups(points: readonly Point[], r: number): Point[];
4376
+ /** This function gives the index of the centre nearest to `p`. The first of two equal centres wins. */
4377
+ export declare function nearestCentre(centres: readonly Point[], p: Point): number;
4378
+ /** One crossing of a route from the cell `from` into the cell `to`, at the share `at` of the length of the route. */
4379
+ interface CellStep {
4380
+ readonly from: number;
4381
+ readonly to: number;
4382
+ readonly at: number;
4383
+ }
4384
+ /**
4385
+ * This function gives the crossings of the cells of a polyline. The cells are the Voronoi cells of the centres.
4386
+ * It samples the polyline at the spacing `step`, and gives each change of the nearest centre.
4387
+ */
4388
+ export declare function cellSteps(line: readonly Point[], centres: readonly Point[], step: number): CellStep[];
4389
+ /**
4390
+ * This function gives the highways of the territories of the flows (HWY-033, Andrienko and Andrienko 2011).
4391
+ * The characteristic points form groups of the radius `radius`. The centres of the groups make Voronoi cells.
4392
+ * Each first route becomes a list of crossings between neighbour cells.
4393
+ *
4394
+ * A pair of cells with `minSize` crossings or more is a line from centre to centre. The edges that cross it snap to it. The centres of the cells are the interchanges.
4395
+ */
4396
+ export declare function territoryPlan(input: HighwayInput, o: Readonly<TerritoryOptions>): HighwayPlan;
4397
+ /** The linkage of the clusters of the vote matrix: `average` (the mean distance of the pairs) or `single` (the nearest pair). */
4398
+ type ConsensusLinkage = "average" | "single";
4399
+ /** The values of `ConsensusLinkage`. */
4400
+ export declare const CONSENSUS_LINKAGES: readonly ConsensusLinkage[];
4401
+ /** The options of the highway strategy `consensus` (HWY-035 of the note on highways). */
4402
+ interface ConsensusOptions {
4403
+ /** The finders that vote. The default is `corridors`, `quickbundles`, `wspd` and `road-classes`. */
4404
+ readonly members: readonly CandidateSource[];
4405
+ /** Two clusters join while their distance `1 - A` is below this value. The default is 0.5: more than half of the votes. */
4406
+ readonly cut: number;
4407
+ /** The linkage of the clusters. The default is `average`. */
4408
+ readonly linkage: ConsensusLinkage;
4409
+ /** A cluster with this number of edges or more gets highways. The default is 2. */
4410
+ readonly minSize: number;
4411
+ /** The spine of each cluster. The default is `shared`. */
4412
+ readonly spine: GroupSpine;
4413
+ }
4414
+ /** The default options of the strategy `consensus`. */
4415
+ export declare const CONSENSUS_DEFAULTS: Readonly<ConsensusOptions>;
4416
+ /**
4417
+ * This function gives the co-association matrix of the plans (Fred and Jain 2005). `A[e][f]` is the share of the plans with a highway that holds both `e` and `f`.
4418
+ * The edges are in the order of `edges`. An edge of no plan has no pair.
4419
+ */
4420
+ export declare function coAssociation(edges: readonly string[], plans: readonly HighwayPlan[]): Float64Array;
4421
+ /**
4422
+ * This function gives the clusters of the agglomerative linkage on the distance `1 - A`. Two clusters join while their distance is below `cut`.
4423
+ * The linkage `average` uses the mean of the distances of the pairs, and `single` the smallest distance.
4424
+ * The result is the cluster of each edge, and -1 for an edge that stays alone.
4425
+ */
4426
+ export declare function consensusLabels(n: number, a: Float64Array, cut: number, linkage: ConsensusLinkage): Int32Array;
4427
+ /** This function gives the edge groups of the consensus of the plans of the finders `members` (HWY-035). */
4428
+ export declare function consensusGroups(input: HighwayInput, o: Readonly<ConsensusOptions>): Map<string, EdgeGroup>;
4429
+ /**
4430
+ * This function gives the highways of the consensus of clusterings (HWY-035). Each finder of `members` votes for the pairs of edges that share one of its highways.
4431
+ * The clusters of the vote matrix with `minSize` edges or more get highways. A small edit changes few votes, so the clusters are stable.
4432
+ */
4433
+ export declare function consensusPlan(input: HighwayInput, o: Readonly<ConsensusOptions>): HighwayPlan;
4434
+ /** The allocation of the edges to the hubs: `single` (each node to its nearest hub) or `multiple` (each edge to its best pair of hubs). */
4435
+ type HubAllocation = "single" | "multiple";
4436
+ /** The values of `HubAllocation`. */
4437
+ export declare const HUB_ALLOCATIONS: readonly HubAllocation[];
4438
+ /** The candidate points of the hubs: the corners of the corner graph, or the centres of the cells of the tree of sections. */
4439
+ type HubCandidates = "corners" | "sections";
4440
+ /** The values of `HubCandidates`. */
4441
+ export declare const HUB_CANDIDATES: readonly HubCandidates[];
4442
+ /** The options of the highway strategy `p-hub` (HWY-041 of the note on highways). */
4443
+ interface PHubOptions {
4444
+ /** The number of hubs. The value 0 gives the root of the number of nodes, rounded. The default is 0. */
4445
+ readonly p: number;
4446
+ /** The cost of a length on a link between two hubs against a length off the links, from 0 to 1. The default is 0.5. */
4447
+ readonly alpha: number;
4448
+ /** The allocation of the edges to the hubs. The default is `single`. */
4449
+ readonly allocation: HubAllocation;
4450
+ /** The candidate points of the hubs. The default is `corners`. */
4451
+ readonly candidates: HubCandidates;
4452
+ /** An edge rides a link only when its way through the two hubs is this many times its first route or less. The default is 1.25. */
4453
+ readonly detour: number;
4454
+ /** The number of passes of the local search with one swap of a hub. The default is 1. */
4455
+ readonly swaps: number;
4456
+ /** A link with fewer edges than this number is not a highway. The default is 2. */
4457
+ readonly minSize: number;
4458
+ }
4459
+ /** The default options of the strategy `p-hub`. */
4460
+ export declare const P_HUB_DEFAULTS: Readonly<PHubOptions>;
4461
+ /** This function gives the candidate points of the hubs, at most `MAX_CANDIDATES`, without the copies. */
4462
+ export declare function hubCandidates(input: HighwayInput, candidates: HubCandidates): Point[];
4463
+ /**
4464
+ * This function chooses `p` points of `candidates` as the p-median of `points`. The greedy step adds the candidate that lowers the sum of the distances most.
4465
+ * Then at most 4 passes of swaps lower the sum more. The result is the indices of the chosen candidates.
4466
+ */
4467
+ export declare function pMedian(points: readonly Point[], candidates: readonly Point[], p: number): number[];
4468
+ /**
4469
+ * This function gives the highways of the hub location (HWY-041, the p-hub median of O'Kelly 1987). The p-median of the plugs chooses `p` hubs from the candidates.
4470
+ * Each swap pass changes one hub for one other candidate while the total cost falls. Each link between two hubs with `minSize` edges or more is a highway.
4471
+ * The edges that ride a link snap to it, from their first hub to their second hub.
4472
+ */
4473
+ export declare function pHubPlan(input: HighwayInput, o: Readonly<PHubOptions>): HighwayPlan;
4474
+ /** The line of each edge that QuickBundles compares: its first route, or the straight line between its plugs. */
4475
+ type BundleLine = "routes" | "lines";
4476
+ /** The order of the edges in the one pass: the order of the graph, or the longest line first. */
4477
+ type BundleOrder = "input" | "length";
4478
+ /** The options of the highway strategy `quickbundles` (HWY-026 of the note on highways). */
4479
+ interface QuickBundlesOptions {
4480
+ /** An edge joins a cluster when its distance to the centroid is this value or less, in units of the board. The default is 3. */
4481
+ readonly theta: number;
4482
+ /** The number of points of each line after the resampling. The default is 12. */
4483
+ readonly points: number;
4484
+ /** The line of each edge. The default is `routes`. */
4485
+ readonly line: BundleLine;
4486
+ /** The order of the edges. The default is `input`, so an added edge does not change the clusters before it. */
4487
+ readonly order: BundleOrder;
4488
+ /** A cluster with this number of edges or more gets highways. The default is 2. */
4489
+ readonly minSize: number;
4490
+ /** The spine of each cluster. The default is `shared`. */
4491
+ readonly spine: GroupSpine;
4492
+ }
4493
+ /** The default options of the strategy `quickbundles`. */
4494
+ export declare const QUICKBUNDLES_DEFAULTS: Readonly<QuickBundlesOptions>;
4495
+ /** This function gives `k` points at equal steps of length along a polyline, from its first point to its last point. */
4496
+ export declare function resample(line: readonly Point[], k: number): Point[];
4497
+ /**
4498
+ * This function gives the MDF distance of two lines with the same number of points. It is the mean distance of their points.
4499
+ * The function compares the points in the same direction and in the opposite direction, and keeps the smaller mean.
4500
+ * `flip` is `true` when the opposite direction is smaller.
4501
+ */
4502
+ export declare function mdf(p: readonly Point[], q: readonly Point[]): {
4503
+ d: number;
4504
+ flip: boolean;
4505
+ };
4506
+ /**
4507
+ * This function gives the clusters of QuickBundles (Garyfallidis 2012) as groups of edges.
4508
+ * In one pass, each edge joins the cluster with the nearest centroid when the MDF distance is `theta` units or less. Else it starts a cluster.
4509
+ * The centroid is the running mean of the lines of the cluster, each in the direction of the centroid.
4510
+ */
4511
+ export declare function quickBundles(input: HighwayInput, o: Readonly<QuickBundlesOptions>): Map<string, EdgeGroup>;
4512
+ /**
4513
+ * This function gives the highways of QuickBundles (HWY-026). The clusters of `quickBundles` with `minSize` edges or more get highways.
4514
+ * With the spine `shared`, the edges of each cluster share their ways through the corner graph. With `trunk`, each cluster gets one trunk.
4515
+ */
4516
+ export declare function quickBundlesPlan(input: HighwayInput, o: Readonly<QuickBundlesOptions>): HighwayPlan;
4517
+ /** The options of the highway strategy `scale-space` (HWY-053 of the note on highways). */
4518
+ interface ScaleSpaceOptions {
4519
+ /** The first scale, in units of the board. The default is 1.5. */
4520
+ readonly theta: number;
4521
+ /** The scale of each next scale is this value times the scale before it. The default is the root of 2. */
4522
+ readonly ratio: number;
4523
+ /** The number of scales. The default is 8. */
4524
+ readonly scales: number;
4525
+ /** The scale of the plan, from 0 (the first scale). With the defaults, the scale 2 is 3 units, as in the level 0 of `nested`. The default is 2. */
4526
+ readonly level: number;
4527
+ /** A cluster gets highways only when its persistence `ln(σ_death / σ_birth)` is this value or more. The default is 0.6: two steps of the root of 2. */
4528
+ readonly p0: number;
4529
+ /** The number of points of each line after the resampling. The default is 12. */
4530
+ readonly points: number;
4531
+ /** The line of each edge. The default is `routes`. */
4532
+ readonly line: BundleLine;
4533
+ /** A cluster with this number of edges or more gets highways. The default is 2. */
4534
+ readonly minSize: number;
4535
+ /** The spine of each cluster. The default is `shared`. */
4536
+ readonly spine: GroupSpine;
4537
+ }
4538
+ /** The default options of the strategy `scale-space`. */
4539
+ export declare const SCALE_SPACE_DEFAULTS: Readonly<ScaleSpaceOptions>;
4540
+ /** One cluster of one scale: its edges (as indices), and the scales of its birth and its death. */
4541
+ interface ScaleCluster {
4542
+ readonly members: readonly number[];
4543
+ /** The first scale of the cluster. A cluster of the first scale has the birth 0. */
4544
+ readonly birth: number;
4545
+ /** The first scale where the cluster joins a larger one. A cluster that lives past the last scale has the death `scales`. */
4546
+ readonly death: number;
4547
+ }
4548
+ /**
4549
+ * This function gives the clusters of the single linkage of `n` items at each scale. The distance `d(i, j)` of each pair is in `pairs`.
4550
+ * At the scale `s`, two items with a distance of `limits[s]` or less are in one cluster. Thus each cluster of a scale is in one cluster of each larger scale.
4551
+ * The result has the clusters of each scale with 2 items or more, with their birth and their death.
4552
+ */
4553
+ export declare function scaleClusters(n: number, pairs: readonly {
4554
+ i: number;
4555
+ j: number;
4556
+ d: number;
4557
+ }[], limits: readonly number[]): ScaleCluster[][];
4558
+ /**
4559
+ * This function gives the groups of the edges at the scale `level` that persist (HWY-053). The scale `s` is `theta × ratio^s` units of the board.
4560
+ * A cluster of the level gets a group when its persistence `(death - birth) × ln(ratio)` is `p0` or more. Each edge of a group gets `flip` against the first edge of the group.
4561
+ */
4562
+ export declare function scaleSpaceGroups(input: HighwayInput, o: Readonly<ScaleSpaceOptions>): Map<string, EdgeGroup>;
4563
+ /**
4564
+ * This function gives the highways of one scale of the scale space with persistence (HWY-053). Only the clusters that live over `p0` of the log scale get highways.
4565
+ * A short-lived cluster is noise, so a zoom level shows only the stable structure.
4566
+ */
4567
+ export declare function scaleSpacePlan(input: HighwayInput, o: Readonly<ScaleSpaceOptions>): HighwayPlan;
4568
+ /** The lines that make the density: the straight lines of the edges, or their first routes. */
4569
+ type RidgeSource = "lines" | "routes";
4570
+ /** The options of the highway strategy `ridges` (HWY-032 of the note on highways). */
4571
+ interface RidgeOptions extends Pick<WayOptions, "margin" | "k"> {
4572
+ /** The lines of the density. The default is `lines`. */
4573
+ readonly source: RidgeSource;
4574
+ /** The side of a cell of the density image, in units of the board. The default is 8. A large board gets larger cells, up to 1024 cells on a side. */
4575
+ readonly cell: number;
4576
+ /** The width of the blur, in units of the board. The default is 16. */
4577
+ readonly bandwidth: number;
4578
+ /** A ridge cell has this share of the largest strength or more. The default is 0.15. */
4579
+ readonly strength: number;
4580
+ /** A ridge has this length or more, in units of the board. The default is 60. */
4581
+ readonly minLength: number;
4582
+ /** An edge snaps to a ridge when its line is this near to the ridge, in units of the board. The default is 16. */
4583
+ readonly snap: number;
4584
+ /** A highway has this number of edges or more. The default is 2. */
4585
+ readonly minSize: number;
4586
+ }
4587
+ /** The default options of the strategy `ridges`. */
4588
+ export declare const RIDGE_DEFAULTS: Readonly<Required<Omit<RidgeOptions, "margin" | "k">>>;
4589
+ /** The density image: the cells, its size, and the place of its first cell. */
4590
+ interface DensityImage {
4591
+ readonly w: number;
4592
+ readonly h: number;
4593
+ readonly cell: number;
4594
+ readonly x0: number;
4595
+ readonly y0: number;
4596
+ readonly rho: Float64Array;
4597
+ }
4598
+ /**
4599
+ * This function gives the density of the polylines on a grid of cells, after a Gaussian blur of the width `bandwidth`.
4600
+ * Each polyline adds 1 to each cell that it goes through, one time for each polyline.
4601
+ */
4602
+ export declare function lineDensity(lines: readonly (readonly Point[])[], box: {
4603
+ x: number;
4604
+ y: number;
4605
+ w: number;
4606
+ h: number;
4607
+ }, cellSize: number, bandwidth: number): DensityImage;
4608
+ /** One ridge: its two ends and the length between them. */
4609
+ interface Ridge {
4610
+ readonly a: Point;
4611
+ readonly b: Point;
4612
+ }
4613
+ /**
4614
+ * This function gives the ridges of a density image (Lindeberg 1998). A ridge cell has a negative eigenvalue of the Hessian with the larger size.
4615
+ * Its density is a maximum along the eigenvector of that eigenvalue. Its strength is the density times the size of that eigenvalue.
4616
+ * The cells with `strength` times the largest strength or more join their neighbours with a direction within 30 degrees.
4617
+ * Each group of cells gives the segment of its main axis. A segment of `minLength` or more is a ridge. The ridges come in the order of their total strength.
4618
+ */
4619
+ export declare function densityRidges(img: DensityImage, strength: number, minLength: number): Ridge[];
4620
+ /**
4621
+ * This function gives the lines of the ridges (HWY-032), each with the edges that snap to it.
4622
+ * An edge snaps to a ridge when the part of its line near the ridge is half of `minLength` or longer.
4623
+ * The angle between the edge and the ridge is 30 degrees or less.
4624
+ * The edge joins and leaves the ridge at the ends of that part. When two ridges hold one part of an edge, only the longer part rides.
4625
+ */
4626
+ export declare function ridgeLines(input: HighwayInput, o: Readonly<RidgeOptions>): SnapLine[];
4627
+ /**
4628
+ * This function gives the highways of the ridges of the line density (HWY-032). One pass draws the density, with no advection.
4629
+ * The ridges of the density are the spines, and the edges near a ridge snap to it between their nearest entry and exit points.
4630
+ */
4631
+ export declare function ridgePlan(input: HighwayInput, o: Readonly<RidgeOptions>): HighwayPlan;
4632
+ /** The options of the highway strategy `soft-keys` (HWY-019 of the note on highways). */
4633
+ interface SoftKeyOptions {
4634
+ /** The rule that gives the key of each edge. The default is `byCollection`: the string `data.collection`. */
4635
+ readonly rule: GroupRule;
4636
+ /** The distance that two different keys add. `Infinity` keeps the edges of two keys apart, as the hard keys do. The default is 0.25. */
4637
+ readonly lambda: number;
4638
+ /** Two clusters join while their distance is this value or less. The default is 0.5. */
4639
+ readonly tau: number;
4640
+ /** The names of number fields of `data` that add a distance. The default is no field. */
4641
+ readonly attributes: readonly string[];
4642
+ /** The weight of each field of `attributes`. The distance of a field is its difference over its range. The default is 1. */
4643
+ readonly weight: number;
4644
+ /** The linkage of the clustering. The default is `average`. */
4645
+ readonly linkage: Linkage;
4646
+ /** A cluster with this number of edges or more gets highways. The default is 2. */
4647
+ readonly minSize: number;
4648
+ /** The spine of each cluster. The default is `shared`: the router `shared` with the cluster as the key. */
4649
+ readonly spine: GroupSpine;
4650
+ }
4651
+ /** The default options of the strategy `soft-keys`. */
4652
+ export declare const SOFT_KEY_DEFAULTS: Readonly<SoftKeyOptions>;
4653
+ /**
4654
+ * This function gives the soft-key distance of two edges (Peysakhovich, Hurter and Telea 2015): `d = d_geom + lambda [key(e) != key(f)] + sum_a w |a(e) - a(f)| / range(a)`.
4655
+ * `d_geom` is the flow distance of HWY-023. The key term is 0 when an edge has no key.
4656
+ */
4657
+ export declare function softDistance(geom: number, keyA: string | undefined, keyB: string | undefined, lambda: number, attributes: number): number;
4658
+ /**
4659
+ * This function gives the soft-key clusters of the edges (HWY-019). It clusters the edges with `softDistance`, with the cut at `tau`.
4660
+ * Each edge of a cluster gets the key of the cluster. It gets `flip` when it goes opposite to the first edge of the cluster.
4661
+ */
4662
+ export declare function softKeyClusters(input: HighwayInput, o: Readonly<SoftKeyOptions>): Map<string, EdgeGroup>;
4663
+ /**
4664
+ * This function gives the highways of the soft keys (HWY-019). The key of an edge is one more term of the distance, not a hard split.
4665
+ * Edges of two keys still share a highway when they are very near, and edges of one key do not bundle when they are far.
4666
+ */
4667
+ export declare function softKeyPlan(input: HighwayInput, o: Readonly<SoftKeyOptions>): HighwayPlan;
4668
+ /** The end of the edges that gets a field: the target of a fan-in, or the source of a fan-out. */
4669
+ type FieldEnd = "target" | "source";
4670
+ /** The options of the highway strategy `flow-field` (EDA-046 with HWY-037 of the notes). */
4671
+ interface FlowFieldOptions extends Pick<WayOptions, "margin" | "k"> {
4672
+ /** An end with this number of edges or more on one side of its box gets a field. The default is 2. */
4673
+ readonly minFanIn: number;
4674
+ /** The end that gets a field. The default is `target`. */
4675
+ readonly end: FieldEnd;
4676
+ }
4677
+ /** The default options of the strategy `flow-field`. */
4678
+ export declare const FLOW_FIELD_DEFAULTS: Readonly<Required<Omit<FlowFieldOptions, "margin" | "k">>>;
4679
+ /**
4680
+ * This function gives the highways of a flow field for each target (EDA-046, HWY-037).
4681
+ * The edges into one side of one box make a fan. The root of the fan is the point out of the median plug of the fan.
4682
+ * Each edge of the fan goes the shortest way from the point out of its other plug to the root, through the corner graph.
4683
+ * The shortest ways to one root make a tree, so they merge like streams and do not cross. Each stretch that two ways share is one highway.
4684
+ * With the end `source`, the same holds for the edges out of one side of one box.
4685
+ */
4686
+ export declare function flowFieldPlan(input: HighwayInput, o: Readonly<FlowFieldOptions>): HighwayPlan;
4687
+ /** The options of the highway strategy `keys`: the options of the router `trunks`, without the name and the limit of the benchmark. */
4688
+ type KeysOptions = Omit<TrunksOptions, "name" | "maxNodes">;
4689
+ /**
4690
+ * This function gives the highways that the router `trunks` decides. A rule gives each edge a key.
4691
+ * The edges from one plug with one key share a trunk to a split point. The edges that go on together share a run past it.
4692
+ * Each trunk and each run becomes one highway. The function does not change the router: it reads its bundles and its runs.
4693
+ */
4694
+ export declare function keysPlan(input: HighwayInput, options: KeysOptions): HighwayPlan;
4695
+ /** The options of the highway strategy `level-links` (HWY-056 with WILD-034 of the notes). */
4696
+ interface LevelHighwayOptions {
4697
+ /** The plan of the edges that do not ride a level link. The default is `shared-ways`. */
4698
+ readonly from: HighwayBase;
4699
+ /** The depth of the level in the tree of sections. Depth 1 is the level below the root. The default is 1. */
4700
+ readonly depth: number;
4701
+ /** A level link becomes a highway when this number of edges or more ride it. The default is 2. */
4702
+ readonly minSize: number;
4703
+ /** An edge rides the link only when its way along the link is this many times its first route, or shorter. The default is 1.5. */
4704
+ readonly stretch: number;
4705
+ }
4706
+ /** The default options of the strategy `level-links`. */
4707
+ export declare const LEVEL_HIGHWAY_DEFAULTS: Readonly<LevelHighwayOptions>;
4708
+ /**
4709
+ * This function gives a highway for each link of a zoom level, with the edges between its two items (HWY-056, WILD-034).
4710
+ * The level is the cut of the tree of sections at `depth`. The link goes around the boxes of the other items (`levelLinks`).
4711
+ * The spine is the link without a margin at each end, so it stays off the boxes of the two items. It must stay out of each box.
4712
+ * The edges between the two items, in each direction, ride the spine. The ramps go through the corner graph inside the items.
4713
+ *
4714
+ * An edge rides only when the ramps (as straight lines) and the spine are `stretch` times its first route, or shorter.
4715
+ * A link with fewer than `minSize` such edges is not a highway. The other edges keep their highways of the plan `from`.
4716
+ * Thus a zoom from the level to the routes shows the same lines, which open into lanes.
4717
+ */
4718
+ export declare function levelHighwayPlan(input: HighwayInput, o: Readonly<LevelHighwayOptions>): HighwayPlan;
4719
+ /** The options of the highway strategy `meet` (HWY-050 of the note on highways). */
4720
+ interface MeetOptions {
4721
+ /** The plan whose merge points and split points the strategy moves. The default is `shared-ways`. */
4722
+ readonly from: HighwayBase;
4723
+ /** A first route meets the spine where it is this distance from the spine, or nearer. The default is 8: two lanes of 4. */
4724
+ readonly near: number;
4725
+ /** A first route meets the spine only where it runs at this angle to the spine, or less, in degrees. The default is 45. */
4726
+ readonly maxTurn: number;
4727
+ /** A member keeps its places when the stretch where its first route meets the spine is shorter than this length. The default is 10. */
4728
+ readonly minRun: number;
4729
+ }
4730
+ /** The default options of the strategy `meet`. */
4731
+ export declare const MEET_DEFAULTS: Readonly<MeetOptions>;
4732
+ /**
4733
+ * This function gives a member with its merge point and its split point where its first route meets the spine and parts from it (HWY-050).
4734
+ * The function samples the stretch of the member on the spine, at steps of `near / 2` or less.
4735
+ * A sample meets the route when the route is `near` or nearer, and its nearest leg runs at `maxTurn` or less to the spine.
4736
+ * The new merge point is the first sample that meets the route, in the direction of the member. The new split point is the last one.
4737
+ * So the edge joins the spine late and leaves it early. The places only move inward.
4738
+ * The member keeps its places when no sample meets the route, or when the met stretch is shorter than `minRun`.
4739
+ */
4740
+ export declare function meetMember(spine: readonly Point[], member: HighwayMember, route: readonly Point[] | undefined, o: Readonly<MeetOptions>): HighwayMember;
4741
+ /**
4742
+ * This function gives the highways of the plan `from`, with merge points and split points where the routes meet and part (HWY-050).
4743
+ * The first route of each edge is the route of `input.routes`, or its route without highways.
4744
+ * Each member gets the places of `meetMember`. The spines and the trips do not change.
4745
+ */
4746
+ export declare function meetPlan(input: HighwayInput, o: Readonly<MeetOptions>): HighwayPlan;
4747
+ /** The options of the highway strategy `mingle` (HWY-003 of the note on highways). */
4748
+ interface MingleOptions {
4749
+ /** Each bundle looks for a merge among this number of nearest bundles in 4D. The default is 8. */
4750
+ readonly k: number;
4751
+ /** The largest turn of an edge at a meeting point, in degrees. A larger turn moves the meeting point along the trunk. The default is 40. */
4752
+ readonly maxTurn: number;
4753
+ /** The number of levels of merges. The default is 6. */
4754
+ readonly levels: number;
4755
+ /** The weight of the trunk in the ink. With 1, the trunk costs its length one time. The default is 1. */
4756
+ readonly weight: number;
4757
+ /** A bundle with this number of edges or more gets highways. The default is 2. */
4758
+ readonly minSize: number;
4759
+ /** The spine of each bundle. The default is `trunk`: one trunk between the two meeting points. */
4760
+ readonly spine: GroupSpine;
4761
+ }
4762
+ /** The default options of the strategy `mingle`. */
4763
+ export declare const MINGLE_DEFAULTS: Readonly<MingleOptions>;
4764
+ /**
4765
+ * This function gives the bundles of MINGLE (Gansner, Hu, North and Scheidegger 2011) as groups of edges.
4766
+ * Each edge is a point in 4D: its two plugs. At each level, each bundle examines its `k` nearest bundles in 4D.
4767
+ * A merge saves ink when the ink of the joint bundle is less than the sum of the two inks. The merges with the largest gain go first.
4768
+ * A bundle merges one time at most in a level. The levels stop after `levels` levels, or when no merge saves ink.
4769
+ */
4770
+ export declare function mingleBundles(input: HighwayInput, o: Readonly<MingleOptions>): Map<string, EdgeGroup>;
4771
+ /**
4772
+ * This function gives the highways of MINGLE (HWY-003). The bundles of `mingleBundles` with `minSize` edges or more get highways.
4773
+ * With the spine `trunk`, each bundle gets one trunk between its two meeting points, through the corner graph.
4774
+ * With `shared`, the edges of each bundle share their ways through the corner graph.
4775
+ */
4776
+ export declare function minglePlan(input: HighwayInput, o: Readonly<MingleOptions>): HighwayPlan;
4777
+ /** The options of the highway strategy `od-cells` (EDA-033 with WILD-032 of the notes). */
4778
+ interface OdCellOptions {
4779
+ /** The depth of the cells in the tree of sections. Depth 1 is the level below the root. The default is 2. */
4780
+ readonly level: number;
4781
+ /** A pair of cells with this number of edges or more gets a trunk. The default is 3. */
4782
+ readonly minGroup: number;
4783
+ /** An edge rides the trunk only when each of its legs is this share of the span or shorter. The default is 0.3. */
4784
+ readonly legMax: number;
4785
+ /** The spine of each pair of cells. The default is `trunk`. */
4786
+ readonly spine: GroupSpine;
4787
+ }
4788
+ /** The default options of the strategy `od-cells`. */
4789
+ export declare const OD_CELL_DEFAULTS: Readonly<OdCellOptions>;
4790
+ /**
4791
+ * This function gives the groups of the edges by the pair of the cells of their two nodes (EDA-033, WILD-032).
4792
+ * The cells are the items of the zoom level at the depth `level`. The edges of one pair of cells, in either direction, are one group.
4793
+ * An edge inside one cell is in no group.
4794
+ */
4795
+ export declare function odGroups(input: HighwayInput, o: Readonly<OdCellOptions>): Map<string, EdgeGroup>;
4796
+ /**
4797
+ * This function gives the highways of the consolidation by origin and destination cells (EDA-033, WILD-032).
4798
+ * Carriers merge the loads from one region to another into one truck between two terminals. Thus each pair of cells with `minGroup` edges or more gets one trunk.
4799
+ * The terminals are the Weber points of the plugs in each cell. An edge with a leg longer than `legMax` times the span goes alone.
4800
+ */
4801
+ export declare function odCellPlan(input: HighwayInput, o: Readonly<OdCellOptions>): HighwayPlan;
4802
+ /** The options of the highway strategy `nested` (HWY-052 of the note on highways). */
4803
+ interface NestedOptions {
4804
+ /** The scale of the closest level, in units of the board. An edge joins a cluster when its distance to the centroid is this value or less. The default is 3. */
4805
+ readonly theta: number;
4806
+ /** The scale of each level is this value times the scale of the next closer level. The default is 2. */
4807
+ readonly ratio: number;
4808
+ /** The number of levels. The default is 3. */
4809
+ readonly levels: number;
4810
+ /** The level of the plan. Level 0 is the closest level, and level `levels - 1` is the far level. The default is 0. */
4811
+ readonly level: number;
4812
+ /** The number of points of each line after the resampling. The default is 12. */
4813
+ readonly points: number;
4814
+ /** The line of each edge. The default is `routes`. */
4815
+ readonly line: BundleLine;
4816
+ /** The order of the edges. The default is `input`. */
4817
+ readonly order: BundleOrder;
4818
+ /** A cluster with this number of edges or more gets highways. The default is 2. */
4819
+ readonly minSize: number;
4820
+ /** The spine of each cluster. The default is `shared`. */
4821
+ readonly spine: GroupSpine;
4822
+ }
4823
+ /** The default options of the strategy `nested`. */
4824
+ export declare const NESTED_DEFAULTS: Readonly<NestedOptions>;
4825
+ /**
4826
+ * This function gives the groups of edges of each level, from the closest level (index 0) to the far level.
4827
+ * The far level puts all the edges in clusters at the scale `theta × ratio^(levels - 1)`.
4828
+ * Each closer level puts the edges of each cluster of the level above in clusters, at its own scale. Thus each group of a level is in one group of the level above.
4829
+ */
4830
+ export declare function nestedGroups(input: HighwayInput, o: Readonly<NestedOptions>): Map<string, EdgeGroup>[];
4831
+ /**
4832
+ * This function gives the number of groups of the closer level `fine` with edges in two groups or more of the level `coarse`.
4833
+ * An edge that is not in `coarse` does not count. The groups of `nestedGroups` give 0.
4834
+ */
4835
+ export declare function nestingViolations(coarse: ReadonlyMap<string, EdgeGroup>, fine: ReadonlyMap<string, EdgeGroup>): number;
4836
+ /**
4837
+ * This function gives the highways of one level of the nested clusters (HWY-052). The level is `o.level`, with 0 as the closest level.
4838
+ * The clusters of that level with `minSize` edges or more get highways, as in the strategy `quickbundles`.
4839
+ */
4840
+ export declare function nestedPlan(input: HighwayInput, o: Readonly<NestedOptions>): HighwayPlan;
4841
+ /** The options of the highway strategy `lanes` (HWY-051 of the note on highways). */
4842
+ interface LanesOptions {
4843
+ /** The distance from a box to the corners of the graph. The default is 5. */
4844
+ readonly margin?: number;
4845
+ /** The number of visible neighbours of each corner. The default is 8. */
4846
+ readonly k?: number;
4847
+ /** The plan that the strategy changes. The default is `shared-ways`. */
4848
+ readonly from: HighwayBase;
4849
+ /** The gap between two lanes. The default is 4. */
4850
+ readonly laneGap: number;
4851
+ /** The largest width of a highway. The default is 32. */
4852
+ readonly maxWidth: number;
4853
+ /** The number of times that a highway can split, one half after the other. The default is 3. */
4854
+ readonly depth: number;
4855
+ }
4856
+ /** The default options of the strategy `lanes`. */
4857
+ export declare const LANES_DEFAULTS: Readonly<LanesOptions>;
4858
+ /**
4859
+ * This function gives the number of legs of the spines of a plan where the lanes do not fit in the channel.
4860
+ * A leg with two lanes or more needs `min(maxWidth, lanes × laneGap)`. The channel is the free space across the leg (`channelWidth`).
4861
+ */
4862
+ export declare function channelOverflows(graph: Graph, plan: HighwayPlan, o: Readonly<Pick<LanesOptions, "laneGap" | "maxWidth" | "margin" | "k">>): number;
4863
+ /**
4864
+ * This function gives the plan of `from`, with each highway that does not fit in its channels split in two (HWY-051).
4865
+ * The lanes split into two halves by lane order. The first half keeps the spine. The second half gets a new spine through the corners, where the narrow links cost more.
4866
+ * A highway with fewer than four lanes moves as one to the new spine.
4867
+ * A half that still does not fit splits again, up to `depth` times. A new spine needs a shorter length of narrow legs than the old spine.
4868
+ */
4869
+ export declare function lanesPlan(input: HighwayInput, o: Readonly<LanesOptions>): HighwayPlan;
4870
+ /** The order of the edges in the growth: the longest first route first, or the order of the graph. */
4871
+ type GrowthOrder = "length" | "input";
4872
+ /** The options of the highway strategy `growth` (HWY-055 of the note on highways). */
4873
+ interface GrowthOptions {
4874
+ /** The distance from a box to the corners of the graph. The default is 5. */
4875
+ readonly margin?: number;
4876
+ /** The number of visible neighbours of each corner. The default is 8. */
4877
+ readonly k?: number;
4878
+ /** The order of the edges. The default is `length`. */
4879
+ readonly order: GrowthOrder;
4880
+ /** The cost of the part on a spine, as a share of its length. The ramps cost their full length. The default is 0.5. */
4881
+ readonly share: number;
4882
+ /** An edge joins a highway only when its way along it is this value times its first route or shorter. The default is 1.3. */
4883
+ readonly stretch: number;
4884
+ /** A spine end extends when this number of its lanes or more go on together. The default is 3. */
4885
+ readonly extendLanes: number;
4886
+ /** The lanes go on together when their ends are this distance from their center or nearer, in units of the board. The default is 2. */
4887
+ readonly extendRadius: number;
4888
+ /** A highway with this number of edges or more stays in the plan. The default is 2. */
4889
+ readonly minSize: number;
4890
+ }
4891
+ /** The default options of the strategy `growth`. */
4892
+ export declare const GROWTH_DEFAULTS: Readonly<GrowthOptions>;
4893
+ /**
4894
+ * This function gives the highways of local growth (HWY-055). The edges come one by one, by default the longest first route first.
4895
+ * Each edge joins the highway with the largest saving: its first route less its ramps and `share` of its part on the spine. Without a saving, the edge starts a highway on its own way.
4896
+ * After the growth, a spine end can go on to the center of the far ends of its lanes.
4897
+ * This occurs when `extendLanes` of them or more are near that center and the line is clear.
4898
+ */
4899
+ export declare function growthPlan(input: HighwayInput, o: Readonly<GrowthOptions>): HighwayPlan;
4900
+ /** The options of the highway strategy `road-classes` (HWY-034 with EDA-050 of the notes). */
4901
+ interface RoadClassOptions extends Pick<WayOptions, "margin" | "k"> {
4902
+ /** A link is a highway link when its use is at this quantile of the use of the links, or higher. The default is 0.9. */
4903
+ readonly quantile: number;
4904
+ /** A highway link has this number of edges or more on it, and a highway has this number of edges or more. The default is 2. */
4905
+ readonly minSize: number;
4906
+ /** The second pass gives each highway link this discount, as a share of its length. The default is 0.5. */
4907
+ readonly discount: number;
4908
+ }
4909
+ /** The default options of the strategy `road-classes`. */
4910
+ export declare const ROAD_CLASS_DEFAULTS: Readonly<Required<Omit<RoadClassOptions, "margin" | "k">>>;
4911
+ /**
4912
+ * This function gives the highways of the road classes (HWY-034, EDA-050). It counts how many first ways use each link of the corner graph.
4913
+ * The links with a use at the quantile `quantile` or higher, and at least `minSize`, are the highway links.
4914
+ * They are the main roads of a road map.
4915
+ * A second pass routes each edge again, with the discount on the highway links, so more edges join them.
4916
+ * Each stretch of highway links that `minSize` ways or more share after the second pass is one highway.
4917
+ */
4918
+ export declare function roadClassPlan(input: HighwayInput, o: Readonly<RoadClassOptions>): HighwayPlan;
4919
+ /** The options of the highway strategy `shared-ways`: the options of the router `shared`, without the name and the limit of the benchmark. */
4920
+ type SharedWaysOptions = Omit<SharedOptions, "name" | "maxNodes">;
4921
+ /**
4922
+ * This function gives the highways that the router `shared` decides. The edges of one key go one by one through the corner graph.
4923
+ * A link that the key uses already costs less, so the ways of a key come together. Each stretch that two edges or more share becomes one highway.
4924
+ * The function does not change the router: it reads its runs.
4925
+ */
4926
+ export declare function sharedWaysPlan(input: HighwayInput, options: SharedWaysOptions): HighwayPlan;
4927
+ /** The options of the highway strategy `spiral` (HWY-017 with EDA-035 of the notes). */
4928
+ interface SpiralOptions extends Pick<WayOptions, "margin" | "k"> {
4929
+ /** The spiral angle, in degrees: the largest angle between a branch and the line to the root. The default is 25. */
4930
+ readonly alpha: number;
4931
+ /** A node with this number of edges or more gets a spiral tree. The default is 4. */
4932
+ readonly minTargets: number;
4933
+ /** The number of points of the arc of each branch. The default is 4. */
4934
+ readonly arc: number;
4935
+ }
4936
+ /** The default options of the strategy `spiral`. */
4937
+ export declare const SPIRAL_DEFAULTS: Readonly<Required<Omit<SpiralOptions, "margin" | "k">>>;
4938
+ /** One node of a spiral tree, in polar coordinates around the root. A leaf has an edge, and a join has two children. */
4939
+ interface SpiralNode {
4940
+ readonly r: number;
4941
+ readonly theta: number;
4942
+ readonly point: Point;
4943
+ /** A join with this node is this distance or more nearer to the root than the node. A leaf keeps its box clear so. A join has 0. */
4944
+ readonly clear: number;
4945
+ readonly edge?: string;
4946
+ readonly children: readonly SpiralNode[];
4947
+ }
4948
+ /**
4949
+ * This function gives the join of the nodes `p` and `q` of a spiral tree with the angle `alpha`. It gives `undefined` when no join is possible.
4950
+ * Each node can reach the points inside its two spirals toward the root: `|theta - theta_p| <= tan(alpha) ln(r_p / r)`.
4951
+ * The join is the point farthest from the root that both nodes reach, and that is `clear` nearer to the root than each node.
4952
+ * At that radius, the join is at the middle of the angles that both nodes reach.
4953
+ */
4954
+ export declare function spiralJoin(p: SpiralNode, q: SpiralNode, alpha: number, root: Point): {
4955
+ r: number;
4956
+ theta: number;
4957
+ point: Point;
4958
+ } | undefined;
4959
+ /**
4960
+ * This function gives the spiral tree of the leaves around the root (Buchin, Speckmann and Verbeek 2011), with the greedy sweep.
4961
+ * The sweep goes from the far leaves to the root. A leaf joins the wavefront at its radius. Two nodes that are next to each other in angle join at their join point.
4962
+ * The join with the largest radius goes first. No join occurs below the radius `rMin`. The function gives the nodes of the wavefront at the end.
4963
+ */
4964
+ export declare function spiralTree(leaves: readonly SpiralNode[], alpha: number, root: Point, rMin: number): SpiralNode[];
4965
+ /**
4966
+ * This function gives the highways of the spiral trees (HWY-017, EDA-035). Each node with `minTargets` edges or more is the root of a fan.
4967
+ * The nodes with more edges go first, and each edge is in one fan at most. The far plug of each edge is a leaf of the tree of its fan.
4968
+ * Each branch of a tree with two leaves or more is a highway. Its spine is an arc of a logarithmic spiral, or a way through the corner graph where the arc hits a box.
4969
+ * An edge rides the branches from the root to its leaf, or from its leaf to the root when the root is its target.
4970
+ */
4971
+ export declare function spiralPlan(input: HighwayInput, o: Readonly<SpiralOptions>): HighwayPlan;
4972
+ /** The ends of the edges that get stubs: the source ends, the target ends, or both. */
4973
+ type StubEnds = "source" | "target" | "both";
4974
+ /** The options of the highway strategy `stubs` (HWY-015 with WILD-005 of the notes). */
4975
+ interface StubOptions {
4976
+ /** The plan that the stubs go into. The default is `shared-ways`. */
4977
+ readonly from: HighwayBase;
4978
+ /** The ends of one side of a box whose directions are in a window of this angle share a stub, in degrees. The default is 30. */
4979
+ readonly omega: number;
4980
+ /** The length of a stub is this share of the distance to the nearest other end. The default is 0.25. */
4981
+ readonly sigma: number;
4982
+ /** The ends that get stubs. The default is `both`. */
4983
+ readonly ends: StubEnds;
4984
+ /** A stub has this number of edges or more. The default is 2. */
4985
+ readonly minSize: number;
4986
+ }
4987
+ /** The default options of the strategy `stubs`. */
4988
+ export declare const STUB_DEFAULTS: Readonly<StubOptions>;
4989
+ /**
4990
+ * This function gives the highways of the plan `from`, with a stub at the ends of the edges (HWY-015, WILD-005).
4991
+ * The ends on one side of one box are sorted by the direction of their other node. A run of ends in a window of `omega` makes a group.
4992
+ * Each group of `minSize` ends or more shares one plug and one stub along the normal of the side. Then the edges fan out.
4993
+ *
4994
+ * The length of the stub is `sigma` times the distance to the nearest other node, and half that distance at most.
3489
4995
  * It is two times the margin of the way finder at least, and the stub stays out of the other boxes. Else the group gets no stub.
3490
4996
  * An end with a fixed plug or a side of its own gets no stub. An end whose first highway starts on its box, or near it, keeps the plan.
3491
4997
  */
3492
4998
  export declare function stubPlan(input: HighwayInput, o: Readonly<StubOptions>): HighwayPlan;
4999
+ /** The options of the highway strategy `traclus` (HWY-025 of the note on highways). */
5000
+ interface TraclusOptions extends Pick<WayOptions, "margin" | "k"> {
5001
+ /** Two segments are neighbours when their distance is this value or less, in units of the board. The default is 2. */
5002
+ readonly eps: number;
5003
+ /** A cluster has segments of this number of edges or more, and a core segment has this number of neighbours or more. The default is 3. */
5004
+ readonly minLns: number;
5005
+ /** The weight of the perpendicular distance. The default is 1. */
5006
+ readonly wPerp: number;
5007
+ /** The weight of the parallel distance. The default is 1. */
5008
+ readonly wPar: number;
5009
+ /** The weight of the angle distance. The default is 1. */
5010
+ readonly wTheta: number;
5011
+ /** A route keeps a corner when the cost of the line without it is more than this value times the cost with it. The default is 1. */
5012
+ readonly mdl: number;
5013
+ }
5014
+ /** The default options of the strategy `traclus`. */
5015
+ export declare const TRACLUS_DEFAULTS: Readonly<Required<Omit<TraclusOptions, "margin" | "k">>>;
5016
+ /** One segment of a partitioned route: the edge, the index of the segment in the route, and its two ends. */
5017
+ interface RouteSegment {
5018
+ readonly edge: string;
5019
+ readonly index: number;
5020
+ readonly a: Point;
5021
+ readonly b: Point;
5022
+ }
5023
+ /**
5024
+ * This function gives the TRACLUS distance of two segments (Lee, Han and Whang 2007): `w_perp d_perp + w_par d_par + w_theta d_theta`.
5025
+ * `d_perp` is `(l1² + l2²) / (l1 + l2)` with the distances of the ends of the shorter segment to the line of the longer segment.
5026
+ * `d_par` is the gap along the longer segment between the two segments, 0 when they overlap. `d_theta` is `|shorter| sin(theta)`.
5027
+ * The segments have no direction, so the angle is 90 degrees or less.
5028
+ */
5029
+ export declare function segmentDistance(p: {
5030
+ a: Point;
5031
+ b: Point;
5032
+ }, q: {
5033
+ a: Point;
5034
+ b: Point;
5035
+ }, w: {
5036
+ perp: number;
5037
+ par: number;
5038
+ theta: number;
5039
+ }): number;
5040
+ /**
5041
+ * This function gives the characteristic points of a route by the rule of the minimum description length (MDL) of TRACLUS.
5042
+ * A partition from point `i` to point `j` costs `L(H) + L(D|H)`. `L(H)` is the log of its length, and `L(D|H)` the logs of the perpendicular and angle distances of the route parts.
5043
+ * The route keeps the point before `j` when that cost is more than `ratio` times the cost of the route parts. The lengths are in units of the board.
5044
+ */
5045
+ export declare function characteristicPoints(route: readonly Point[], unit: number, ratio: number): Point[];
5046
+ /**
5047
+ * This function gives the clusters of segments of DBSCAN. A segment with `minLns` neighbours or more within `eps` (itself included) is a core segment.
5048
+ * A cluster grows from each core segment through its neighbours. A cluster with segments of fewer than `minLns` edges is dropped.
5049
+ */
5050
+ export declare function segmentClusters(segments: readonly RouteSegment[], eps: number, minLns: number, w: {
5051
+ perp: number;
5052
+ par: number;
5053
+ theta: number;
5054
+ }): RouteSegment[][];
5055
+ /**
5056
+ * This function gives the representative line of a cluster of segments. The line goes along the mean direction of the segments.
5057
+ * A sweep along that direction stops at each end of a segment. Where `minLns` segments or more cover the stop, the point is the mean of their points there.
5058
+ * Two points of the line are at least `gap` apart.
5059
+ */
5060
+ export declare function representative(cluster: readonly RouteSegment[], minLns: number, gap: number): Point[];
5061
+ /**
5062
+ * This function gives the highways of TRACLUS (HWY-025). Each first route breaks into a few long segments by the rule of MDL.
5063
+ * DBSCAN puts the segments that are near in distance and angle into clusters. Each cluster with segments of `minLns` edges or more is one highway.
5064
+ * The spine is the representative line of the cluster, or a way through the corner graph between its ends when the line hits a box.
5065
+ * Each edge of the cluster joins the spine nearest to the first end of its segments. It leaves the spine nearest to the last end.
5066
+ * An edge rides only when both ends of its part are within `eps` of the spine.
5067
+ * Its length on the spine is also at most 1.25 times the length of its own route there.
5068
+ * Each edge rides one highway at most: the highway where it rides the longest length.
5069
+ */
5070
+ export declare function traclusPlan(input: HighwayInput, o: Readonly<TraclusOptions>): HighwayPlan;
3493
5071
  /** The options of the highway strategy `weiszfeld` (HWY-043 of the note on highways). */
3494
5072
  interface WeiszfeldOptions {
3495
5073
  /** The plan whose highways get new meeting points. The default is `shared-ways`. */
@@ -3718,6 +5296,40 @@ export declare const highwayStrategies: {
3718
5296
  readonly wspd: Strategy<"highway", WspdOptions>;
3719
5297
  readonly "od-cells": Strategy<"highway", OdCellOptions>;
3720
5298
  readonly select: Strategy<"highway", SelectOptions>;
5299
+ readonly mingle: Strategy<"highway", MingleOptions>;
5300
+ readonly spiral: Strategy<"highway", SpiralOptions>;
5301
+ readonly "flow-clusters": Strategy<"highway", FlowClusterOptions>;
5302
+ readonly traclus: Strategy<"highway", TraclusOptions>;
5303
+ readonly diffusion: Strategy<"highway", DiffusionOptions>;
5304
+ readonly nested: Strategy<"highway", NestedOptions>;
5305
+ readonly lanes: Strategy<"highway", LanesOptions>;
5306
+ readonly growth: Strategy<"highway", GrowthOptions>;
5307
+ readonly "edge-paths": Strategy<"highway", EdgePathOptions>;
5308
+ readonly "soft-keys": Strategy<"highway", SoftKeyOptions>;
5309
+ readonly hough: Strategy<"highway", HoughOptions>;
5310
+ readonly ridges: Strategy<"highway", RidgeOptions>;
5311
+ readonly hdbscan: Strategy<"highway", HdbscanOptions>;
5312
+ readonly "hub-arcs": Strategy<"highway", HubArcOptions>;
5313
+ readonly divided: Strategy<"highway", DividedOptions>;
5314
+ readonly hierarchy: Strategy<"highway", HierarchyOptions>;
5315
+ readonly fdeb: Strategy<"highway", FdebOptions>;
5316
+ readonly mesh: Strategy<"highway", MeshOptions>;
5317
+ readonly kdeeb: Strategy<"highway", KdeebOptions>;
5318
+ readonly cubu: Strategy<"highway", CubuOptions>;
5319
+ readonly mlseb: Strategy<"highway", MlsebOptions>;
5320
+ readonly sbeb: Strategy<"highway", SbebOptions>;
5321
+ readonly areas: Strategy<"highway", AreaOptions>;
5322
+ readonly confluent: Strategy<"highway", ConfluentOptions>;
5323
+ readonly power: Strategy<"highway", PowerOptions>;
5324
+ readonly crossbars: Strategy<"highway", CrossbarOptions>;
5325
+ readonly frechet: Strategy<"highway", FrechetOptions>;
5326
+ readonly spectral: Strategy<"highway", SpectralOptions>;
5327
+ readonly resistance: Strategy<"highway", ResistanceOptions>;
5328
+ readonly "link-communities": Strategy<"highway", LinkCommunityOptions>;
5329
+ readonly territories: Strategy<"highway", TerritoryOptions>;
5330
+ readonly consensus: Strategy<"highway", ConsensusOptions>;
5331
+ readonly "p-hub": Strategy<"highway", PHubOptions>;
5332
+ readonly "scale-space": Strategy<"highway", ScaleSpaceOptions>;
3721
5333
  readonly "corridors+breakeven": Strategy<"highway", CorridorOptions & BreakEvenOptions>;
3722
5334
  readonly "corridors+stretch": Strategy<"highway", CorridorOptions & StretchOptions>;
3723
5335
  readonly "corridors+ambiguity": Strategy<"highway", CorridorOptions & AmbiguityGuardOptions>;
@@ -3802,18 +5414,12 @@ export interface StepComparison {
3802
5414
  * The same graph and the same options give the same measures. Only the times change.
3803
5415
  */
3804
5416
  export declare function compareStep(step: CompareStep, graph: Graph, options?: CompareOptions): StepComparison;
3805
- /** This function gives the bytes of a string in UTF-8. */
5417
+ /** This function gives the bytes of a string in UTF-8. The contract does not export its own `utf8`, so the core keeps this function. */
3806
5418
  export declare function utf8(text: string): Uint8Array;
3807
- /** This function gives the SHA-256 digest of a string, as 64 lowercase hex characters. It encodes the string in UTF-8. */
3808
- export declare function sha256Hex(text: string): string;
3809
- /**
3810
- * This function writes a value as canonical JSON: the keys of each object in sorted order, and no whitespace.
3811
- * It drops a key whose value is `undefined`, as `JSON.stringify` does.
3812
- */
3813
- export declare function canonicalJson(value: unknown): string;
3814
5419
  /**
3815
5420
  * This function gives the hash of a JSON document: the first 16 hex characters of the SHA-256 of its canonical JSON.
3816
5421
  * The document does not include its own field `hash`. The function removes that field before it calculates the hash.
5422
+ * The `documentHash` of the contract puts each number on a grid first, so it is not equal to this function. The hashes of the corpus files use this function.
3817
5423
  */
3818
5424
  export declare function documentHash(value: object): string;
3819
5425
  /** This function gives the 32-bit FNV-1a hash of the UTF-8 bytes of a text, as an unsigned integer. */
@@ -3822,7 +5428,7 @@ export declare function fnv1a32(text: string): number;
3822
5428
  export declare function stepSeed(seed: number, step: string): number;
3823
5429
  /** This function gives the generator `mulberry32` for a seed. Each call gives the next number from 0 to below 1. */
3824
5430
  export declare function mulberry32(seed: number): () => number;
3825
- /** This function rounds a number to 3 decimals, as the files of a corpus keep it. The value `-0` becomes `0`. */
5431
+ /** This function rounds a number to 3 decimals (a step of `RECORD_EPS`), as the files of a corpus keep it. The value `-0` becomes `0`. */
3826
5432
  export declare function round3(value: number): number;
3827
5433
  /** The side of a port in an input file. The router calls the same sides `north`, `east`, `south` and `west`. */
3828
5434
  export type LayoutSide = "top" | "right" | "bottom" | "left";
@@ -3884,8 +5490,8 @@ export interface LayoutBox {
3884
5490
  readonly parent?: string;
3885
5491
  /** The group of the box. */
3886
5492
  readonly group?: string;
3887
- /** This value is `true` when the box is an obstacle: the packer keeps its `x` and `y`. The router ignores it. */
3888
- readonly locked?: true;
5493
+ /** This value is `true` when the box is an obstacle: the packer keeps its `x` and `y`. `false` is the same as no value. The router ignores it. */
5494
+ readonly locked?: boolean;
3889
5495
  /** The reading order that the caller wants. The router ignores it. */
3890
5496
  readonly rank?: number;
3891
5497
  readonly ports?: readonly LayoutPort[];
@@ -3919,7 +5525,7 @@ export interface LayoutGenerator {
3919
5525
  * The packer reads the first six dimensions. The router reads the last four.
3920
5526
  */
3921
5527
  export interface LayoutCell {
3922
- readonly containerSize?: "fixed" | "freeWidth" | "freeAspect";
5528
+ readonly containerSize?: "fixed" | "freeHeight" | "freeWidth" | "freeAspect" | "freeArea";
3923
5529
  readonly containerShape?: "rect" | "convex" | "polygon" | "circle" | "ellipse" | "holes";
3924
5530
  readonly obstacles?: "none" | "center" | "scattered" | "wall" | "corridors" | "touching" | "edge";
3925
5531
  readonly sizes?: "identical" | "uniform" | "heavyTail" | "bimodal" | "extremeAspect" | "nearIdentical";
@@ -4014,6 +5620,19 @@ export interface LayoutRecord {
4014
5620
  readonly commit?: string;
4015
5621
  /** The reason when the strategy did not run, for example an input over its `maxNodes`. Then the record has no measures. */
4016
5622
  readonly skipped?: string;
5623
+ /**
5624
+ * The first 16 hex characters of the SHA-256 of the output in the highways form (ACTIVATION). `resultHash` gives it for a router.
5625
+ * Two records with the same hash have the same output, at the precision `RECORD_EPS`.
5626
+ */
5627
+ readonly outputHash?: string;
5628
+ /** The facts of the stages of the run. The trace measures `move.<name>` count the own move of the strategy (ACTIVATION). */
5629
+ readonly trace?: readonly RecordTrace[];
5630
+ }
5631
+ /** The facts of one stage of a run, as the `StageTrace` of the contract: its id, its time and its trace measures. */
5632
+ export interface RecordTrace {
5633
+ readonly id: string;
5634
+ readonly ms?: number;
5635
+ readonly measures?: Readonly<Record<string, number>>;
4017
5636
  }
4018
5637
  /** The comparison of a prediction. Without it, `<=` applies to a measure where lower is better, and `>=` to the other measures. */
4019
5638
  export type PredictionOp = "<" | "<=" | "=" | ">=" | ">";
@@ -4045,13 +5664,20 @@ export declare function regionBounds(region: Region): {
4045
5664
  w: number;
4046
5665
  h: number;
4047
5666
  };
5667
+ /**
5668
+ * The fields of an input that `inputGraph` reads. A contract input, for example the result of `applyPack`, has these fields.
5669
+ * Without `edges`, the input has no edges.
5670
+ */
5671
+ export type RouteInput = Pick<LayoutInput, "id" | "boxes" | "obstacles"> & {
5672
+ readonly edges?: LayoutInput["edges"];
5673
+ };
4048
5674
  /**
4049
5675
  * This function reads the graph of the router from an input file. The router reads the positions, the ports, the edges and the data.
4050
5676
  * Each obstacle becomes a node without edges, with the bounding box of its region, after the boxes.
4051
5677
  * The router ignores the other fields of the packer: `container`, `gap`, `locked`, `rank`, the `shape` of a box and the `move` of an obstacle.
4052
5678
  * A box without `x` and `y` is an error.
4053
5679
  */
4054
- export declare function inputGraph(input: LayoutInput): Graph;
5680
+ export declare function inputGraph(input: RouteInput): Graph;
4055
5681
  /**
4056
5682
  * This function writes an input file as text: the keys in sorted order, and one box or one edge on each line.
4057
5683
  * `JSON.parse` of the text gives the input again.
@@ -4066,6 +5692,21 @@ export declare function parseLines<T>(text: string): T[];
4066
5692
  * A function becomes the text `function:<name>`, and a number that is not finite becomes its text.
4067
5693
  */
4068
5694
  export declare function jsonSafe(value: unknown): unknown;
5695
+ /**
5696
+ * The smallest change of a measure that counts as better or worse (WIN-RES).
5697
+ * A number is an absolute change. `{ rel }` is a share of the larger of the two absolute values.
5698
+ * The threshold is not less than `RECORD_EPS` at any time.
5699
+ */
5700
+ export type MinEffect = NonNullable<MeasureSpec["minEffect"]>;
5701
+ /** The result of a compare of a candidate with a baseline on one measure. A tie is not a win. It is the `Verdict` of the contract. */
5702
+ export type MeasureCompare = Verdict;
5703
+ /** The part of a measure that a compare reads: the better side and the minimum effect. */
5704
+ export type CompareSpec = Pick<MeasureSpec, "direction" | "minEffect">;
5705
+ /**
5706
+ * This function applies the wave rule to the compares of one board, for example of `B1` and of the `B3` q95.
5707
+ * The board is a win only when no compare is `worse` and one or more compares are `better`. Thus a board of ties is not a win.
5708
+ */
5709
+ export declare function boardWins(compares: readonly MeasureCompare[]): boolean;
4069
5710
  /**
4070
5711
  * One measure of a record. `key` is the key of the measure in the values of `runSuite` and `compareStep`.
4071
5712
  * `name` is the name of the measure in a record of the form `layout-record/1`.
@@ -4084,13 +5725,32 @@ export interface MeasureInfo {
4084
5725
  * Then two values compare only on the same input. The value is `false` when the measure scores the routes or the curves for a fixed placement.
4085
5726
  */
4086
5727
  readonly placementDependent: boolean;
5728
+ /**
5729
+ * The smallest change that counts as better or worse in `compareMeasure` (WIN-RES). `MIN_EFFECTS` gives it by the unit, with its reason.
5730
+ * A measure without this field has the threshold `RECORD_EPS`.
5731
+ */
5732
+ readonly minEffect?: MinEffect;
4087
5733
  }
5734
+ /** One rule of `MIN_EFFECTS`: the units, the minimum effect of a measure with one of these units, and the reason. */
5735
+ export interface MinEffectRule {
5736
+ readonly units: readonly string[];
5737
+ /** The minimum effect. The value `undefined` gives the threshold `RECORD_EPS`. */
5738
+ readonly minEffect: MinEffect | undefined;
5739
+ readonly reason: string;
5740
+ }
5741
+ /**
5742
+ * The minimum effect of each measure of `MEASURES`, by the unit of the measure (WIN-RES).
5743
+ * Each unit of `MEASURES` is in one rule. The test of the module checks it.
5744
+ */
5745
+ export declare const MIN_EFFECTS: readonly MinEffectRule[];
4088
5746
  /**
4089
5747
  * The measures of the records of the stage `route`, with the placement dependence of each one.
4090
5748
  * A joint harness that moves the boxes and routes the edges reads `placementDependent`.
4091
5749
  * It compares a measure with the value `true` only between runs on the same input.
4092
5750
  */
4093
5751
  export declare const MEASURES: readonly MeasureInfo[];
5752
+ /** This function gives the spec of a compare of a measure: its better side and its minimum effect. */
5753
+ export declare function compareSpec(info: MeasureInfo): CompareSpec;
4094
5754
  /** This function gives the measure of a key of `runSuite` or `compareStep`, or `undefined` for a key that is not in `MEASURES`. */
4095
5755
  export declare function measureByKey(key: string): MeasureInfo | undefined;
4096
5756
  /** This function gives the measure of a name of a record, or `undefined` for a name that is not in `MEASURES`. */
@@ -4126,7 +5786,7 @@ export interface ScreenSet {
4126
5786
  * This set does not change. The tests compare it with the files in `corpus/screen-v1`.
4127
5787
  */
4128
5788
  export declare const SCREEN_V1: ScreenSet;
4129
- /** The screen sets by id. */
5789
+ /** The screen sets by id: `screen-v1`, the small boards with a known optimum `exact-v1` (MEAS2), and the larger boards with bounds `exact-v1-bounds` (EXACT-BOUNDS). */
4130
5790
  export declare const SCREEN_SETS: Readonly<Record<string, ScreenSet>>;
4131
5791
  /** This function gives the id of the member `seed` of a family of a set: `<set>/<family>/s<seed>`. */
4132
5792
  export declare function inputId(set: string, family: string, seed: number): string;
@@ -4152,6 +5812,257 @@ export interface LayoutCorpus {
4152
5812
  }
4153
5813
  /** This function gives the manifest of a list of inputs. The inputs of one generator, version and parameters share one spec. */
4154
5814
  export declare function corpusManifest(corpus: string, inputs: readonly LayoutInput[]): LayoutCorpus;
5815
+ /**
5816
+ * This function gives the output hash of a result of a router, in the highways form.
5817
+ * The form holds the routes in the order of the edge ids, and the levels, the bundles and the runs as the router gives them.
5818
+ * Each number goes to the grid `RECORD_EPS`, as `round3` does.
5819
+ */
5820
+ export declare function resultHash(result: Result): string;
5821
+ /** This function gives the highways form of a result of a router: the value that `resultHash` hashes. */
5822
+ export declare function resultForm(result: Result): object;
5823
+ /** This function gives the output hash of the curves of the step `curve`, in the order of the edge ids. */
5824
+ export declare function curvesHash(edges: readonly string[], curves: readonly (readonly CurveSegment[])[]): string;
5825
+ /**
5826
+ * The name of the own move of each built-in highway finder. The trace of a record names the count `move.<name>`.
5827
+ * The count is the number of highways of the plan with 2 edges or more. A finder without an entry counts `move.highway`.
5828
+ */
5829
+ export declare const MOVE_NAMES: Readonly<Record<string, string>>;
5830
+ /**
5831
+ * The highway strategies that change the plan of another strategy (`from`). Their own move is a change of that plan, so they count no move.
5832
+ * The output against the plan `from` tells if they ran.
5833
+ */
5834
+ export declare const PLAN_CHANGERS: readonly string[];
5835
+ /**
5836
+ * This function gives the built-in highway strategy of a name: the strategy itself, or the strategy of a variant, for example `power` for `power-near`.
5837
+ * It gives `undefined` for a gate (a name with `+`) and for a name of another step.
5838
+ */
5839
+ export declare function finderOf(name: string): string | undefined;
5840
+ /**
5841
+ * This function gives the count of the own move of a highway strategy on its plan, for example `{ "move.powerEdge": 3 }`.
5842
+ * It gives `undefined` for a gate and for a strategy of `PLAN_CHANGERS`.
5843
+ */
5844
+ export declare function planMoves(name: string, plan: HighwayPlan): Record<string, number> | undefined;
5845
+ /** A function that gives the own move counts of a strategy on a graph, or `undefined` for a strategy without a count. */
5846
+ export type MoveCounter = (strategy: string, graph: Graph) => Readonly<Record<string, number>> | undefined;
5847
+ /** This function gives a `MoveCounter` for highway strategies, by the names of the records. It makes the plan of the strategy again. */
5848
+ export declare function highwayMoves(strategies: Readonly<Record<string, Strategy<"highway", object>>>): MoveCounter;
5849
+ /**
5850
+ * This function gives the base of a strategy for the fallback test: the strategy that it falls back to or extends.
5851
+ * - A gate `X+G` and a wrapped router `X+W` have the base `X`.
5852
+ * - A highway finder of a module (`hw:power`, `w3e:power-near`) has the base `hw:none`, the empty plan.
5853
+ * - A plan changer has the base of its plan `from`: `hw:shared-ways`, or `hw:corridors` and `hw:none` for a name that ends with `-corridors` and `-none`.
5854
+ * - An option of a router (`shared-cap-3`, `shared-all-p3`, `trunks-tree-bf02`, `corners-side`) has the base `shared`, `shared-all`, `trunks` or `corners`.
5855
+ * The function gives `undefined` when the base is not in `known`.
5856
+ */
5857
+ export declare function activationBase(name: string, known: ReadonlySet<string>): string | undefined;
5858
+ /** The activation of one strategy over the decision inputs of a screen. */
5859
+ export interface ActivationRow {
5860
+ readonly strategy: string;
5861
+ /** The base of the fallback test, or `undefined` when the strategy has none. */
5862
+ readonly base?: string;
5863
+ /** The decision inputs where the strategy ran. */
5864
+ readonly inputs: number;
5865
+ /** The decision inputs where a move count is above 0. */
5866
+ readonly moved: readonly string[];
5867
+ /** The decision inputs where the output differs from the output of the base. */
5868
+ readonly differs: readonly string[];
5869
+ /** The sum of each move count over the decision inputs. */
5870
+ readonly moves: Readonly<Record<string, number>>;
5871
+ readonly verdict: "exercised" | "not-exercised";
5872
+ /** The id of the output group of the strategy on the decision inputs. */
5873
+ readonly group: string;
5874
+ }
5875
+ /** The groups of the strategies with equal output on each input of one cell (a family of boards). They are diagnostics only. */
5876
+ export interface CellGroups {
5877
+ readonly cell: string;
5878
+ readonly groups: readonly OutputGroup[];
5879
+ }
5880
+ /** The activation report of a screen. */
5881
+ export interface ActivationReport {
5882
+ /** The decision inputs, in sorted order. */
5883
+ readonly inputs: readonly string[];
5884
+ readonly rows: readonly ActivationRow[];
5885
+ /** The output groups with more than one strategy: equal output hashes on each decision input. */
5886
+ readonly groups: readonly OutputGroup[];
5887
+ /** The cell groups with more than one strategy, for each family of the decision inputs. */
5888
+ readonly cells: readonly CellGroups[];
5889
+ }
5890
+ /** This function gives the family of an input id, for example `small-clustered` for `screen-v1/small-clustered/s0`. */
5891
+ export declare function familyOf(input: string): string;
5892
+ /** This function gives the move counts of a record, from its trace. */
5893
+ export declare function recordMoves(record: LayoutRecord): Record<string, number>;
5894
+ /**
5895
+ * This function gives the activation report of the records of a screen.
5896
+ * A strategy is exercised when a move count is above 0 on a decision input.
5897
+ * It is also exercised when its output differs from the output of its base on a decision input.
5898
+ * The decision inputs are the inputs of the families `families`, or each input. `bases` gives the base of each strategy, or `activationBase` gives it.
5899
+ */
5900
+ export declare function activationReport(records: readonly LayoutRecord[], options?: {
5901
+ readonly families?: readonly string[];
5902
+ readonly bases?: Readonly<Record<string, string>>;
5903
+ }): ActivationReport;
5904
+ /** This function writes the activation report as Markdown: the strategies that are not exercised, and the output groups. */
5905
+ export declare function formatActivation(report: ActivationReport, candidates?: ReadonlySet<string>): string;
5906
+ /** The rule of the exact model: `collection` lets only the edges of one collection share a link, and `all` lets each edge share a link. */
5907
+ export type GapRule = "collection" | "all";
5908
+ /** The rules of the gap closed, in the order of the records. */
5909
+ export declare const GAP_RULES: readonly GapRule[];
5910
+ /**
5911
+ * A view of the gap closed: one rule, or `chosen`. The view `chosen` takes a rule for each run.
5912
+ * It takes `all` when a shared segment of the run holds edges of two collections. Else it takes `collection`.
5913
+ */
5914
+ export type GapView = GapRule | "chosen";
5915
+ /** The views of the gap closed, in the order of the tables. */
5916
+ export declare const GAP_VIEWS: readonly GapView[];
5917
+ /** The stretch caps of the exact optima, from small to large. */
5918
+ export declare const GAP_CAPS: readonly number[];
5919
+ /** The baseline of each rule: the router `shared` for `collection`, and the plan `shared-ways-all` after `follow` for `all`. */
5920
+ export declare const GAP_BASELINES: Readonly<Record<GapRule, string>>;
5921
+ /** The parameters of the paired bootstrap of the gap closed, from `docs/PROMOTION.md`. */
5922
+ export declare const GAP_BOOTSTRAP: {
5923
+ readonly runs: number;
5924
+ readonly level: number;
5925
+ readonly seed: number;
5926
+ };
5927
+ /** The optimum of the exact model on one input, for one rule and one stretch cap. The file of the optima of a set holds one for each. */
5928
+ export interface ExactOptimum {
5929
+ /** The id of the input. */
5930
+ readonly input: string;
5931
+ /** The hash of the input file. The screen uses the optimum only when the hash matches. */
5932
+ readonly hash: string;
5933
+ /** The class of the input: its family in the set. */
5934
+ readonly class: string;
5935
+ readonly nodes: number;
5936
+ readonly edges: number;
5937
+ readonly rule: GapRule;
5938
+ readonly cap: number;
5939
+ /** The status of HiGHS: `optimal`, `time-limit` or another status. */
5940
+ readonly status: string;
5941
+ /** This value is `true` when HiGHS proved the optimum within the time limit. */
5942
+ readonly proven: boolean;
5943
+ /** The objective of the best solution, the dual bound and the relative MIP gap. Each one is `null` when HiGHS gives none. */
5944
+ readonly objective: number | null;
5945
+ readonly bound: number | null;
5946
+ readonly mipGap: number | null;
5947
+ /** The time of the solve, in seconds. */
5948
+ readonly seconds: number;
5949
+ /** The number of binary variables of the model. */
5950
+ readonly binaries: number;
5951
+ /** The ink saved (B1) of the routes of the best plan after `follow`. The gap closed uses this value. */
5952
+ readonly b1: number | null;
5953
+ /** The ink saved of the model itself, without `follow`. */
5954
+ readonly modelB1: number | null;
5955
+ /** The largest bundle stretch (B3) of the routes of the best plan, against the routes of `corners`. */
5956
+ readonly b3max: number | null;
5957
+ /** The number of highways of the best plan. */
5958
+ readonly highways: number;
5959
+ }
5960
+ /** The file of the optima of a set (`exact-optima/1`). Later screens read it and do not solve again. */
5961
+ export interface ExactOptimaFile {
5962
+ readonly schema: "exact-optima/1";
5963
+ readonly set: string;
5964
+ /** The time limit of each solve, in seconds. */
5965
+ readonly seconds: number;
5966
+ /** The commit of the code and the CI run of the solves. */
5967
+ readonly commit?: string;
5968
+ readonly run?: string;
5969
+ readonly optima: readonly ExactOptimum[];
5970
+ }
5971
+ /** This function gives the file of the optima of a set, with the rows in the order of the input, the rule and the cap. */
5972
+ export declare function optimaFile(set: string, rows: readonly ExactOptimum[], at: {
5973
+ readonly seconds: number;
5974
+ readonly commit?: string;
5975
+ readonly run?: string;
5976
+ }): ExactOptimaFile;
5977
+ /** This function gives the key of an optimum in a map: the input, the rule and the cap. */
5978
+ export declare function optimumKey(input: string, rule: GapRule, cap: number): string;
5979
+ /** This function gives the smallest cap that is at least the stretch, or `undefined` when the stretch is above the largest cap. */
5980
+ export declare function gapCap(stretch: number, caps?: readonly number[]): number | undefined;
5981
+ /**
5982
+ * This function gives the gap closed: `(b1 - base) / (optimum - base)`.
5983
+ * It gives `undefined` when the denominator is 0 or less, because then the baseline is at the optimum or above it.
5984
+ */
5985
+ export declare function gapClosed(b1: number, base: number, optimum: number): number | undefined;
5986
+ /**
5987
+ * This function gives the largest bundle stretch of routes against base routes: the max of `L(r_e) / L(r*_e)` over the edges, as B3 counts them.
5988
+ * An edge without a base route, or with a base route of 1 unit or less, does not count. Without such an edge, the value is 1.
5989
+ */
5990
+ export declare function maxStretch(routes: readonly Route[], base: readonly Route[]): number;
5991
+ /** The highway strategy `shared-ways-all`: the plan of the router `shared` without a rule. It is the baseline of the rule `all`. */
5992
+ export declare const sharedWaysAll: Strategy<"highway", object>;
5993
+ /** This function gives the B1 of the baseline of each rule on a graph. */
5994
+ export declare function gapBaselines(graph: Graph): Record<GapRule, number>;
5995
+ /** A median with its paired bootstrap interval. */
5996
+ export interface BootstrapMedian {
5997
+ readonly median: number;
5998
+ readonly lo: number;
5999
+ readonly hi: number;
6000
+ }
6001
+ /**
6002
+ * This function gives the median of the values and its bootstrap interval: `runs` samples of the values with replacement, from the seed `seed`.
6003
+ * The interval is the central `level` share of the medians of the samples. Each value is the paired value of one input, so the bootstrap is paired.
6004
+ */
6005
+ export declare function bootstrapMedian(values: readonly number[], o?: {
6006
+ readonly runs?: number;
6007
+ readonly level?: number;
6008
+ readonly seed?: number;
6009
+ }): BootstrapMedian;
6010
+ /** The gap closed of one strategy and one view over the inputs of a screen. */
6011
+ export interface GapSummary {
6012
+ readonly strategy: string;
6013
+ readonly rule: GapView;
6014
+ /** The number of runs, and the number of runs with a value. A run has no value above the largest cap, or without a proven optimum. */
6015
+ readonly runs: number;
6016
+ readonly values: number;
6017
+ /** The median over the inputs with a value, and its paired bootstrap interval. */
6018
+ readonly median: number;
6019
+ readonly lo: number;
6020
+ readonly hi: number;
6021
+ /** The median of each class, by the family of the input. */
6022
+ readonly byClass: Readonly<Record<string, number>>;
6023
+ /** The number of values at each cap, by the cap. */
6024
+ readonly caps: Readonly<Record<string, number>>;
6025
+ /** The number of runs with some ink saved (B1 above 0): the runs where the strategy builds a shared segment. */
6026
+ readonly builds: number;
6027
+ /** The number of runs where a shared segment holds edges of two collections. */
6028
+ readonly mixed: number;
6029
+ }
6030
+ /** The names of the measures of the gap closed in a record, for a view. */
6031
+ export declare function gapNames(view: GapView): {
6032
+ readonly gap: string;
6033
+ readonly cap: string;
6034
+ };
6035
+ /**
6036
+ * This function gives the gap closed of each strategy and view over records.
6037
+ * It sorts them by the view and then by the median, from high to low.
6038
+ * A strategy with a value on fewer than half of its runs comes after the others, because its median shows only a few inputs.
6039
+ */
6040
+ export declare function summarizeGap(records: readonly {
6041
+ readonly strategy: string;
6042
+ readonly input: string;
6043
+ readonly skipped?: string;
6044
+ readonly measures: Readonly<Record<string, number>>;
6045
+ }[]): GapSummary[];
6046
+ /** This function writes the gap closed as Markdown: one table for each view, sorted by the median. */
6047
+ export declare function formatGap(rows: readonly GapSummary[]): string;
6048
+ /** This function gives the count of the shared segments of a result (the runs and the bundles) that hold edges of two collections or more. */
6049
+ export declare function mixedSegments(graph: Graph, result: Result): number;
6050
+ /** This function tells if a shared segment of a result (a run or a bundle) holds edges of two collections. */
6051
+ export declare function mixesCollections(graph: Graph, result: Result): boolean;
6052
+ /**
6053
+ * This function gives the gap measures of the result of one run on an input with optima, by the keys of `MEASURES`.
6054
+ * `B3.max` is the largest stretch against the routes of `corners`. `gap.stretch` is the largest stretch as the exact model counts it (`exactStretch`).
6055
+ * The cap is the smallest cap at or above `gap.stretch`, so both sides of the gap have the same stretch limit.
6056
+ *
6057
+ * `gap.<rule>` is the gap closed at the cap `gap.cap.<rule>`. `gap` is the gap closed of the rule of the run.
6058
+ * That rule is `all` when `gap.mixed` is 1, else `collection`.
6059
+ * A rule has no value above the largest cap or without a proven optimum at the cap.
6060
+ * It also has no value when the hash of the optimum is not the hash of the input.
6061
+ */
6062
+ export declare function gapValues(input: {
6063
+ readonly id: string;
6064
+ readonly hash: string;
6065
+ }, graph: Graph, result: Result, corners: readonly Route[], baselines: Readonly<Record<GapRule, number>>, optima: ReadonlyMap<string, ExactOptimum>): Record<string, number>;
4155
6066
  /**
4156
6067
  * The steps of the screen: the steps of `compareStep` and the step `highway`.
4157
6068
  * The screen of the step `highway` routes the plan of each strategy with `follow`, and measures the routes as the routes of a router.
@@ -4214,6 +6125,16 @@ export interface ScreenOptions {
4214
6125
  readonly commit?: string;
4215
6126
  /** The predictions of the run. Each record names the first prediction with its strategy, its set and its input. */
4216
6127
  readonly predictions?: readonly LayoutPrediction[];
6128
+ /**
6129
+ * The exact optima of the inputs, from the file of the optima of a set (MEAS2). The steps `router` and `highway` read them.
6130
+ * Each run on an input with optima gets the largest B3 and the gap closed of each rule (B10). The summary then gets the gap table.
6131
+ */
6132
+ readonly optima?: readonly ExactOptimum[];
6133
+ /**
6134
+ * This function gives the own move counts of a strategy on an input (ACTIVATION), for example `{ "move.powerEdge": 3 }`.
6135
+ * Each record of a strategy with counts gets them as the trace measures of its step. The default is no counts.
6136
+ */
6137
+ readonly moves?: MoveCounter;
4217
6138
  /** This function gets one line of progress for each input. */
4218
6139
  readonly log?: (line: string) => void;
4219
6140
  }
@@ -4267,6 +6188,8 @@ export interface ScreenSummary {
4267
6188
  /** The strategies with a break over the floor, without a run or with two different outputs of one input. They do not enter the front. */
4268
6189
  readonly excluded: readonly string[];
4269
6190
  readonly predictions: readonly PredictionCheck[];
6191
+ /** The gap closed of each strategy and rule, when the screen has optima. */
6192
+ readonly gap?: readonly GapSummary[];
4270
6193
  }
4271
6194
  /** The result of `screen`: one record for each strategy and input, and the summary. */
4272
6195
  export interface ScreenReport {
@@ -4302,6 +6225,48 @@ export interface RectScatteredParams {
4302
6225
  * The steps are `container`, `obstacles` and `boxes`. Each step has its own generator from `stepSeed`.
4303
6226
  */
4304
6227
  export declare function rectScattered(seed: number, params: RectScatteredParams, set?: string): LayoutInput;
6228
+ /** The board classes of the small boards with a known optimum (MEAS2). */
6229
+ export type ExactClass = "uniform" | "clustered" | "hubs" | "fanout";
6230
+ /** The board classes of `EXACT_V1`, in the order of the set. */
6231
+ export declare const EXACT_CLASSES: readonly ExactClass[];
6232
+ /** The edges of each node of a small board with a known optimum. */
6233
+ export declare const EXACT_EDGES_PER_NODE = 1.5;
6234
+ /** This function gives the seed of the fixture of the member `k` of a class: `100 × (the index of the class + 1) + k`. */
6235
+ export declare function exactSeed(cls: ExactClass, k: number): number;
6236
+ /** This function gives the generator of a small board: the generator `fixture` with the kind of the class, `nodes` and the seed of `exactSeed`. */
6237
+ export declare function exactGenerator(cls: ExactClass, nodes: number, k: number): LayoutGenerator;
6238
+ /** This function makes the small board of a class with `nodes` nodes and the member `k`. The same values always give the same graph. */
6239
+ export declare function exactBoard(cls: ExactClass, nodes: number, k: number): Graph;
6240
+ /**
6241
+ * This function gives a family of small boards of one class. The member `k` has `sizes[k mod sizes.length]` nodes.
6242
+ * The count of the cell is `10`, because each board has fewer than 100 nodes.
6243
+ */
6244
+ export declare function exactFamily(cls: ExactClass, sizes: readonly number[], seeds: number): ScreenFamily;
6245
+ /**
6246
+ * The node counts of the boards of `EXACT_V1`. The member `k` of each class has `EXACT_V1_SIZES[k mod length]` nodes.
6247
+ * The size ladder of MEAS2 (CI run 40613531631) proved each optimum at 10 nodes within 300 s, for each class, both rules and the cap 1.5.
6248
+ * At 14 nodes, 4 of 24 solves stopped at the time limit.
6249
+ */
6250
+ export declare const EXACT_V1_SIZES: readonly number[];
6251
+ /** The number of seeds of each class of `EXACT_V1`. It is `cellMin` of the promotion rule. */
6252
+ export declare const EXACT_V1_SEEDS = 10;
6253
+ /**
6254
+ * The screen set `exact-v1` (MEAS2): small boards of made-up data with a known optimum of the exact model.
6255
+ * It has 4 classes of 10 seeds. The file `optima-exact-v1.json` of `bench/exact` keeps the optimum of each input, each rule and each cap.
6256
+ * This set does not change. The tests compare it with the files in `corpus/exact-v1`.
6257
+ */
6258
+ export declare const EXACT_V1: ScreenSet;
6259
+ /** The node counts of the boards of `EXACT_V1_BOUNDS`. HiGHS proves few optima at these sizes within 300 s, so the set keeps bounds (EXACT-BOUNDS). */
6260
+ export declare const EXACT_V1_BOUNDS_SIZES: readonly number[];
6261
+ /** This function gives the name of the family of a class at a size in `EXACT_V1_BOUNDS`: `<class>-n<nodes>`. */
6262
+ export declare function boundsFamilyName(cls: ExactClass, nodes: number): string;
6263
+ /**
6264
+ * The screen set `exact-v1-bounds` (EXACT-BOUNDS): the boards of the classes of `exact-v1` at 18, 24 and 40 nodes, with 10 seeds each.
6265
+ * Each family is one class at one size. The member `k` uses the seed `exactSeed(class, k)`, as in `exact-v1`.
6266
+ * The file `optima-exact-v1-bounds.json` of `bench/exact` keeps the best bound and the best solution of each input, each rule and each cap.
6267
+ * This set does not change. The tests compare it with the files in `corpus/exact-v1-bounds`.
6268
+ */
6269
+ export declare const EXACT_V1_BOUNDS: ScreenSet;
4305
6270
  /** The options of `follow`. */
4306
6271
  interface FollowOptions extends WayOptions {
4307
6272
  /**
@@ -4378,6 +6343,41 @@ interface SharedStretchOptions {
4378
6343
  * The `seq` of each member follows the order of the stretches along the way.
4379
6344
  */
4380
6345
  export declare function sharedStretches(ways: readonly KeyedWay[], o: Readonly<SharedStretchOptions>): HighwayPlan;
6346
+ /** The options of `tracePlan`. */
6347
+ interface TraceOptions {
6348
+ /** The side of the grid that the waypoints snap to, in units of the board. The value 0 keeps each waypoint where it is. */
6349
+ readonly snap: number;
6350
+ /** A highway has this number of edges or more. The value is 2 or more. */
6351
+ readonly minSize: number;
6352
+ /** The key of the ways. Only the ways with one key share a highway. */
6353
+ readonly key: string;
6354
+ }
6355
+ /**
6356
+ * This function moves a point out of each box, made larger by `pad`. A point in a box moves to the nearest side of that box.
6357
+ * The function tries four times, so a point between two near boxes can stay in a box.
6358
+ */
6359
+ export declare function outOfBoxes(obstacles: Obstacles, p: Point, pad: number): Point;
6360
+ /**
6361
+ * This function gives the push of the boxes on a point. Each box nearer than `reach` adds a unit vector away from it, times `(reach - d) / reach`.
6362
+ * The value `d` is the distance from the point to the box. It is the gradient of a field that is 0 at the distance `reach` from each box.
6363
+ */
6364
+ export declare function boxPush(obstacles: Obstacles, p: Point, reach: number): Point;
6365
+ /** This function gives points at equal steps of `step` or a little less along a polyline, without its two ends. A polyline without length gives no point. */
6366
+ export declare function innerPoints(line: readonly Point[], step: number): Point[];
6367
+ /**
6368
+ * This function gives the way of one edge through its waypoints. The way starts at `a` and ends at `b`.
6369
+ * Each waypoint snaps to the grid of side `snap`. A waypoint in a box moves to the nearest corner of the corner graph.
6370
+ * From each waypoint to the next one, the way is a straight line when that line is clear. Otherwise it goes through the corner graph.
6371
+ * A waypoint that the graph does not reach is not on the way. When the way cannot reach `b`, the function gives the way of the corner graph from `a` to `b`.
6372
+ */
6373
+ export declare function waypointWay(finder: WayFinder, a: Point, b: Point, waypoints: readonly Point[], snap: number): Point[] | undefined;
6374
+ /**
6375
+ * This function gives the highways of the waypoints of each edge. The ways go through the corner graph, so they stay out of the boxes.
6376
+ * Each edge goes from the point at `margin` from its source plug, through its waypoints, to the point at `margin` from its target plug.
6377
+ * Each stretch that `minSize` ways or more share is one highway, with the needless corners removed.
6378
+ * An edge without waypoints takes its way of the corner graph.
6379
+ */
6380
+ export declare function tracePlan(input: HighwayInput, finder: WayFinder, waypoints: ReadonlyMap<string, readonly Point[]>, o: Readonly<TraceOptions>): HighwayPlan;
4381
6381
  /**
4382
6382
  * This function gives the graph with its edges in the stable order of WILD-053: by the FNV-1a hash of the id, then by the id.
4383
6383
  * The nodes and the edges do not change. Two orders of the same edges give the same graph.
@@ -4486,5 +6486,145 @@ export declare function withRepair(router: Router, options?: RepairOptions): Rou
4486
6486
  * The new strategy has the name `<name>+repair`, and the options and the schema of `strategy`. The strategy `strategy` does not change.
4487
6487
  */
4488
6488
  export declare function repairStrategy<O extends object>(strategy: Strategy<"router", O>, repair?: RepairOptions): Strategy<"router", O>;
4489
- export type { AmbiguityGuardOptions, ArcOptions, BreakEvenOptions, BundleLine, BundleOrder, CandidateSource, ClothoidOptions, CornersOptions, CorridorOptions, CurveSpace, CutObjective, CutOptions, EdgeGroup, EdgeLengths, EdgePlugs, FieldEnd, FlowFieldOptions, FollowOptions, Gate, GroupSpine, GroupedOptions, Highway, HighwayBase, HighwayInput, HighwayMember, HighwayOptions, HighwayPlan, HysteresisOptions, JogStyle, KdAxis, KdLine, KdOptions, KeyOptions, KeyedWay, KeysOptions, LaneCurve, LevelHighwayOptions, MeetOptions, NodeKey, OdCellOptions, QuickBundlesOptions, RoadClassOptions, RoomBends, RoundedOptions, SectionsOptions, SelectOptions, ShareCost, ShareMerge, ShareOrder, SharedOptions, SharedStretchOptions, SharedWaysOptions, SmoothOptions, SplineOptions, SplitCell, StableIdOptions, StretchOptions, StubEnds, StubOptions, TrunkFan, TrunkSplit, TrunksOptions, WeiszfeldOptions, WspdOptions, Zip, ZipLimits, ZipperOptions };
6489
+ /** The rule of the caller. Under `collection`, a shared segment holds edges of one collection only. Under `all`, collections can mix. */
6490
+ export type PortfolioRule = "collection" | "all";
6491
+ /** The stretch caps of the portfolio router: the caps of the gap closed (B10). */
6492
+ export type PortfolioCap = 1.1 | 1.25 | 1.5;
6493
+ /** The rules of the portfolio router. */
6494
+ export declare const PORTFOLIO_RULES: readonly PortfolioRule[];
6495
+ /** The caps of the portfolio router. */
6496
+ export declare const PORTFOLIO_CAPS: readonly PortfolioCap[];
6497
+ /** The sizes of the sets of the portfolio router, without the base. */
6498
+ export declare const PORTFOLIO_KS_API: readonly (3 | 5 | 8)[];
6499
+ /** One size band of the inputs. Each band has its own greedy sets. */
6500
+ export interface PortfolioBand {
6501
+ readonly id: string;
6502
+ /** The largest node count of the band. An input with more nodes than the last band uses the last band. */
6503
+ readonly maxNodes: number;
6504
+ }
6505
+ /** The size bands: up to 12 nodes, 13 to 24 nodes, and 25 to 40 nodes. An input above 40 nodes uses the band `n25-40`. */
6506
+ export declare const PORTFOLIO_BANDS: readonly PortfolioBand[];
6507
+ /** This function gives the band of a node count: the first band whose `maxNodes` is the count or more, else the last band. */
6508
+ export declare function portfolioBand(nodes: number, bands?: readonly PortfolioBand[]): PortfolioBand;
6509
+ /**
6510
+ * The fit of each rule, cap and size band, by the key `<rule>|<cap>|<band>`: the members of the default of the portfolio router, in their order.
6511
+ * Each member has a node limit: it runs only on an input with that many nodes or fewer. The limits keep the model time at or below 40 ms.
6512
+ * The base `shared` is not in a fit: the portfolio always runs it first.
6513
+ */
6514
+ export declare const PORTFOLIO_FIT: Readonly<Record<`${PortfolioRule}|${PortfolioCap}|${string}`, readonly (readonly [string, number])[]>>;
6515
+ /** The id of the B1 level of the key of the portfolio router. */
6516
+ export declare const PORTFOLIO_B1 = "B1";
6517
+ /** This function gives the spec of the B1 level: higher is better, with the `minEffect` of the row `B1.inkSaved` of the table `MEASURES`. */
6518
+ export declare function portfolioB1Spec(): CompareSpec;
6519
+ /** The facts of one output that the guard reads. The router takes them from the output, and the script `portfolio.ts` from a record. */
6520
+ export interface PortfolioFacts {
6521
+ /** The count of the breaks of each hard rule. */
6522
+ readonly hard: Readonly<Record<string, number>>;
6523
+ /** The count of the edges with a stretch above each cap, by the cap. The largest stretch of a record gives 1 or 0. */
6524
+ readonly over: (cap: number) => number;
6525
+ /** The count of the shared segments that hold edges of two collections. */
6526
+ readonly mixed: number;
6527
+ }
6528
+ /**
6529
+ * This function gives the count of the breaks of the guard of an output against the base, with the rule `rule` and the cap `cap`.
6530
+ * The count is the sum of three parts:
6531
+ * - for each hard rule, the breaks above the breaks of the base
6532
+ * - the edges with a stretch above the cap
6533
+ * - under the rule `collection`, the mixed segments.
6534
+ * An output passes the guard when the count is 0.
6535
+ */
6536
+ export declare function guardBreaks(facts: PortfolioFacts, base: PortfolioFacts | undefined, rule: PortfolioRule, cap: number): number;
6537
+ /**
6538
+ * This function gives the function of the facts of the outputs on the graph `graph`. It builds the network of the stretch one time for the graph.
6539
+ * The hard rules are the rules of `checkProperties`. The stretch is the stretch of the exact model, as the records of the gap screen give it.
6540
+ */
6541
+ export declare function portfolioFacts(graph: Graph): (result: Result) => PortfolioFacts;
6542
+ /**
6543
+ * This function gives the key of the portfolio router on the graph `graph`, with the rule `rule` and the cap `cap`.
6544
+ * - `hard` is `guardBreaks` against the output of the base. `base` gives that output after the base runs. The output of the base has 0 breaks.
6545
+ * Before the base runs, or when the base throws, a member has its own breaks of the hard rules.
6546
+ * - The one level `B1` is the ink saved (higher is better), with the `minEffect` of the table `MEASURES`.
6547
+ * - The hash is `resultHash`.
6548
+ * The winner is the first member with the most B1 of the members with 0 breaks (`selectBest`). The base has 0 breaks, so a member that fails the guard does not win.
6549
+ */
6550
+ export declare function portfolioKey(graph: Graph, rule: PortfolioRule, cap: PortfolioCap, base?: () => Result | undefined): PortfolioKey<Graph, Result>;
6551
+ /** The name of a built-in highway strategy. */
6552
+ type HighwayName = keyof typeof highwayStrategies;
6553
+ /**
6554
+ * The form of one member:
6555
+ * - `["shared", options]`, `["trunks", options]` or `["corners", options]`: the router with the options. `shared` and `trunks` use the rule `byCollection`.
6556
+ * - `["highway", name]`: the built-in highway strategy `name`, or `shared-ways-all`, with `follow`.
6557
+ * - `["gate", name, gate, budget?]`: the built-in highway strategy with the gate `stretch`, `breakeven` or `ambiguity`. `budget` sets the budget of the gate `stretch`.
6558
+ * - `["plan", name, options]`: the plan of the built-in highway strategy `name` with other options.
6559
+ */
6560
+ export type MemberForm = readonly ["shared", Omit<SharedOptions, "name" | "rule">] | readonly ["trunks", Omit<TrunksOptions, "name" | "rule">] | readonly ["corners", Omit<CornersOptions, "name">] | readonly ["highway", HighwayName | "shared-ways-all"] | readonly ["gate", HighwayName, "stretch" | "breakeven" | "ambiguity", number?] | readonly ["plan", HighwayName, Readonly<Record<string, unknown>>];
6561
+ /** The forms of the members, by the names of the records. `shared` is the base. The greedy sets of `sets.ts` name only these members. */
6562
+ export declare const MEMBER_FORMS: Readonly<Record<string, MemberForm>>;
6563
+ /** This function gives the router strategy of a member form, with the name `name`. */
6564
+ export declare function memberStrategy(name: string, form: MemberForm): Strategy<"router", object>;
6565
+ /** This function gives the member with the name `name`, or `undefined` for a name without a form in `MEMBER_FORMS`. */
6566
+ export declare function portfolioMember(name: string): Strategy<"router", object> | undefined;
6567
+ /** The options of the portfolio router. */
6568
+ export interface PortfolioRouterOptions {
6569
+ /** The rule of the caller. Under `collection` (the default), a shared segment must hold edges of one collection only. Under `all`, collections can mix. */
6570
+ readonly rule?: PortfolioRule;
6571
+ /** The stretch cap of the caller: 1.1, 1.25 or 1.5 (the default). An output with an edge above the cap does not win. The base is the fallback output. */
6572
+ readonly cap?: PortfolioCap;
6573
+ /**
6574
+ * The count of members after the base: 3, 5 or 8. Without `k` (the default), the router runs the fit of `fit.ts`.
6575
+ * The fit gives a member count for each rule, cap and band, and a node limit for each member. Thus the default is deterministic.
6576
+ */
6577
+ readonly k?: 3 | 5 | 8;
6578
+ /**
6579
+ * A time limit of the pick in milliseconds, as a ceiling that the caller sets. The base always runs. The combinator cuts the members that start after the limit.
6580
+ * A cut by the budget makes the output depend on the speed of the machine. Then the trace has `deterministic: false`.
6581
+ */
6582
+ readonly budgetMs?: number;
6583
+ /** The largest count of members that run, with the base. */
6584
+ readonly maxMembers?: number;
6585
+ /** The clock in milliseconds. The default is `performance.now`. */
6586
+ readonly now?: () => number;
6587
+ }
6588
+ /** The base member of each portfolio: the router `shared` with the rule `byCollection`. It is the fallback output above the cap. */
6589
+ export declare const PORTFOLIO_BASE_MEMBER = "shared";
6590
+ /** The result of the portfolio router: the output of the winner, the winner, the trace of the pick, the move counts and the band. */
6591
+ export interface PortfolioRoute {
6592
+ readonly result: Result;
6593
+ readonly winner: string;
6594
+ readonly trace: PortfolioTrace;
6595
+ /** The move count of the pick (ACTIVATION): `{ "move.pick": 1 }` when the winner is not the base and has another output. */
6596
+ readonly moves: Readonly<Record<string, number>>;
6597
+ /** The size band of the input, from its node count. */
6598
+ readonly band: string;
6599
+ /** The names of the members, in their order. */
6600
+ readonly members: readonly string[];
6601
+ }
6602
+ /** This function gives the name of the portfolio router with the options `options`: `portfolio-<rule>-<cap>-k<k>`, or `portfolio-<rule>-<cap>-fit` without `k`. */
6603
+ export declare function portfolioName(options?: PortfolioRouterOptions): string;
6604
+ /**
6605
+ * This function gives the names of the members for an input with `nodes` nodes. The base comes first.
6606
+ * - With `k`, the first `k` names of the set of the band follow.
6607
+ * - Without `k`, the members of the fit of the band follow, each only when `nodes` is at or below its node limit.
6608
+ */
6609
+ export declare function portfolioMembers(nodes: number, options?: PortfolioRouterOptions): string[];
6610
+ /**
6611
+ * This function routes the graph `graph` with the portfolio of its size band, rule and cap. The base runs first, then the members in their order.
6612
+ * The key is `portfolioKey`: a member wins only when it passes the guard against the base. Of those members, the winner has the most ink saved.
6613
+ * A tie within the `minEffect` of B1 goes to the first member (`selectBest`). A member that throws does not win.
6614
+ * The result carries the trace of the pick and the move count `move.pick`.
6615
+ */
6616
+ export declare function routePortfolio(graph: Graph, options?: PortfolioRouterOptions): PortfolioRoute;
6617
+ /** This function gives a router that routes each graph with `routePortfolio` and the options `options`. Its name is `portfolioName(options)`. */
6618
+ export declare function portfolioRouter(options?: PortfolioRouterOptions): Router;
6619
+ /**
6620
+ * The portfolio router as a router strategy. It is not in the registry `STRATEGIES`, so the benchmark and the site do not race it by default.
6621
+ * A caller adds it to a registry of its own, or calls `routePortfolio` for the trace.
6622
+ */
6623
+ export declare const portfolioStrategy: Strategy<"router", PortfolioRouterOptions>;
6624
+ /**
6625
+ * The greedy set of each rule, cap and size band, by the key `<rule>|<cap>|<band>`. The set of k strategies is the first k names.
6626
+ * Each set comes from the train seeds (0 to 4) of its band. The base `shared` is not in a set: the portfolio always runs it first.
6627
+ */
6628
+ export declare const PORTFOLIO_SETS: Readonly<Record<`${PortfolioRule}|${PortfolioCap}|${string}`, readonly string[]>>;
6629
+ export { type AdvectionSettings, type AmbiguityGuardOptions, type ArcOptions, type ArcSource, type AreaOptions, type AreaWidth, type Biclique, type BreakEvenOptions, type BundleLine, type BundleOrder, type CandidateSource, type CellStep, type ClothoidOptions, type ConfluentOptions, type ConsensusLinkage, type ConsensusOptions, type CornersOptions, type CorridorOptions, type Crossbar, type CrossbarOptions, type CubuOptions, type CurveSpace, type CutObjective, type CutOptions, type DensityGrid, type DensityImage, type DensityKernel, type DensitySource, type DiffusionOptions, type DividedOptions, type EdgeDistance, type EdgeEnds, type EdgeGroup, type EdgeLengths, type EdgePathOptions, type EdgePlugs, type ExerciseEvidence, type FdebOptions, type FieldEnd, type FlowClusterOptions, type FlowFieldOptions, type FollowOptions, type FrechetBundle, type FrechetOptions, type Gate, type GroupScope, type GroupSpine, type GroupedOptions, type GrowthOptions, type GrowthOrder, type HashOptions, type HdbscanOptions, type HierarchyGroups, type HierarchyOptions, type Highway, type HighwayBase, type HighwayInput, type HighwayMember, type HighwayOptions, type HighwayPlan, type HoughOptions, type HoughPeak, type HubAllocation, type HubArcOptions, type HubCandidates, type HysteresisOptions, type JogStyle, type KdAxis, type KdLine, type KdOptions, type KdeebOptions, type KeyOptions, type KeyedWay, type KeysOptions, type LaneCurve, type LanesOptions, type LevelHighwayOptions, type LinkCommunityOptions, type LinkEdge, type Linkage, type MeetOptions, type Member, type MemberStatus, type MemberTrace, type MeshOptions, type MingleOptions, type MlsFit, type MlsebOptions, type ModuleRule, type NestedOptions, type NodeKey, type NodeLinks, type OdCellOptions, type OutputGroup, type PHubOptions, type PathStep, type PickSpec, type Portfolio, type PortfolioKey, type PortfolioLevel, type PortfolioOptions, type PortfolioPick, type PortfolioTrace, type PowerOptions, type QuickBundlesOptions, RECORD_EPS, type ResistanceOptions, type Ridge, type RidgeOptions, type RidgeSource, type RoadClassOptions, type RoomBends, type RoundedOptions, type RouteCrossing, type RouteSegment, type SbebOptions, type ScaleCluster, type ScaleSpaceOptions, type SectionsOptions, type SelectCandidate, type SelectLevel, type SelectOptions, type Selection, type ShapeSkeleton, type ShareCost, type ShareMerge, type ShareOrder, type SharedOptions, type SharedStretchOptions, type SharedWaysOptions, type SkeletonGroups, type SkeletonTarget, type SmoothOptions, type SnapLine, type SnapMember, type SnapOptions, type SoftKeyOptions, type SpectralOptions, type SpiralNode, type SpiralOptions, type SplineOptions, type SplitCell, type StableIdOptions, type StretchOptions, type StubEnds, type StubOptions, type TerritoryOptions, type TerritoryPoints, type TraceOptions, type TraclusOptions, type TrafficRule, type TrunkFan, type TrunkSplit, type TrunksOptions, type WeiszfeldOptions, type WspdOptions, type Zip, type ZipLimits, type ZipperOptions, canonicalJson, compareMeasure, exercised, minEffectOf, outputGroups, outputHash, pickMoves, portfolio, selectBest, sha256Hex };
4490
6630
  //# sourceMappingURL=index.d.ts.map