@mark1russell7/highways 0.4.1 → 0.4.2
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.
- package/README.md +27 -1
- package/build/index.d.ts +642 -1
- package/build/index.d.ts.map +1 -1
- package/build/index.js +5189 -2609
- package/build/index.js.map +1 -1
- package/package.json +1 -1
- package/src/bench/measures/highways.ts +93 -0
- package/src/bench/measures/index.ts +1 -0
- package/src/bench/screen/measures.ts +5 -0
- package/src/bench/screen/screen.ts +14 -0
- package/src/highways/base.ts +126 -0
- package/src/highways/flow-field/index.ts +49 -0
- package/src/highways/gates/ambiguity/index.ts +110 -0
- package/src/highways/gates/breakeven/index.ts +62 -0
- package/src/highways/gates/hysteresis/index.ts +48 -0
- package/src/highways/gates/ids/index.ts +59 -0
- package/src/highways/gates/index.ts +6 -0
- package/src/highways/gates/model.ts +129 -0
- package/src/highways/gates/stretch/index.ts +39 -0
- package/src/highways/grouped.ts +123 -0
- package/src/highways/index.ts +15 -0
- package/src/highways/level-links/index.ts +114 -0
- package/src/highways/meet/index.ts +84 -0
- package/src/highways/model.ts +5 -0
- package/src/highways/od-cells/index.ts +50 -0
- package/src/highways/quickbundles/index.ts +117 -0
- package/src/highways/road-classes/index.ts +74 -0
- package/src/highways/router.ts +1 -1
- package/src/highways/select/index.ts +162 -0
- package/src/highways/stretches.ts +141 -0
- package/src/highways/stubs/index.ts +117 -0
- package/src/highways/weiszfeld/index.ts +105 -0
- package/src/highways/wspd/index.ts +130 -0
- package/src/highways/zipper/index.ts +168 -0
- package/src/strategies/builtins.ts +149 -7
- package/src/strategies/schemas.ts +120 -0
package/build/index.d.ts
CHANGED
|
@@ -1083,6 +1083,14 @@ interface HighwayInput {
|
|
|
1083
1083
|
* The strategy `corridors` makes the ways of the corner graph, as the router `corners` finds them.
|
|
1084
1084
|
*/
|
|
1085
1085
|
readonly routes?: Result;
|
|
1086
|
+
/**
|
|
1087
|
+
* This value is the graph before an edit and the plan of the same strategy on it. A strategy that keeps its highways stable over edits reads it.
|
|
1088
|
+
* The gates `hysteresis` (HWY-046) and `ids` (HWY-054) read it. The other strategies ignore it.
|
|
1089
|
+
*/
|
|
1090
|
+
readonly previous?: {
|
|
1091
|
+
readonly graph: Graph;
|
|
1092
|
+
readonly plan: HighwayPlan;
|
|
1093
|
+
};
|
|
1086
1094
|
}
|
|
1087
1095
|
/**
|
|
1088
1096
|
* One edge of a highway. The edge joins the spine at the merge point and leaves it at the split point.
|
|
@@ -2742,6 +2750,43 @@ export interface OrderFragilityOptions {
|
|
|
2742
2750
|
* The cost is `orders` extra runs of the router.
|
|
2743
2751
|
*/
|
|
2744
2752
|
export declare function orderFragility(graph: Graph, route: (graph: Graph) => Result, options?: OrderFragilityOptions): OrderFragility;
|
|
2753
|
+
/**
|
|
2754
|
+
* This function gives the churn of the highways over one edit (Z10 for highways, from HWY-046). Two edges are a pair when they share a highway.
|
|
2755
|
+
* The churn is the share of the pairs that come or go: `|P ∆ P'| / |P ∪ P'|`. Only the edges of `edges` count, for example the edges of both graphs.
|
|
2756
|
+
* Two plans without pairs give 0. The scale is 0 to 1, and lower is better.
|
|
2757
|
+
*/
|
|
2758
|
+
export declare function highwayChurn(before: HighwayPlan, after: HighwayPlan, edges: ReadonlySet<string>): number;
|
|
2759
|
+
/** The match of the highways over one edit. */
|
|
2760
|
+
export interface HighwayIdKeep {
|
|
2761
|
+
/** The number of new highways with a match in the old plan: a Jaccard index of their edges of 0.5 or more. */
|
|
2762
|
+
readonly matched: number;
|
|
2763
|
+
/** The number of matched highways that keep the id of their match. */
|
|
2764
|
+
readonly kept: number;
|
|
2765
|
+
/** `kept / matched`, or `NaN` without a match. The scale is 0 to 1, and higher is better. */
|
|
2766
|
+
readonly share: number;
|
|
2767
|
+
}
|
|
2768
|
+
/**
|
|
2769
|
+
* This function tells how many highways keep their id over one edit (HWY-054). It matches the new highways with the old ones by `matchHighways`, with the index 0.5.
|
|
2770
|
+
* A matched highway keeps its id when its id is the id of its match. Only the edges of `edges` count.
|
|
2771
|
+
*/
|
|
2772
|
+
export declare function highwayIdKeep(before: HighwayPlan, after: HighwayPlan, edges: ReadonlySet<string>): HighwayIdKeep;
|
|
2773
|
+
/** The stability of a highway strategy over a seeded sequence of edits. Each value is the mean over the edits. */
|
|
2774
|
+
export interface HighwayEdits {
|
|
2775
|
+
/** The mean Fréchet distance of the routes over one edit, in units of the board (Z10). */
|
|
2776
|
+
readonly mean: number;
|
|
2777
|
+
/** The share of the routes that move over one edit (Z10). */
|
|
2778
|
+
readonly moved: number;
|
|
2779
|
+
/** The churn of the highways over one edit (`highwayChurn`). */
|
|
2780
|
+
readonly churn: number;
|
|
2781
|
+
/** The share of the matched highways that keep their id over one edit (`highwayIdKeep`), or `NaN` without a match. */
|
|
2782
|
+
readonly ids: number;
|
|
2783
|
+
}
|
|
2784
|
+
/**
|
|
2785
|
+
* This function measures a highway strategy over a sequence of `edits` seeded edits. Each edit is the small change of `changeGraph` with the seed `seed + i`.
|
|
2786
|
+
* The strategy gets the graph and its plan before the edit as `previous`, so a strategy with memory can keep its highways.
|
|
2787
|
+
* `follow` routes each plan with the way options of the strategy. The same graph, strategy, options and seed give the same values.
|
|
2788
|
+
*/
|
|
2789
|
+
export declare function highwayEdits(graph: Graph, strategy: Strategy<"highway", object>, options: object | undefined, edits: number, seed?: number): HighwayEdits;
|
|
2745
2790
|
/** The names of the proposed hard rules of MEAS0. The suite counts them. It does not apply them as rules yet. */
|
|
2746
2791
|
export declare const PROPOSED_RULES: readonly string[];
|
|
2747
2792
|
/** The options of `runSuite`. */
|
|
@@ -3011,6 +3056,180 @@ export declare function minHash(keys: Iterable<string>, count: number): number[]
|
|
|
3011
3056
|
* The edges of the cluster that are not on the spine make the next highway, while `minSize` of them remain.
|
|
3012
3057
|
*/
|
|
3013
3058
|
export declare function corridorPlan(input: HighwayInput, o: Readonly<CorridorOptions>): HighwayPlan;
|
|
3059
|
+
/**
|
|
3060
|
+
* A gate: a rule that keeps, drops or changes the highways of a plan. `gateStrategy` puts a gate after a highway strategy.
|
|
3061
|
+
* A gate does not move a spine. It takes members out of a highway, drops a highway or changes the id of a highway.
|
|
3062
|
+
*/
|
|
3063
|
+
interface Gate<G extends object> {
|
|
3064
|
+
/** The name of the gate. The strategy of a gate has the name `<strategy>+<gate>`. */
|
|
3065
|
+
readonly name: string;
|
|
3066
|
+
/** One or two sentences that tell what the gate does. */
|
|
3067
|
+
readonly describe: string;
|
|
3068
|
+
/** The values of the options of the gate. Their keys must not be keys of the options of the strategy before the gate. */
|
|
3069
|
+
readonly defaults: G;
|
|
3070
|
+
readonly schema: OptionSchema<G>;
|
|
3071
|
+
/** This function gives the plan after the gate. `way` holds the options of the way finder of the strategy. */
|
|
3072
|
+
apply(input: HighwayInput, plan: HighwayPlan, options: Readonly<G>, way: WayOptions): HighwayPlan;
|
|
3073
|
+
}
|
|
3074
|
+
/**
|
|
3075
|
+
* This function puts a gate after a highway strategy. The new strategy has the name `<strategy>+<gate>`, and the options of both.
|
|
3076
|
+
* The strategy gets its own options, and the gate gets the plan of the strategy and the options of the gate.
|
|
3077
|
+
* Thus a gate can follow each plan, for example `corridors+breakeven` or `shared-ways+stretch`. Gates can follow gates.
|
|
3078
|
+
*/
|
|
3079
|
+
export declare function gateStrategy<O extends object, G extends object>(strategy: Strategy<"highway", O>, gate: Gate<G>): Strategy<"highway", O & G>;
|
|
3080
|
+
/**
|
|
3081
|
+
* This function gives the plan with only the members that `keep` accepts. A highway with fewer than two members goes away.
|
|
3082
|
+
* The lanes keep their order, and each highway keeps its id, its key and its spine.
|
|
3083
|
+
*/
|
|
3084
|
+
export declare function keepMembers(plan: HighwayPlan, keep: (h: Highway, m: HighwayMember) => boolean): HighwayPlan;
|
|
3085
|
+
/** The lengths of the route of one edge of a plan. */
|
|
3086
|
+
interface EdgeLengths {
|
|
3087
|
+
/** The length of the route along the plan, after `follow`. */
|
|
3088
|
+
readonly route: number;
|
|
3089
|
+
/** The length of the route without a highway: the route of the router `corners`. */
|
|
3090
|
+
readonly alone: number;
|
|
3091
|
+
}
|
|
3092
|
+
/**
|
|
3093
|
+
* This function gives the length of the route of each edge of a plan, along the plan and alone. `follow` routes each edge of a plan on its own.
|
|
3094
|
+
* Thus the route of an edge does not change when another edge leaves the plan.
|
|
3095
|
+
*/
|
|
3096
|
+
export declare function edgeLengths(graph: Graph, plan: HighwayPlan, way: WayOptions): Map<string, EdgeLengths>;
|
|
3097
|
+
/** This function gives the ids of the edges that both graphs have. */
|
|
3098
|
+
export declare function commonEdges(a: Graph, b: Graph): Set<string>;
|
|
3099
|
+
/** This function gives the Jaccard index of two sets of edges: the common edges over all edges. Two empty sets give 0. */
|
|
3100
|
+
export declare function jaccard(a: ReadonlySet<string>, b: ReadonlySet<string>): number;
|
|
3101
|
+
/**
|
|
3102
|
+
* This function matches the highways of a plan with the highways of an earlier plan. It pairs the highways with the largest Jaccard index of their edges first.
|
|
3103
|
+
* A pair needs an index of `min` or more. Each highway is in one pair at most. The result maps the index of a new highway to the index of its old highway.
|
|
3104
|
+
* Only the edges of `edges` count, when this set is present: for example the edges of both graphs.
|
|
3105
|
+
*/
|
|
3106
|
+
export declare function matchHighways(before: HighwayPlan, after: HighwayPlan, min: number, edges?: ReadonlySet<string>): Map<number, number>;
|
|
3107
|
+
/** The options of the gate `ambiguity` (HWY-049). */
|
|
3108
|
+
interface AmbiguityGuardOptions {
|
|
3109
|
+
/** Two groups of edges merge only when the merge adds this share of false pairs, or less. The default is 0.5. */
|
|
3110
|
+
readonly maxAmbiguity: number;
|
|
3111
|
+
/** With `node`, the default, two groups merge only when they share an end node. With `any`, only `maxAmbiguity` decides. */
|
|
3112
|
+
readonly link: "node" | "any";
|
|
3113
|
+
}
|
|
3114
|
+
/** The default options of the gate `ambiguity`. */
|
|
3115
|
+
export declare const AMBIGUITY_GUARD_DEFAULTS: Readonly<AmbiguityGuardOptions>;
|
|
3116
|
+
/**
|
|
3117
|
+
* This function gives the ambiguity of a set of nodes: the share of the pairs of distinct nodes without an edge between them.
|
|
3118
|
+
* The nodes are the ends of the edges of one highway. A set with fewer than two nodes gives 0.
|
|
3119
|
+
*/
|
|
3120
|
+
export declare function nodeAmbiguity(nodes: ReadonlySet<string>, adj: ReadonlyMap<string, ReadonlySet<string>>): number;
|
|
3121
|
+
/**
|
|
3122
|
+
* This function applies the ambiguity guard of HWY-049 to a plan. A highway joins edges that belong together.
|
|
3123
|
+
*
|
|
3124
|
+
* Two nodes are a false pair when their edges share a highway and no edge joins them. The ambiguity of a group of edges is the share of false pairs among the pairs of its end nodes.
|
|
3125
|
+
* In each highway, each edge starts as a group. Two groups merge only when `amb(A ∪ B) - max(amb A, amb B)` is at most `maxAmbiguity`.
|
|
3126
|
+
* With the link `node`, they also must share an end node. The merge with the smallest rise comes first.
|
|
3127
|
+
*
|
|
3128
|
+
* The largest group stays on the highway. The other edges leave it and go alone.
|
|
3129
|
+
*/
|
|
3130
|
+
export declare function ambiguityPlan(input: HighwayInput, plan: HighwayPlan, options: Readonly<AmbiguityGuardOptions>): HighwayPlan;
|
|
3131
|
+
/** The gate `ambiguity` (HWY-049): the ambiguity guard. A highway does not join edges whose end nodes have no edges between them. */
|
|
3132
|
+
export declare const ambiguityGate: Gate<AmbiguityGuardOptions>;
|
|
3133
|
+
/** The options of the gate `breakeven` (HWY-047). */
|
|
3134
|
+
interface BreakEvenOptions {
|
|
3135
|
+
/**
|
|
3136
|
+
* The exponent of the cost law: a stretch with `n` edges costs `n^shareAlpha` times its length. Each edge pays the share `n^(shareAlpha - 1)`.
|
|
3137
|
+
* With 0, a shared stretch is one line, as the ink of B1 counts it. The default is 0.5, as the break-even floor of `corridors`.
|
|
3138
|
+
*/
|
|
3139
|
+
readonly shareAlpha: number;
|
|
3140
|
+
}
|
|
3141
|
+
/** The default options of the gate `breakeven`. */
|
|
3142
|
+
export declare const BREAK_EVEN_DEFAULTS: Readonly<BreakEvenOptions>;
|
|
3143
|
+
/**
|
|
3144
|
+
* This function applies the break-even law of HWY-047 to a plan. An edge stays on its highways only when sharing saves ink.
|
|
3145
|
+
*
|
|
3146
|
+
* The edge pays `n^(shareAlpha - 1)` of each shared stretch, with `n` the members of the highway. Thus it saves `(1 - n^(shareAlpha - 1)) L` on a stretch of the length `L`.
|
|
3147
|
+
* It adds the length of its route along the plan less the length of its route alone. An edge stays when the saving is as large as the added length.
|
|
3148
|
+
* For two parallel edges at the gap `d`, this rule gives the break-even overlap `d √((2 + t) / (2 - t))` with `t = 2^shareAlpha`.
|
|
3149
|
+
*
|
|
3150
|
+
* An edge that does not save ink leaves each of its highways. Then the other members of those highways save less, so the test repeats until no edge leaves.
|
|
3151
|
+
*/
|
|
3152
|
+
export declare function breakEvenPlan(input: HighwayInput, plan: HighwayPlan, options: Readonly<BreakEvenOptions>, way?: WayOptions): HighwayPlan;
|
|
3153
|
+
/** The gate `breakeven` (HWY-047): an edge stays on a highway only when sharing saves ink. */
|
|
3154
|
+
export declare const breakEvenGate: Gate<BreakEvenOptions>;
|
|
3155
|
+
/** The options of the gate `hysteresis` (HWY-046). */
|
|
3156
|
+
interface HysteresisOptions {
|
|
3157
|
+
/** A new highway needs this number of edges or more. The default is 3. */
|
|
3158
|
+
readonly kOn: number;
|
|
3159
|
+
/** A highway of the earlier plan stays while it has this number of edges or more. The default is 2. */
|
|
3160
|
+
readonly kOff: number;
|
|
3161
|
+
}
|
|
3162
|
+
/** The default options of the gate `hysteresis`. */
|
|
3163
|
+
export declare const HYSTERESIS_DEFAULTS: Readonly<HysteresisOptions>;
|
|
3164
|
+
/** Two highways of two plans are the same highway when the Jaccard index of their edges is this value or more. */
|
|
3165
|
+
export declare const SAME_HIGHWAY = .5;
|
|
3166
|
+
/**
|
|
3167
|
+
* This function applies the count threshold with hysteresis of HWY-046 to a plan.
|
|
3168
|
+
* A highway with `kOn` edges or more stays. A highway with fewer than `kOff` edges goes away.
|
|
3169
|
+
* A highway between the two limits stays only when it was in the earlier plan, `input.previous`.
|
|
3170
|
+
* The highway of the earlier plan with the most common edges is its match, with a Jaccard index of `SAME_HIGHWAY` or more.
|
|
3171
|
+
*
|
|
3172
|
+
* Thus an edit that adds or removes one edge near the limit does not make a highway come and go. Without an earlier plan, the limit is `kOn`.
|
|
3173
|
+
*/
|
|
3174
|
+
export declare function hysteresisPlan(input: HighwayInput, plan: HighwayPlan, options: Readonly<HysteresisOptions>): HighwayPlan;
|
|
3175
|
+
/** The gate `hysteresis` (HWY-046): a highway forms at `kOn` edges and goes away below `kOff` edges. */
|
|
3176
|
+
export declare const hysteresisGate: Gate<HysteresisOptions>;
|
|
3177
|
+
/** The options of the gate `ids` (HWY-054). */
|
|
3178
|
+
interface StableIdOptions {
|
|
3179
|
+
/** A new highway takes the id of an old highway when the Jaccard index of their edges is this value or more. The default is 0.5. */
|
|
3180
|
+
readonly minJaccard: number;
|
|
3181
|
+
}
|
|
3182
|
+
/** The default options of the gate `ids`. */
|
|
3183
|
+
export declare const STABLE_ID_DEFAULTS: Readonly<StableIdOptions>;
|
|
3184
|
+
/**
|
|
3185
|
+
* This function gives stable ids to the highways of a plan (HWY-054). The earlier plan is `input.previous`.
|
|
3186
|
+
* Each new highway takes the id of the old highway with the most common edges.
|
|
3187
|
+
* The pairs with the largest Jaccard index of their edges come first.
|
|
3188
|
+
*
|
|
3189
|
+
* A pair needs an index of `minJaccard` or more, and only the edges of both graphs count.
|
|
3190
|
+
* A new highway without a match gets a new id `h<n>` that no old highway and no new highway has. Thus the old highway of a new id ends.
|
|
3191
|
+
* The gate changes only the ids, so the routes do not change. Without an earlier plan, the plan does not change.
|
|
3192
|
+
*/
|
|
3193
|
+
export declare function stableIdPlan(input: HighwayInput, plan: HighwayPlan, options: Readonly<StableIdOptions>): HighwayPlan;
|
|
3194
|
+
/** The gate `ids` (HWY-054): stable highway ids across edits. A highway keeps the id of its match in the earlier plan. */
|
|
3195
|
+
export declare const stableIdGate: Gate<StableIdOptions>;
|
|
3196
|
+
/** The options of the gate `stretch` (HWY-048). */
|
|
3197
|
+
interface StretchOptions {
|
|
3198
|
+
/** An edge stays on its highways when its route is at most this number times its route alone, plus `pad`. The default is 1.2. */
|
|
3199
|
+
readonly budget: number;
|
|
3200
|
+
/** The added length that each edge can use, in units of the board. The default is 0. */
|
|
3201
|
+
readonly pad: number;
|
|
3202
|
+
}
|
|
3203
|
+
/** The default options of the gate `stretch`. */
|
|
3204
|
+
export declare const STRETCH_DEFAULTS: Readonly<StretchOptions>;
|
|
3205
|
+
/**
|
|
3206
|
+
* This function applies the stretch budget of HWY-048 to a plan: the join test of each edge.
|
|
3207
|
+
* An edge stays on its highways only when its route along the plan is at most `budget` times its route alone, plus `pad`.
|
|
3208
|
+
* The route alone is the route of the router `corners`. An edge that fails leaves each of its highways and goes alone, so the highways do not bend for it.
|
|
3209
|
+
* `follow` routes each edge on its own, so the test of one edge does not change with the other edges. One pass is enough.
|
|
3210
|
+
*/
|
|
3211
|
+
export declare function stretchPlan(input: HighwayInput, plan: HighwayPlan, options: Readonly<StretchOptions>, way?: WayOptions): HighwayPlan;
|
|
3212
|
+
/** The gate `stretch` (HWY-048): an edge joins a highway only when its route stays in a budget of its route alone. */
|
|
3213
|
+
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;
|
|
3014
3233
|
/** The options of the highway strategy `keys`: the options of the router `trunks`, without the name and the limit of the benchmark. */
|
|
3015
3234
|
type KeysOptions = Omit<TrunksOptions, "name" | "maxNodes">;
|
|
3016
3235
|
/**
|
|
@@ -3019,6 +3238,223 @@ type KeysOptions = Omit<TrunksOptions, "name" | "maxNodes">;
|
|
|
3019
3238
|
* Each trunk and each run becomes one highway. The function does not change the router: it reads its bundles and its runs.
|
|
3020
3239
|
*/
|
|
3021
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. */
|
|
3257
|
+
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
|
+
}
|
|
3285
|
+
/** The default options of the strategy `meet`. */
|
|
3286
|
+
export declare const MEET_DEFAULTS: Readonly<MeetOptions>;
|
|
3287
|
+
/**
|
|
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`.
|
|
3294
|
+
*/
|
|
3295
|
+
export declare function meetMember(spine: readonly Point[], member: HighwayMember, route: readonly Point[] | undefined, o: Readonly<MeetOptions>): HighwayMember;
|
|
3296
|
+
/**
|
|
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.
|
|
3300
|
+
*/
|
|
3301
|
+
export declare function meetPlan(input: HighwayInput, o: Readonly<MeetOptions>): HighwayPlan;
|
|
3302
|
+
/**
|
|
3303
|
+
* 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
|
+
* Each stretch that they share is a highway. With `trunk`, each group gets one trunk between two terminals, with a leg from each plug.
|
|
3305
|
+
*/
|
|
3306
|
+
type GroupSpine = "shared" | "trunk";
|
|
3307
|
+
/** The values of `GroupSpine`. */
|
|
3308
|
+
export declare const GROUP_SPINES: readonly GroupSpine[];
|
|
3309
|
+
/** The group of one edge: its key, and `flip` when the edge goes from the second end of the group to the first end. */
|
|
3310
|
+
interface EdgeGroup {
|
|
3311
|
+
readonly key: string;
|
|
3312
|
+
readonly flip: boolean;
|
|
3313
|
+
}
|
|
3314
|
+
/** The options of `groupedPlan`. */
|
|
3315
|
+
interface GroupedOptions extends WayOptions {
|
|
3316
|
+
readonly spine: GroupSpine;
|
|
3317
|
+
/** A group has this number of edges or more. The value is 2 or more. */
|
|
3318
|
+
readonly minSize: number;
|
|
3319
|
+
/**
|
|
3320
|
+
* With the spine `trunk`, an edge rides the trunk only when each of its legs is this share of the span or shorter.
|
|
3321
|
+
* The span is the distance between the two terminals. `Infinity` sets no limit.
|
|
3322
|
+
*/
|
|
3323
|
+
readonly legMax?: number;
|
|
3324
|
+
}
|
|
3325
|
+
/**
|
|
3326
|
+
* This function gives the geometric median of points (the Weber point), with the iterations of Weiszfeld.
|
|
3327
|
+
* The point has the least sum of the distances to the points.
|
|
3328
|
+
*/
|
|
3329
|
+
export declare function weberPoint(points: readonly Point[], iterations?: number): Point;
|
|
3330
|
+
/**
|
|
3331
|
+
* This function gives the highways of the groups of edges. Only the edges in `groups` ride a highway, and each group needs `minSize` edges.
|
|
3332
|
+
* The spine `shared` gives the shared stretches of the router `shared` with the group as the key.
|
|
3333
|
+
* The spine `trunk` gives one trunk for each group, through the corner graph between two terminals.
|
|
3334
|
+
* 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
|
+
*/
|
|
3336
|
+
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`. */
|
|
3346
|
+
readonly spine: GroupSpine;
|
|
3347
|
+
}
|
|
3348
|
+
/** The default options of the strategy `od-cells`. */
|
|
3349
|
+
export declare const OD_CELL_DEFAULTS: Readonly<OdCellOptions>;
|
|
3350
|
+
/**
|
|
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.
|
|
3354
|
+
*/
|
|
3355
|
+
export declare function odGroups(input: HighwayInput, o: Readonly<OdCellOptions>): Map<string, EdgeGroup>;
|
|
3356
|
+
/**
|
|
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.
|
|
3360
|
+
*/
|
|
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. */
|
|
3377
|
+
readonly minSize: number;
|
|
3378
|
+
/** The spine of each cluster. The default is `shared`. */
|
|
3379
|
+
readonly spine: GroupSpine;
|
|
3380
|
+
}
|
|
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[];
|
|
3385
|
+
/**
|
|
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.
|
|
3389
|
+
*/
|
|
3390
|
+
export declare function mdf(p: readonly Point[], q: readonly Point[]): {
|
|
3391
|
+
d: number;
|
|
3392
|
+
flip: boolean;
|
|
3393
|
+
};
|
|
3394
|
+
/**
|
|
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.
|
|
3398
|
+
*/
|
|
3399
|
+
export declare function quickBundles(input: HighwayInput, o: Readonly<QuickBundlesOptions>): Map<string, EdgeGroup>;
|
|
3400
|
+
/**
|
|
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.
|
|
3403
|
+
*/
|
|
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. */
|
|
3410
|
+
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
|
+
}
|
|
3414
|
+
/** The default options of the strategy `road-classes`. */
|
|
3415
|
+
export declare const ROAD_CLASS_DEFAULTS: Readonly<Required<Omit<RoadClassOptions, "margin" | "k">>>;
|
|
3416
|
+
/**
|
|
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.
|
|
3422
|
+
*/
|
|
3423
|
+
export declare function roadClassPlan(input: HighwayInput, o: Readonly<RoadClassOptions>): HighwayPlan;
|
|
3424
|
+
/** A generator of candidate highways: a highway strategy with its defaults. */
|
|
3425
|
+
type CandidateSource = "corridors" | "quickbundles" | "wspd" | "road-classes" | "flow-field" | "od-cells" | "shared-ways";
|
|
3426
|
+
/** The values of `CandidateSource`. */
|
|
3427
|
+
export declare const CANDIDATE_SOURCES: readonly CandidateSource[];
|
|
3428
|
+
/** The options of the highway strategy `select` (HWY-045 of the note on highways). */
|
|
3429
|
+
interface SelectOptions {
|
|
3430
|
+
/** The generators of the candidates. The default is `corridors`, `quickbundles`, `wspd` and `road-classes`. */
|
|
3431
|
+
readonly generators: readonly CandidateSource[];
|
|
3432
|
+
/** The weight of the added length of the edges against the ink that a highway saves (lambda 3 of the note). The default is 1. */
|
|
3433
|
+
readonly lambda: number;
|
|
3434
|
+
/** The number of passes of the local search with one swap. The default is 2. */
|
|
3435
|
+
readonly swaps: number;
|
|
3436
|
+
}
|
|
3437
|
+
/** The default options of the strategy `select`. */
|
|
3438
|
+
export declare const SELECT_DEFAULTS: Readonly<SelectOptions>;
|
|
3439
|
+
/** This function gives the plan of a generator, with its defaults. */
|
|
3440
|
+
export declare function candidatePlan(input: HighwayInput, source: CandidateSource): HighwayPlan;
|
|
3441
|
+
/**
|
|
3442
|
+
* This function gives the ink that a highway saves. It is the sum of the spine lengths of the members, less the length of their union.
|
|
3443
|
+
* The extra length of a member is its detour from its first route. The detour goes to the merge point, along the spine and back from the split point.
|
|
3444
|
+
*/
|
|
3445
|
+
export declare function candidateScore(h: Highway, routes: ReadonlyMap<string, readonly Point[]>): {
|
|
3446
|
+
gain: number;
|
|
3447
|
+
extra: number;
|
|
3448
|
+
};
|
|
3449
|
+
/**
|
|
3450
|
+
* This function gives the highways of the candidate generation and selection (HWY-045). Each generator proposes its highways as candidates.
|
|
3451
|
+
* The net gain of a candidate is the ink that it saves, less `lambda` times the length that it adds to its edges.
|
|
3452
|
+
* Two candidates of two generators conflict when they share an edge. The highways of one generator do not conflict.
|
|
3453
|
+
*
|
|
3454
|
+
* The selection takes the candidates by net gain for each edge, without a conflict. Then each pass of the local search
|
|
3455
|
+
* 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
|
+
*/
|
|
3457
|
+
export declare function selectPlan(input: HighwayInput, o: Readonly<SelectOptions>): HighwayPlan;
|
|
3022
3458
|
/** The options of the highway strategy `shared-ways`: the options of the router `shared`, without the name and the limit of the benchmark. */
|
|
3023
3459
|
type SharedWaysOptions = Omit<SharedOptions, "name" | "maxNodes">;
|
|
3024
3460
|
/**
|
|
@@ -3027,6 +3463,156 @@ type SharedWaysOptions = Omit<SharedOptions, "name" | "maxNodes">;
|
|
|
3027
3463
|
* The function does not change the router: it reads its runs.
|
|
3028
3464
|
*/
|
|
3029
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. */
|
|
3479
|
+
readonly minSize: number;
|
|
3480
|
+
}
|
|
3481
|
+
/** The default options of the strategy `stubs`. */
|
|
3482
|
+
export declare const STUB_DEFAULTS: Readonly<StubOptions>;
|
|
3483
|
+
/**
|
|
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.
|
|
3489
|
+
* 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
|
+
* 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
|
+
*/
|
|
3492
|
+
export declare function stubPlan(input: HighwayInput, o: Readonly<StubOptions>): HighwayPlan;
|
|
3493
|
+
/** The options of the highway strategy `weiszfeld` (HWY-043 of the note on highways). */
|
|
3494
|
+
interface WeiszfeldOptions {
|
|
3495
|
+
/** The plan whose highways get new meeting points. The default is `shared-ways`. */
|
|
3496
|
+
readonly from: HighwayBase;
|
|
3497
|
+
/** The weight of the trunk is `k^alpha` for `k` members. With 0, the trunk costs its ink one time. With 1, it costs each lane. The default is 0.5. */
|
|
3498
|
+
readonly alpha: number;
|
|
3499
|
+
/** The number of steps of Weiszfeld. The default is 20. */
|
|
3500
|
+
readonly steps: number;
|
|
3501
|
+
}
|
|
3502
|
+
/** The default options of the strategy `weiszfeld`. */
|
|
3503
|
+
export declare const WEISZFELD_DEFAULTS: Readonly<WeiszfeldOptions>;
|
|
3504
|
+
/**
|
|
3505
|
+
* This function gives the meeting points `M1` and `M2` of a bundle with the least weighted ink (HWY-043):
|
|
3506
|
+
* `Σ |a_i - M1| + w |M1 - M2| + Σ |M2 - b_i|`. The lists `a` and `b` are the ends of the edges on each side, and `w` is the weight of the trunk.
|
|
3507
|
+
* The function starts at the means of `a` and `b`. Each step moves `M1` and then `M2` by one step of Weiszfeld.
|
|
3508
|
+
*/
|
|
3509
|
+
export declare function meetingPoints(a: readonly Point[], b: readonly Point[], w: number, steps: number): [Point, Point];
|
|
3510
|
+
/**
|
|
3511
|
+
* This function gives the highways of the plan `from`, with the meeting points of Weiszfeld (HWY-043).
|
|
3512
|
+
* The ends of a member are the points where its edge comes to the highway and goes away from it after `follow` of the plan.
|
|
3513
|
+
* They are the plugs, or the split point of the highway before and the merge point of the highway after.
|
|
3514
|
+
* The weight of the trunk is `k^alpha` for `k` members. The trunk stays on the spine: the function projects `M1` and `M2` on the spine.
|
|
3515
|
+
* Each member then joins the spine at `M1` and leaves it at `M2`, but not outside its own stretch. So a member only gets shorter on the spine.
|
|
3516
|
+
*/
|
|
3517
|
+
export declare function weiszfeldPlan(input: HighwayInput, o: Readonly<WeiszfeldOptions>): HighwayPlan;
|
|
3518
|
+
/** The options of the highway strategy `wspd` (HWY-018 of the note on highways). */
|
|
3519
|
+
interface WspdOptions {
|
|
3520
|
+
/** The separation `s` of the pairs: the gap between two sets is at least `s` times the radius of the larger set. The default is 2. */
|
|
3521
|
+
readonly separation: number;
|
|
3522
|
+
/** A pair with this number of edges or more gets a highway. The default is 3. */
|
|
3523
|
+
readonly minSize: number;
|
|
3524
|
+
/** The spine of each pair. The default is `trunk`. */
|
|
3525
|
+
readonly spine: GroupSpine;
|
|
3526
|
+
}
|
|
3527
|
+
/** The default options of the strategy `wspd`. */
|
|
3528
|
+
export declare const WSPD_DEFAULTS: Readonly<WspdOptions>;
|
|
3529
|
+
/** A cell of the split tree: the points at the places `lo` to `hi - 1` of the order, with their bounding circle. */
|
|
3530
|
+
interface SplitCell {
|
|
3531
|
+
readonly id: number;
|
|
3532
|
+
readonly lo: number;
|
|
3533
|
+
readonly hi: number;
|
|
3534
|
+
readonly c: Point;
|
|
3535
|
+
readonly r: number;
|
|
3536
|
+
readonly kids?: readonly [SplitCell, SplitCell];
|
|
3537
|
+
}
|
|
3538
|
+
/**
|
|
3539
|
+
* The split tree of a set of points and its well-separated pairs (Callahan and Kosaraju 1995).
|
|
3540
|
+
* Each cell splits at the middle of the longer side of its bounding box. A cell of equal points is a leaf.
|
|
3541
|
+
*/
|
|
3542
|
+
export declare class SplitTree {
|
|
3543
|
+
#private;
|
|
3544
|
+
readonly root: SplitCell;
|
|
3545
|
+
/** This constructor builds the tree of the points. */
|
|
3546
|
+
constructor(points: readonly Point[]);
|
|
3547
|
+
/** This method tells if the cell holds the point `i`. */
|
|
3548
|
+
holds(cell: SplitCell, i: number): boolean;
|
|
3549
|
+
/**
|
|
3550
|
+
* This method gives the well-separated pair that holds the pair of points `u` and `v`, with the cell of `u` first.
|
|
3551
|
+
* Each pair of two different points is in one pair of the decomposition. Two equal points give `undefined`.
|
|
3552
|
+
*/
|
|
3553
|
+
pairOf(u: number, v: number, s: number): [SplitCell, SplitCell] | undefined;
|
|
3554
|
+
}
|
|
3555
|
+
/**
|
|
3556
|
+
* This function gives the groups of the edges by the well-separated pair of their two nodes (HWY-018).
|
|
3557
|
+
* The points are the centers of the boxes. The edges of one pair, in either direction, are one group.
|
|
3558
|
+
*/
|
|
3559
|
+
export declare function wspdGroups(input: HighwayInput, o: Readonly<WspdOptions>): Map<string, EdgeGroup>;
|
|
3560
|
+
/**
|
|
3561
|
+
* This function gives the highways of clustered edge routing with the WSPD (HWY-018, after Bouts and Speckmann 2015).
|
|
3562
|
+
* The well-separated pairs split all the pairs of nodes. The edges of one pair with `minSize` edges or more get one highway from one set to the other.
|
|
3563
|
+
*/
|
|
3564
|
+
export declare function wspdPlan(input: HighwayInput, o: Readonly<WspdOptions>): HighwayPlan;
|
|
3565
|
+
/** The options of the highway strategy `zipper` (NAT-022 with WILD-037 of the notes). */
|
|
3566
|
+
interface ZipperOptions {
|
|
3567
|
+
/** The plan whose routes the zipper joins. The default is `shared-ways`. */
|
|
3568
|
+
readonly from: HighwayBase;
|
|
3569
|
+
/** Two legs zip when they are this distance apart or nearer, in units of the board (the median short side of the boxes). The default is 1. */
|
|
3570
|
+
readonly near: number;
|
|
3571
|
+
/** Two legs zip when the angle between them is this value or less, in degrees. The default is 15. */
|
|
3572
|
+
readonly maxAngle: number;
|
|
3573
|
+
/** The adhesion over the tension: two legs zip when `adhesion * overlap` is more than the length that the zip adds. The default is 0.3. */
|
|
3574
|
+
readonly adhesion: number;
|
|
3575
|
+
/** Two legs zip when they overlap along this length or more, in units of the board. The default is 1. */
|
|
3576
|
+
readonly minOverlap: number;
|
|
3577
|
+
/** The number of passes. Each pass routes the plan and zips the legs again. The default is 1. */
|
|
3578
|
+
readonly passes: number;
|
|
3579
|
+
}
|
|
3580
|
+
/** The default options of the strategy `zipper`. */
|
|
3581
|
+
export declare const ZIPPER_DEFAULTS: Readonly<ZipperOptions>;
|
|
3582
|
+
/** A pair of legs that can zip, with the line of the zip. */
|
|
3583
|
+
interface Zip {
|
|
3584
|
+
readonly gain: number;
|
|
3585
|
+
/** The first point of the zipped line. */
|
|
3586
|
+
readonly from: Point;
|
|
3587
|
+
/** The last point of the zipped line. */
|
|
3588
|
+
readonly to: Point;
|
|
3589
|
+
/** This value is `true` when the leg goes from `from` to `to`, for each of the two legs. */
|
|
3590
|
+
readonly forward: readonly [boolean, boolean];
|
|
3591
|
+
}
|
|
3592
|
+
/** The limits of `zipLegs`, in the units of the board. */
|
|
3593
|
+
interface ZipLimits {
|
|
3594
|
+
readonly near: number;
|
|
3595
|
+
readonly maxAngle: number;
|
|
3596
|
+
readonly adhesion: number;
|
|
3597
|
+
readonly minOverlap: number;
|
|
3598
|
+
}
|
|
3599
|
+
/**
|
|
3600
|
+
* This function tells if two legs zip (NAT-022), and gives the zipped line.
|
|
3601
|
+
* The zipped line is the mean of the two legs, with the weight of their lengths, along the stretch where they overlap.
|
|
3602
|
+
* The legs zip when the angle between them is `maxAngle` or less, and they are `near` or nearer along the overlap.
|
|
3603
|
+
* The overlap must be `minOverlap` or more.
|
|
3604
|
+
* The zip adds two jogs to each leg, so it adds the length `2 (d_a + d_b)`, with the distances of the legs to the zipped line.
|
|
3605
|
+
* The legs zip only when `adhesion * overlap` is more than that length.
|
|
3606
|
+
*/
|
|
3607
|
+
export declare function zipLegs(a0: Point, a1: Point, b0: Point, b1: Point, o: ZipLimits): Zip | undefined;
|
|
3608
|
+
/**
|
|
3609
|
+
* This function gives the highways of the plan `from`, with the legs that run near and nearly parallel zipped together (NAT-022, WILD-037).
|
|
3610
|
+
* A pass routes the plan with `follow` and takes each leg that no other route shares. A grid of the legs finds the near pairs.
|
|
3611
|
+
* The pairs that zip (`zipLegs`) go from the largest gain to the smallest, and each leg zips one time in a pass at most.
|
|
3612
|
+
* A zipped line that goes into a box, made larger by 1, does not zip.
|
|
3613
|
+
* Each zip is a new highway of two members. The `seq` of each member follows the place of its merge point along the route of the edge.
|
|
3614
|
+
*/
|
|
3615
|
+
export declare function zipperPlan(input: HighwayInput, o: Readonly<ZipperOptions>): HighwayPlan;
|
|
3030
3616
|
/** The options of a router strategy: the options of its router, without the name and the limit of the benchmark. */
|
|
3031
3617
|
export type RouterPreset<O> = Omit<O, "name" | "maxNodes">;
|
|
3032
3618
|
/** The built-in router strategies, in the order of the benchmark. They route as the routers of `ROUTERS`. */
|
|
@@ -3113,12 +3699,30 @@ export declare const groupStrategies: {
|
|
|
3113
3699
|
};
|
|
3114
3700
|
/**
|
|
3115
3701
|
* The built-in highway strategies: the decisions of the routers `trunks` and `shared` as plans, and corridor signatures (HWY-031).
|
|
3702
|
+
* The strategies `corridors+<gate>` put a gate of BUILD-W2A after `corridors`: `breakeven` (HWY-047), `stretch` (HWY-048), `ambiguity` (HWY-049),
|
|
3703
|
+
* `hysteresis` (HWY-046) and `ids` (HWY-054). `gateStrategy` puts a gate after any other plan.
|
|
3116
3704
|
* `follow` routes the edges along a plan, and `highwayRouter` gives a router that does both.
|
|
3117
3705
|
*/
|
|
3118
3706
|
export declare const highwayStrategies: {
|
|
3119
3707
|
readonly keys: Strategy<"highway", KeysOptions>;
|
|
3120
3708
|
readonly "shared-ways": Strategy<"highway", SharedWaysOptions>;
|
|
3121
3709
|
readonly corridors: Strategy<"highway", CorridorOptions>;
|
|
3710
|
+
readonly meet: Strategy<"highway", MeetOptions>;
|
|
3711
|
+
readonly weiszfeld: Strategy<"highway", WeiszfeldOptions>;
|
|
3712
|
+
readonly stubs: Strategy<"highway", StubOptions>;
|
|
3713
|
+
readonly zipper: Strategy<"highway", ZipperOptions>;
|
|
3714
|
+
readonly "level-links": Strategy<"highway", LevelHighwayOptions>;
|
|
3715
|
+
readonly quickbundles: Strategy<"highway", QuickBundlesOptions>;
|
|
3716
|
+
readonly "road-classes": Strategy<"highway", RoadClassOptions>;
|
|
3717
|
+
readonly "flow-field": Strategy<"highway", FlowFieldOptions>;
|
|
3718
|
+
readonly wspd: Strategy<"highway", WspdOptions>;
|
|
3719
|
+
readonly "od-cells": Strategy<"highway", OdCellOptions>;
|
|
3720
|
+
readonly select: Strategy<"highway", SelectOptions>;
|
|
3721
|
+
readonly "corridors+breakeven": Strategy<"highway", CorridorOptions & BreakEvenOptions>;
|
|
3722
|
+
readonly "corridors+stretch": Strategy<"highway", CorridorOptions & StretchOptions>;
|
|
3723
|
+
readonly "corridors+ambiguity": Strategy<"highway", CorridorOptions & AmbiguityGuardOptions>;
|
|
3724
|
+
readonly "corridors+hysteresis": Strategy<"highway", CorridorOptions & HysteresisOptions>;
|
|
3725
|
+
readonly "corridors+ids": Strategy<"highway", CorridorOptions & StableIdOptions>;
|
|
3122
3726
|
};
|
|
3123
3727
|
/** The built-in strategies of each step, in order. A consumer adds its own: `createRegistry([...BUILT_IN_STRATEGIES, mine])`. */
|
|
3124
3728
|
export declare const BUILT_IN_STRATEGIES: readonly AnyStrategy[];
|
|
@@ -3600,6 +4204,12 @@ export interface ScreenOptions {
|
|
|
3600
4204
|
* The default is 0: no measure of the order fragility. The steps `group` and `curve` do not read it.
|
|
3601
4205
|
*/
|
|
3602
4206
|
readonly shuffles?: number;
|
|
4207
|
+
/**
|
|
4208
|
+
* The number of seeded edits of the step `highway` (BUILD-W2A). Each highway strategy runs again after each edit of `highwayEdits`, with its plan before the edit.
|
|
4209
|
+
* The records then get `Z10.edits.*`, the churn of the highways and the share of the highways that keep their id.
|
|
4210
|
+
* The default is 0: no edits. The other steps and the base routers do not read it.
|
|
4211
|
+
*/
|
|
4212
|
+
readonly edits?: number;
|
|
3603
4213
|
/** The commit of the code, for the records. */
|
|
3604
4214
|
readonly commit?: string;
|
|
3605
4215
|
/** The predictions of the run. Each record names the first prediction with its strategy, its set and its input. */
|
|
@@ -3737,6 +4347,37 @@ export declare function highwayRouter<O extends object>(strategy: Strategy<"high
|
|
|
3737
4347
|
* The benchmark and the screen race such a router with the other routers.
|
|
3738
4348
|
*/
|
|
3739
4349
|
export declare function highwayRouterStrategy<O extends object>(strategy: Strategy<"highway", O>): Strategy<"router", O>;
|
|
4350
|
+
/** An edge with its two plugs, as the router `corners` places them. */
|
|
4351
|
+
interface EdgePlugs {
|
|
4352
|
+
readonly edge: Edge;
|
|
4353
|
+
readonly ps: Plug;
|
|
4354
|
+
readonly pt: Plug;
|
|
4355
|
+
}
|
|
4356
|
+
/** This function gives the plugs of each edge of the graph, in the order of the edges. An edge with an unknown node is not in the list. */
|
|
4357
|
+
export declare function edgePlugs(graph: Graph): EdgePlugs[];
|
|
4358
|
+
/** The way of one edge through the corner graph, with a key. Only the ways with one key share a highway. */
|
|
4359
|
+
interface KeyedWay {
|
|
4360
|
+
readonly edge: string;
|
|
4361
|
+
readonly key: string;
|
|
4362
|
+
/** The points of the way, without the plugs. Two ways share a link when the link has the same two points. */
|
|
4363
|
+
readonly points: readonly Point[];
|
|
4364
|
+
}
|
|
4365
|
+
/** The options of `sharedStretches`. */
|
|
4366
|
+
interface SharedStretchOptions {
|
|
4367
|
+
/** A highway has this number of edges or more. The value is 2 or more. */
|
|
4368
|
+
readonly minSize: number;
|
|
4369
|
+
/** This function tells if a link can be part of a highway. Without it, each link can. */
|
|
4370
|
+
readonly link?: (a: Point, b: Point) => boolean;
|
|
4371
|
+
/** This function removes the needless corners of a spine. Without it, the spine keeps each point of the stretch. */
|
|
4372
|
+
readonly pull?: (points: readonly Point[]) => Point[];
|
|
4373
|
+
}
|
|
4374
|
+
/**
|
|
4375
|
+
* This function gives a highway for each stretch that two ways or more of one key share. A way is a polyline through the corner graph.
|
|
4376
|
+
* Each way breaks into stretches where the set of the ways on its links stays the same. The router `shared` makes its runs in the same way.
|
|
4377
|
+
* A stretch with fewer than `minSize` ways is not a highway. Each way joins the spine at one end of the stretch and leaves it at the other end.
|
|
4378
|
+
* The `seq` of each member follows the order of the stretches along the way.
|
|
4379
|
+
*/
|
|
4380
|
+
export declare function sharedStretches(ways: readonly KeyedWay[], o: Readonly<SharedStretchOptions>): HighwayPlan;
|
|
3740
4381
|
/**
|
|
3741
4382
|
* 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.
|
|
3742
4383
|
* The nodes and the edges do not change. Two orders of the same edges give the same graph.
|
|
@@ -3845,5 +4486,5 @@ export declare function withRepair(router: Router, options?: RepairOptions): Rou
|
|
|
3845
4486
|
* The new strategy has the name `<name>+repair`, and the options and the schema of `strategy`. The strategy `strategy` does not change.
|
|
3846
4487
|
*/
|
|
3847
4488
|
export declare function repairStrategy<O extends object>(strategy: Strategy<"router", O>, repair?: RepairOptions): Strategy<"router", O>;
|
|
3848
|
-
export type { ArcOptions, ClothoidOptions, CornersOptions, CorridorOptions, CurveSpace, CutObjective, CutOptions, FollowOptions, Highway, HighwayInput, HighwayMember, HighwayOptions, HighwayPlan, JogStyle, KdAxis, KdLine, KdOptions, KeyOptions, KeysOptions, LaneCurve, NodeKey, RoomBends, RoundedOptions, SectionsOptions, ShareCost, ShareMerge, ShareOrder, SharedOptions, SharedWaysOptions, SmoothOptions, SplineOptions, TrunkFan, TrunkSplit, TrunksOptions };
|
|
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 };
|
|
3849
4490
|
//# sourceMappingURL=index.d.ts.map
|