@mark1russell7/highways 0.4.2 → 0.5.0
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 +18 -2
- package/build/index.d.ts +799 -68
- package/build/index.d.ts.map +1 -1
- package/build/index.js +6235 -2128
- package/build/index.js.map +1 -1
- package/package.json +3 -1
- package/src/bench/exact/index.ts +197 -0
- package/src/bench/measures/index.ts +1 -0
- package/src/bench/measures/lanes.ts +304 -0
- package/src/bench/measures/levels.ts +86 -2
- package/src/bench/screen/forms.ts +11 -5
- package/src/bench/screen/measures.ts +18 -0
- package/src/bench/screen/screen.ts +28 -0
- package/src/channels.ts +56 -0
- package/src/highways/diffusion/index.ts +103 -0
- package/src/highways/edge-paths/index.ts +155 -0
- package/src/highways/fixtures.test-util.ts +71 -0
- package/src/highways/flow-clusters/index.ts +143 -0
- package/src/highways/growth/index.ts +148 -0
- package/src/highways/hdbscan/index.ts +250 -0
- package/src/highways/hough/index.ts +182 -0
- package/src/highways/hub-arcs/index.ts +181 -0
- package/src/highways/index.ts +15 -0
- package/src/highways/lanes/index.ts +189 -0
- package/src/highways/mingle/index.ts +171 -0
- package/src/highways/nested/index.ts +143 -0
- package/src/highways/ridges/index.ts +328 -0
- package/src/highways/snap.ts +110 -0
- package/src/highways/soft-keys/index.ts +114 -0
- package/src/highways/spiral/index.ts +205 -0
- package/src/highways/traclus/index.ts +296 -0
- package/src/index.ts +1 -0
- package/src/routers/shared.ts +56 -3
- package/src/strategies/builtins.ts +155 -1
- package/src/strategies/schemas.ts +180 -0
- package/src/visibility.ts +5 -0
package/build/index.d.ts
CHANGED
|
@@ -734,6 +734,8 @@ export declare class CornerGraph {
|
|
|
734
734
|
constructor(nodes: readonly Node[], obstacles: Obstacles, options: CornerGraphOptions);
|
|
735
735
|
/** This method gives the number of links of the graph. */
|
|
736
736
|
get linkCount(): number;
|
|
737
|
+
/** 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. */
|
|
738
|
+
neighbours(i: number): readonly number[];
|
|
737
739
|
/** 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
740
|
nearest(p: Point): number;
|
|
739
741
|
/** This method gives at most `k` corners that `p` can see, nearest first. The corner `self` does not count. */
|
|
@@ -783,6 +785,19 @@ export declare class SoftGraph {
|
|
|
783
785
|
*/
|
|
784
786
|
path(from: Point, to: Point, cost: (n: Node) => number): Point[];
|
|
785
787
|
}
|
|
788
|
+
/** The largest distance that `channelWidth` looks on each side of a link. A wider channel counts as this width on that side. */
|
|
789
|
+
export declare const CHANNEL_REACH = 64;
|
|
790
|
+
/**
|
|
791
|
+
* 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.
|
|
792
|
+
* A point inside the box gives 0. The function uses the slab test.
|
|
793
|
+
*/
|
|
794
|
+
export declare function rayToBox(p: Point, d: Point, box: Box): number;
|
|
795
|
+
/**
|
|
796
|
+
* 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.
|
|
797
|
+
* It measures the width at five points of the link, and gives the smallest. Each side counts up to `reach`.
|
|
798
|
+
* A link of length 0 gives the free space across the x axis at its point.
|
|
799
|
+
*/
|
|
800
|
+
export declare function channelWidth(obstacles: Obstacles, a: Point, b: Point, reach?: number): number;
|
|
786
801
|
/** The options of a way finder. */
|
|
787
802
|
export interface WayOptions {
|
|
788
803
|
/** The distance from a box to the corners of the graph. The default is 5. */
|
|
@@ -1043,6 +1058,20 @@ interface SharedOptions extends WayOptions {
|
|
|
1043
1058
|
* 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
1059
|
*/
|
|
1045
1060
|
readonly merge?: ShareMerge;
|
|
1061
|
+
/**
|
|
1062
|
+
* 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.
|
|
1063
|
+
* 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.
|
|
1064
|
+
*/
|
|
1065
|
+
readonly reuse?: number;
|
|
1066
|
+
/** The exponent of the pull of `reuse`. The default is 1. */
|
|
1067
|
+
readonly reuseExponent?: number;
|
|
1068
|
+
/**
|
|
1069
|
+
* 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.
|
|
1070
|
+
* `width` is the free space across the link (`channelWidth`). The default is 0: the router does not read the channels.
|
|
1071
|
+
*/
|
|
1072
|
+
readonly capacity?: number;
|
|
1073
|
+
/** The width of one lane, for `capacity`. The default is 4. */
|
|
1074
|
+
readonly laneWidth?: number;
|
|
1046
1075
|
/** The benchmark skips a fixture with more nodes. */
|
|
1047
1076
|
readonly maxNodes?: number;
|
|
1048
1077
|
}
|
|
@@ -2619,6 +2648,16 @@ export declare function positionStability(levels: readonly Level[]): number;
|
|
|
2619
2648
|
* A result without such a level gives 1. The cost is `n log n`, with a sample above 1500 items.
|
|
2620
2649
|
*/
|
|
2621
2650
|
export declare function orderStability(graph: Graph, levels: readonly Level[]): number;
|
|
2651
|
+
/**
|
|
2652
|
+
* This function gives the link agreement of the levels with groups (Z9 of MEAS0).
|
|
2653
|
+
* `la = mean over links of hausdorff(link, routes of its edges outside the two items) / u`, with `u` the argument `unit`.
|
|
2654
|
+
* The edges of a link are the edges between a node of one item and a node of the other item, in either direction.
|
|
2655
|
+
*
|
|
2656
|
+
* 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.
|
|
2657
|
+
* A link without such points on both sides does not count. It gives `undefined` when no link counts.
|
|
2658
|
+
* The value has no unit, and lower is better. The cost is quadratic in the points of each link.
|
|
2659
|
+
*/
|
|
2660
|
+
export declare function linkAgreement(graph: Graph, levels: readonly Level[], routes: readonly Route[], unit: number): number | undefined;
|
|
2622
2661
|
/** A grouping of the nodes: a map from the id of each node to the id of its group. */
|
|
2623
2662
|
export type Grouping = ReadonlyMap<string, string>;
|
|
2624
2663
|
/** This function gives the grouping of one level: each node goes to the id of its item. */
|
|
@@ -2787,6 +2826,92 @@ export interface HighwayEdits {
|
|
|
2787
2826
|
* `follow` routes each plan with the way options of the strategy. The same graph, strategy, options and seed give the same values.
|
|
2788
2827
|
*/
|
|
2789
2828
|
export declare function highwayEdits(graph: Graph, strategy: Strategy<"highway", object>, options: object | undefined, edits: number, seed?: number): HighwayEdits;
|
|
2829
|
+
/**
|
|
2830
|
+
* 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`).
|
|
2831
|
+
* R12 also uses it as the smallest correct distance between two parallel legs.
|
|
2832
|
+
*/
|
|
2833
|
+
export declare const MEASURE_LANE_WIDTH = 4;
|
|
2834
|
+
/** The routes of a result with each shared segment open: one lane for each edge. */
|
|
2835
|
+
export interface OpenLanes {
|
|
2836
|
+
/** The segments of the result. The shared segments are the runs and the trunks of the bundles. */
|
|
2837
|
+
readonly graph: SegmentGraph;
|
|
2838
|
+
/** The lane route of each edge, from `laneRoutes`. Without a shared segment, the lane routes are the routes. */
|
|
2839
|
+
readonly lanes: readonly Route[];
|
|
2840
|
+
/** The distance between two lanes. */
|
|
2841
|
+
readonly width: number;
|
|
2842
|
+
}
|
|
2843
|
+
/** This function opens each shared segment of a result: each edge of a run or of a trunk gets its own lane, `width` apart. */
|
|
2844
|
+
export declare function openLanes(result: Result, width?: number): OpenLanes;
|
|
2845
|
+
/**
|
|
2846
|
+
* 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.
|
|
2847
|
+
*
|
|
2848
|
+
* 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.
|
|
2849
|
+
* The sets of their edges are different. They are within `maxAngle` degrees of parallel. Their projections overlap. Their distance is less than `near`.
|
|
2850
|
+
*
|
|
2851
|
+
* `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.
|
|
2852
|
+
* 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.
|
|
2853
|
+
*/
|
|
2854
|
+
export declare function routeSeparation(routes: readonly Route[], near?: number, maxAngle?: number): number;
|
|
2855
|
+
/**
|
|
2856
|
+
* This function gives the orthogonality of the routes (R14 of MEAS0): `orth = Σ L(legs within maxAngle degrees of an axis) / Σ_e L(r_e)`.
|
|
2857
|
+
* 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.
|
|
2858
|
+
* Routes without length give 1. The cost is linear.
|
|
2859
|
+
*/
|
|
2860
|
+
export declare function orthogonality(routes: readonly Route[], maxAngle?: number): number;
|
|
2861
|
+
/**
|
|
2862
|
+
* This function counts the lane crossings of the segments of a result (B5 of MEAS0): the pairs of edges whose lane order flips.
|
|
2863
|
+
* 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`.
|
|
2864
|
+
*
|
|
2865
|
+
* A pair `(e, f)` counts one time when the side of `f` changes from one shared segment of both edges to the next one.
|
|
2866
|
+
* 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.
|
|
2867
|
+
*/
|
|
2868
|
+
export declare function laneCrossings(graph: SegmentGraph): number;
|
|
2869
|
+
/**
|
|
2870
|
+
* This function gives the occupied area of the routes (B7 of MEAS0): `moa = cells that S touches / cells that the straight lines touch`.
|
|
2871
|
+
* 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.
|
|
2872
|
+
* The scale is a ratio, and lower is better. Routes without a straight line give 1. The cost is linear in the cells.
|
|
2873
|
+
*/
|
|
2874
|
+
export declare function occupiedArea(routes: readonly Route[], unit: number): number;
|
|
2875
|
+
/** The run profile of a result (B8 of MEAS0). */
|
|
2876
|
+
export interface RunProfile {
|
|
2877
|
+
/** The number of shared segments: the runs and the trunks of the bundles with two edges or more. */
|
|
2878
|
+
readonly runs: number;
|
|
2879
|
+
/** The median of the edges of each shared segment. It is 0 without a shared segment. */
|
|
2880
|
+
readonly median: number;
|
|
2881
|
+
/** The most edges of one shared segment. It is 0 without a shared segment. */
|
|
2882
|
+
readonly max: number;
|
|
2883
|
+
}
|
|
2884
|
+
/** 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. */
|
|
2885
|
+
export declare function runProfile(graph: SegmentGraph): RunProfile;
|
|
2886
|
+
/** The lane fidelity of a result (B9 of MEAS0). */
|
|
2887
|
+
export interface LaneFidelity {
|
|
2888
|
+
/** The median of `lf(e)` over the edges with a shared segment. */
|
|
2889
|
+
readonly median: number;
|
|
2890
|
+
/** The largest `lf(e)`. */
|
|
2891
|
+
readonly max: number;
|
|
2892
|
+
/** The number of edges with a shared segment. */
|
|
2893
|
+
readonly edges: number;
|
|
2894
|
+
}
|
|
2895
|
+
/**
|
|
2896
|
+
* 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.
|
|
2897
|
+
* `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`.
|
|
2898
|
+
* `frechet` is the discrete Fréchet distance of the points. A value of 1 or less is correct, and lower is better.
|
|
2899
|
+
* It gives `undefined` when no edge has a shared segment. The cost is quadratic in the points of each route.
|
|
2900
|
+
*/
|
|
2901
|
+
export declare function laneFidelity(routes: readonly Route[], open: OpenLanes): LaneFidelity | undefined;
|
|
2902
|
+
/**
|
|
2903
|
+
* This function counts the lane routes that go through a box that is not one of their ends (M4 of MEAS0).
|
|
2904
|
+
* 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`.
|
|
2905
|
+
*/
|
|
2906
|
+
export declare function lanesThrough(graph: Graph, open: OpenLanes): number;
|
|
2907
|
+
/**
|
|
2908
|
+
* This function gives the area of a result (M1 of MEAS0) for a router: the growth of the board that the open lanes need.
|
|
2909
|
+
* 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.
|
|
2910
|
+
*
|
|
2911
|
+
* 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.
|
|
2912
|
+
* A board without area gives 1. The cost is linear.
|
|
2913
|
+
*/
|
|
2914
|
+
export declare function laneArea(graph: Graph, open: OpenLanes): number;
|
|
2790
2915
|
/** The names of the proposed hard rules of MEAS0. The suite counts them. It does not apply them as rules yet. */
|
|
2791
2916
|
export declare const PROPOSED_RULES: readonly string[];
|
|
2792
2917
|
/** The options of `runSuite`. */
|
|
@@ -3211,6 +3336,415 @@ export declare const STRETCH_DEFAULTS: Readonly<StretchOptions>;
|
|
|
3211
3336
|
export declare function stretchPlan(input: HighwayInput, plan: HighwayPlan, options: Readonly<StretchOptions>, way?: WayOptions): HighwayPlan;
|
|
3212
3337
|
/** The gate `stretch` (HWY-048): an edge joins a highway only when its route stays in a budget of its route alone. */
|
|
3213
3338
|
export declare const stretchGate: Gate<StretchOptions>;
|
|
3339
|
+
/** The options of the highway strategy `diffusion` (HWY-020 of the note on highways). */
|
|
3340
|
+
interface DiffusionOptions extends Pick<WayOptions, "margin" | "k"> {
|
|
3341
|
+
/** The share of the density that each step of the diffusion takes from the links next to a link. The default is 0.25. */
|
|
3342
|
+
readonly a: number;
|
|
3343
|
+
/** The number of steps of the diffusion. The default is 3. */
|
|
3344
|
+
readonly steps: number;
|
|
3345
|
+
/** The weight of the density in the cost of a link. The default is 1. */
|
|
3346
|
+
readonly lambda: number;
|
|
3347
|
+
/** The power of the discount of a dense link. The default is 1. */
|
|
3348
|
+
readonly gamma: number;
|
|
3349
|
+
/** A highway has this number of edges or more. The default is 2. */
|
|
3350
|
+
readonly minSize: number;
|
|
3351
|
+
}
|
|
3352
|
+
/** The default options of the strategy `diffusion`. */
|
|
3353
|
+
export declare const DIFFUSION_DEFAULTS: Readonly<Required<Omit<DiffusionOptions, "margin" | "k">>>;
|
|
3354
|
+
/**
|
|
3355
|
+
* 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.
|
|
3356
|
+
* 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:
|
|
3357
|
+
* `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.
|
|
3358
|
+
*/
|
|
3359
|
+
export declare function linkDensity(neighbours: (i: number) => readonly number[], corners: number, use: ReadonlyMap<number, number>, a: number, steps: number): Map<number, number>;
|
|
3360
|
+
/**
|
|
3361
|
+
* This function gives the highways of the route-aware bundling on the corner graph (HWY-020).
|
|
3362
|
+
* The first ways of the edges give the density of each link. A diffusion along the graph smooths it.
|
|
3363
|
+
* 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.
|
|
3364
|
+
* 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.
|
|
3365
|
+
*/
|
|
3366
|
+
export declare function diffusionPlan(input: HighwayInput, o: Readonly<DiffusionOptions>): HighwayPlan;
|
|
3367
|
+
/**
|
|
3368
|
+
* 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.
|
|
3369
|
+
* Each stretch that they share is a highway. With `trunk`, each group gets one trunk between two terminals, with a leg from each plug.
|
|
3370
|
+
*/
|
|
3371
|
+
type GroupSpine = "shared" | "trunk";
|
|
3372
|
+
/** The values of `GroupSpine`. */
|
|
3373
|
+
export declare const GROUP_SPINES: readonly GroupSpine[];
|
|
3374
|
+
/** The group of one edge: its key, and `flip` when the edge goes from the second end of the group to the first end. */
|
|
3375
|
+
interface EdgeGroup {
|
|
3376
|
+
readonly key: string;
|
|
3377
|
+
readonly flip: boolean;
|
|
3378
|
+
}
|
|
3379
|
+
/** The options of `groupedPlan`. */
|
|
3380
|
+
interface GroupedOptions extends WayOptions {
|
|
3381
|
+
readonly spine: GroupSpine;
|
|
3382
|
+
/** A group has this number of edges or more. The value is 2 or more. */
|
|
3383
|
+
readonly minSize: number;
|
|
3384
|
+
/**
|
|
3385
|
+
* With the spine `trunk`, an edge rides the trunk only when each of its legs is this share of the span or shorter.
|
|
3386
|
+
* The span is the distance between the two terminals. `Infinity` sets no limit.
|
|
3387
|
+
*/
|
|
3388
|
+
readonly legMax?: number;
|
|
3389
|
+
}
|
|
3390
|
+
/**
|
|
3391
|
+
* This function gives the geometric median of points (the Weber point), with the iterations of Weiszfeld.
|
|
3392
|
+
* The point has the least sum of the distances to the points.
|
|
3393
|
+
*/
|
|
3394
|
+
export declare function weberPoint(points: readonly Point[], iterations?: number): Point;
|
|
3395
|
+
/**
|
|
3396
|
+
* This function gives the highways of the groups of edges. Only the edges in `groups` ride a highway, and each group needs `minSize` edges.
|
|
3397
|
+
* The spine `shared` gives the shared stretches of the router `shared` with the group as the key.
|
|
3398
|
+
* The spine `trunk` gives one trunk for each group, through the corner graph between two terminals.
|
|
3399
|
+
* 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.
|
|
3400
|
+
*/
|
|
3401
|
+
export declare function groupedPlan(input: HighwayInput, groups: ReadonlyMap<string, EdgeGroup>, o: Readonly<GroupedOptions>): HighwayPlan;
|
|
3402
|
+
/** The linkage of the hierarchical clustering: the distance of two clusters from the distances of their edges. */
|
|
3403
|
+
type Linkage = "average" | "complete" | "single";
|
|
3404
|
+
/** The values of `Linkage`. */
|
|
3405
|
+
export declare const LINKAGES: readonly Linkage[];
|
|
3406
|
+
/** The options of the highway strategy `flow-clusters` (HWY-023 of the note on highways). */
|
|
3407
|
+
interface FlowClusterOptions {
|
|
3408
|
+
/** 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. */
|
|
3409
|
+
readonly tau: number;
|
|
3410
|
+
/** The linkage. The default is `average`. */
|
|
3411
|
+
readonly linkage: Linkage;
|
|
3412
|
+
/** With `true`, the source of one edge only compares with the source of the other edge. The default is `false`. */
|
|
3413
|
+
readonly directed: boolean;
|
|
3414
|
+
/** A cluster with this number of edges or more gets highways. The default is 2. */
|
|
3415
|
+
readonly minSize: number;
|
|
3416
|
+
/** The spine of each cluster. The default is `trunk`: one flow line from one area to the other area. */
|
|
3417
|
+
readonly spine: GroupSpine;
|
|
3418
|
+
}
|
|
3419
|
+
/** The default options of the strategy `flow-clusters`. */
|
|
3420
|
+
export declare const FLOW_CLUSTER_DEFAULTS: Readonly<FlowClusterOptions>;
|
|
3421
|
+
/**
|
|
3422
|
+
* 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)`.
|
|
3423
|
+
* Without `directed`, it is the smaller value of the two directions of `f`, and `flip` is `true` when the opposite direction is smaller.
|
|
3424
|
+
*/
|
|
3425
|
+
export declare function flowDistance(s1: Point, t1: Point, s2: Point, t2: Point, directed: boolean): {
|
|
3426
|
+
d: number;
|
|
3427
|
+
flip: boolean;
|
|
3428
|
+
};
|
|
3429
|
+
/**
|
|
3430
|
+
* 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.
|
|
3431
|
+
* 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.
|
|
3432
|
+
*/
|
|
3433
|
+
export declare function chainClusters(n: number, d: Float64Array, tau: number, linkage: Linkage): Int32Array;
|
|
3434
|
+
/**
|
|
3435
|
+
* This function gives the flow clusters of the edges (HWY-023). It clusters the edges as points in 4D, with the cut at `tau`.
|
|
3436
|
+
* 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.
|
|
3437
|
+
*/
|
|
3438
|
+
export declare function flowClusters(input: HighwayInput, o: Readonly<FlowClusterOptions>): Map<string, EdgeGroup>;
|
|
3439
|
+
/**
|
|
3440
|
+
* This function gives the highways of the flow clusters (HWY-023). The clusters of `flowClusters` with `minSize` edges or more get highways.
|
|
3441
|
+
* 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.
|
|
3442
|
+
*/
|
|
3443
|
+
export declare function flowClusterPlan(input: HighwayInput, o: Readonly<FlowClusterOptions>): HighwayPlan;
|
|
3444
|
+
/** The options of the highway strategy `edge-paths` (HWY-012 of the note on highways). */
|
|
3445
|
+
interface EdgePathOptions extends Pick<WayOptions, "margin" | "k"> {
|
|
3446
|
+
/** 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. */
|
|
3447
|
+
readonly distortion: number;
|
|
3448
|
+
/** 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. */
|
|
3449
|
+
readonly power: number;
|
|
3450
|
+
/** A highway has this number of edges or more. The default is 2. */
|
|
3451
|
+
readonly minSize: number;
|
|
3452
|
+
}
|
|
3453
|
+
/** The default options of the strategy `edge-paths`. */
|
|
3454
|
+
export declare const EDGE_PATH_DEFAULTS: Readonly<Required<Omit<EdgePathOptions, "margin" | "k">>>;
|
|
3455
|
+
/** 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. */
|
|
3456
|
+
interface PathStep {
|
|
3457
|
+
readonly edge: string;
|
|
3458
|
+
readonly back: boolean;
|
|
3459
|
+
}
|
|
3460
|
+
/**
|
|
3461
|
+
* 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.
|
|
3462
|
+
* 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.
|
|
3463
|
+
* 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.
|
|
3464
|
+
*/
|
|
3465
|
+
export declare function edgePaths(input: HighwayInput, o: Readonly<Pick<EdgePathOptions, "distortion" | "power">>): Map<string, PathStep[]>;
|
|
3466
|
+
/**
|
|
3467
|
+
* 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.
|
|
3468
|
+
* 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.
|
|
3469
|
+
*/
|
|
3470
|
+
export declare function edgePathPlan(input: HighwayInput, o: Readonly<EdgePathOptions>): HighwayPlan;
|
|
3471
|
+
/** The distance of two edges: 1 less their compatibility of FDEB, or the flow distance in 4D of HWY-023. */
|
|
3472
|
+
type EdgeDistance = "compatibility" | "flow";
|
|
3473
|
+
/** The values of `EdgeDistance`. */
|
|
3474
|
+
export declare const EDGE_DISTANCES: readonly EdgeDistance[];
|
|
3475
|
+
/** The options of the highway strategy `hdbscan` (HWY-028 of the note on highways). */
|
|
3476
|
+
interface HdbscanOptions {
|
|
3477
|
+
/** A cluster has this number of edges or more. The default is 3. */
|
|
3478
|
+
readonly minClusterSize: number;
|
|
3479
|
+
/** The core distance of an edge is the distance to its neighbour of this rank. The default is 3. */
|
|
3480
|
+
readonly minSamples: number;
|
|
3481
|
+
/** The distance of two edges. The default is `compatibility`. */
|
|
3482
|
+
readonly distance: EdgeDistance;
|
|
3483
|
+
/** The spine of each cluster. The default is `trunk`: one trunk from one area to the other area. */
|
|
3484
|
+
readonly spine: GroupSpine;
|
|
3485
|
+
}
|
|
3486
|
+
/** The default options of the strategy `hdbscan`. */
|
|
3487
|
+
export declare const HDBSCAN_DEFAULTS: Readonly<HdbscanOptions>;
|
|
3488
|
+
/**
|
|
3489
|
+
* This function gives the compatibility of two edges of FDEB (Holten and van Wijk 2009): `Ca Cs Cp Cv`, from 0 to 1.
|
|
3490
|
+
* `Ca` is the angle, `Cs` the scale, `Cp` the position and `Cv` the visibility. The direction of an edge does not change the value.
|
|
3491
|
+
*/
|
|
3492
|
+
export declare function compatibility(p0: Point, p1: Point, q0: Point, q1: Point): number;
|
|
3493
|
+
/**
|
|
3494
|
+
* This function gives the HDBSCAN clusters of the points of a distance matrix (Campello, Moulavi and Sander 2013). The value -1 is noise.
|
|
3495
|
+
* 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))`.
|
|
3496
|
+
* 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.
|
|
3497
|
+
* The selection keeps the clusters with the largest stability, `sum (lambda_leave - lambda_birth)`, with `lambda = 1 / distance`. The root is not a cluster.
|
|
3498
|
+
*/
|
|
3499
|
+
export declare function hdbscanLabels(n: number, d: Float64Array, minClusterSize: number, minSamples: number): Int32Array;
|
|
3500
|
+
/**
|
|
3501
|
+
* This function gives the HDBSCAN clusters of the edges (HWY-028). The edges that are noise get no group.
|
|
3502
|
+
* Each edge of a cluster gets `flip` when it goes opposite to the first edge of the cluster.
|
|
3503
|
+
*/
|
|
3504
|
+
export declare function hdbscanClusters(input: HighwayInput, o: Readonly<HdbscanOptions>): Map<string, EdgeGroup>;
|
|
3505
|
+
/**
|
|
3506
|
+
* This function gives the highways of the HDBSCAN clusters (HWY-028). The clusters that live over a long range of densities are the highways.
|
|
3507
|
+
* The number of highways is not fixed, and the noise edges stay alone.
|
|
3508
|
+
*/
|
|
3509
|
+
export declare function hdbscanPlan(input: HighwayInput, o: Readonly<HdbscanOptions>): HighwayPlan;
|
|
3510
|
+
/** One edge that snaps to a line: the points where it joins and leaves the line, and its place along its own way. */
|
|
3511
|
+
interface SnapMember {
|
|
3512
|
+
readonly edge: string;
|
|
3513
|
+
/** The point on the line where the edge joins it. */
|
|
3514
|
+
readonly from: Point;
|
|
3515
|
+
/** The point on the line where the edge leaves it. */
|
|
3516
|
+
readonly to: Point;
|
|
3517
|
+
/** 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. */
|
|
3518
|
+
readonly at: number;
|
|
3519
|
+
}
|
|
3520
|
+
/** A straight line that a finder gives as the place of a highway, with the edges that snap to it. */
|
|
3521
|
+
interface SnapLine {
|
|
3522
|
+
readonly key: string;
|
|
3523
|
+
readonly a: Point;
|
|
3524
|
+
readonly b: Point;
|
|
3525
|
+
readonly members: readonly SnapMember[];
|
|
3526
|
+
}
|
|
3527
|
+
/** The options of `snapPlan`. */
|
|
3528
|
+
interface SnapOptions extends Pick<WayOptions, "margin" | "k"> {
|
|
3529
|
+
/** A highway has this number of edges or more. The value is 2 or more. */
|
|
3530
|
+
readonly minSize: number;
|
|
3531
|
+
}
|
|
3532
|
+
/** This function gives the line `u d + rho n` of the direction angle `theta`, with `d = (cos, sin)` and the normal `n = (-sin, cos)`. */
|
|
3533
|
+
export declare function linePoint(theta: number, rho: number, u: number): Point;
|
|
3534
|
+
/**
|
|
3535
|
+
* 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.
|
|
3536
|
+
* An end inside a box moves to the nearest corner of the graph.
|
|
3537
|
+
* Each member joins the spine at the place nearest to its point `from`, and leaves it at the place nearest to its point `to`.
|
|
3538
|
+
* 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.
|
|
3539
|
+
* An edge on several highways takes them in the order of `at`.
|
|
3540
|
+
*/
|
|
3541
|
+
export declare function snapPlan(input: HighwayInput, lines: readonly SnapLine[], o: Readonly<SnapOptions>): HighwayPlan;
|
|
3542
|
+
/** This function gives the points of a spine from the place `on` to the place `off`, backward when `on` is larger. */
|
|
3543
|
+
export declare function spinePart(spine: readonly Point[], on: number, off: number): Point[];
|
|
3544
|
+
/** The options of the highway strategy `hough` (HWY-024 of the note on highways). */
|
|
3545
|
+
interface HoughOptions extends Pick<WayOptions, "margin" | "k"> {
|
|
3546
|
+
/** The width of the votes in the angle, in degrees. An edge joins a peak within this angle. The default is 8. */
|
|
3547
|
+
readonly dTheta: number;
|
|
3548
|
+
/** 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. */
|
|
3549
|
+
readonly dRho: number;
|
|
3550
|
+
/** A peak with fewer edges than this number is not a corridor. The default is 3. */
|
|
3551
|
+
readonly minVotes: number;
|
|
3552
|
+
/** With `true`, the peaks are only horizontal or vertical lines. The default is `false`. */
|
|
3553
|
+
readonly orthogonal: boolean;
|
|
3554
|
+
}
|
|
3555
|
+
/** The default options of the strategy `hough`. */
|
|
3556
|
+
export declare const HOUGH_DEFAULTS: Readonly<Required<Omit<HoughOptions, "margin" | "k">>>;
|
|
3557
|
+
/** A peak of the votes: its angle, its offset and the sum of its votes. */
|
|
3558
|
+
interface HoughPeak {
|
|
3559
|
+
readonly theta: number;
|
|
3560
|
+
readonly rho: number;
|
|
3561
|
+
readonly votes: number;
|
|
3562
|
+
}
|
|
3563
|
+
/**
|
|
3564
|
+
* 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.
|
|
3565
|
+
* 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`.
|
|
3566
|
+
* 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.
|
|
3567
|
+
*/
|
|
3568
|
+
export declare function houghPeaks(lines: readonly {
|
|
3569
|
+
theta: number;
|
|
3570
|
+
mid: Point;
|
|
3571
|
+
len: number;
|
|
3572
|
+
}[], o: Readonly<Pick<HoughOptions, "dTheta" | "dRho" | "orthogonal">>): HoughPeak[];
|
|
3573
|
+
/**
|
|
3574
|
+
* 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.
|
|
3575
|
+
* 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.
|
|
3576
|
+
* A member that makes the span shorter than four margins leaves, while the peak keeps `minVotes` edges.
|
|
3577
|
+
*/
|
|
3578
|
+
export declare function houghLines(input: HighwayInput, o: Readonly<HoughOptions>): SnapLine[];
|
|
3579
|
+
/**
|
|
3580
|
+
* 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.
|
|
3581
|
+
* Each corridor is a spine through the corner graph, and its edges ride it over their common span.
|
|
3582
|
+
*/
|
|
3583
|
+
export declare function houghPlan(input: HighwayInput, o: Readonly<HoughOptions>): HighwayPlan;
|
|
3584
|
+
/** A generator of candidate highways: a highway strategy with its defaults. */
|
|
3585
|
+
type CandidateSource = "corridors" | "quickbundles" | "wspd" | "road-classes" | "flow-field" | "od-cells" | "shared-ways";
|
|
3586
|
+
/** The values of `CandidateSource`. */
|
|
3587
|
+
export declare const CANDIDATE_SOURCES: readonly CandidateSource[];
|
|
3588
|
+
/** The options of the highway strategy `select` (HWY-045 of the note on highways). */
|
|
3589
|
+
interface SelectOptions {
|
|
3590
|
+
/** The generators of the candidates. The default is `corridors`, `quickbundles`, `wspd` and `road-classes`. */
|
|
3591
|
+
readonly generators: readonly CandidateSource[];
|
|
3592
|
+
/** 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. */
|
|
3593
|
+
readonly lambda: number;
|
|
3594
|
+
/** The number of passes of the local search with one swap. The default is 2. */
|
|
3595
|
+
readonly swaps: number;
|
|
3596
|
+
}
|
|
3597
|
+
/** The default options of the strategy `select`. */
|
|
3598
|
+
export declare const SELECT_DEFAULTS: Readonly<SelectOptions>;
|
|
3599
|
+
/** This function gives the plan of a generator, with its defaults. */
|
|
3600
|
+
export declare function candidatePlan(input: HighwayInput, source: CandidateSource): HighwayPlan;
|
|
3601
|
+
/**
|
|
3602
|
+
* 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.
|
|
3603
|
+
* 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.
|
|
3604
|
+
*/
|
|
3605
|
+
export declare function candidateScore(h: Highway, routes: ReadonlyMap<string, readonly Point[]>): {
|
|
3606
|
+
gain: number;
|
|
3607
|
+
extra: number;
|
|
3608
|
+
};
|
|
3609
|
+
/**
|
|
3610
|
+
* This function gives the highways of the candidate generation and selection (HWY-045). Each generator proposes its highways as candidates.
|
|
3611
|
+
* The net gain of a candidate is the ink that it saves, less `lambda` times the length that it adds to its edges.
|
|
3612
|
+
* Two candidates of two generators conflict when they share an edge. The highways of one generator do not conflict.
|
|
3613
|
+
*
|
|
3614
|
+
* The selection takes the candidates by net gain for each edge, without a conflict. Then each pass of the local search
|
|
3615
|
+
* 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.
|
|
3616
|
+
*/
|
|
3617
|
+
export declare function selectPlan(input: HighwayInput, o: Readonly<SelectOptions>): HighwayPlan;
|
|
3618
|
+
/** A generator of candidate arcs: `runs` (the shared stretches of the first ways of all edges) or a generator of the strategy `select`. */
|
|
3619
|
+
type ArcSource = "runs" | CandidateSource;
|
|
3620
|
+
/** The values of `ArcSource`. */
|
|
3621
|
+
export declare const ARC_SOURCES: readonly ArcSource[];
|
|
3622
|
+
/** The options of the highway strategy `hub-arcs` (HWY-042 of the note on highways). */
|
|
3623
|
+
interface HubArcOptions {
|
|
3624
|
+
/** The largest number of arcs (highways). The default is 12. */
|
|
3625
|
+
readonly q: number;
|
|
3626
|
+
/** The cost of a length on an arc against a length off the arcs, from 0 to 1. The default is 0.5. */
|
|
3627
|
+
readonly alpha: number;
|
|
3628
|
+
/** 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. */
|
|
3629
|
+
readonly stretch: number;
|
|
3630
|
+
/** The number of passes of the local search with one swap. The default is 1. */
|
|
3631
|
+
readonly swaps: number;
|
|
3632
|
+
/** An arc with fewer edges than this number is not a highway. The default is 2. */
|
|
3633
|
+
readonly minSize: number;
|
|
3634
|
+
/** The generators of the candidate arcs. The default is `runs`, `corridors` and `road-classes`. */
|
|
3635
|
+
readonly generators: readonly ArcSource[];
|
|
3636
|
+
}
|
|
3637
|
+
/** The default options of the strategy `hub-arcs`. */
|
|
3638
|
+
export declare const HUB_ARC_DEFAULTS: Readonly<HubArcOptions>;
|
|
3639
|
+
/** This function gives the candidate arcs: the spines of the plans of the generators, without the copies, with the longest first. */
|
|
3640
|
+
export declare function candidateArcs(input: HighwayInput, generators: readonly ArcSource[]): Point[][];
|
|
3641
|
+
/**
|
|
3642
|
+
* This function gives the highways of the hub arc location (Campbell, Ernst and Krishnamoorthy 2005). It chooses at most `q` arcs from the candidates.
|
|
3643
|
+
* 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.
|
|
3644
|
+
* 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.
|
|
3645
|
+
* Each edge rides the arc that saves the most for it.
|
|
3646
|
+
*/
|
|
3647
|
+
export declare function hubArcPlan(input: HighwayInput, o: Readonly<HubArcOptions>): HighwayPlan;
|
|
3648
|
+
/** The lines that make the density: the straight lines of the edges, or their first routes. */
|
|
3649
|
+
type RidgeSource = "lines" | "routes";
|
|
3650
|
+
/** The options of the highway strategy `ridges` (HWY-032 of the note on highways). */
|
|
3651
|
+
interface RidgeOptions extends Pick<WayOptions, "margin" | "k"> {
|
|
3652
|
+
/** The lines of the density. The default is `lines`. */
|
|
3653
|
+
readonly source: RidgeSource;
|
|
3654
|
+
/** 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. */
|
|
3655
|
+
readonly cell: number;
|
|
3656
|
+
/** The width of the blur, in units of the board. The default is 16. */
|
|
3657
|
+
readonly bandwidth: number;
|
|
3658
|
+
/** A ridge cell has this share of the largest strength or more. The default is 0.15. */
|
|
3659
|
+
readonly strength: number;
|
|
3660
|
+
/** A ridge has this length or more, in units of the board. The default is 60. */
|
|
3661
|
+
readonly minLength: number;
|
|
3662
|
+
/** An edge snaps to a ridge when its line is this near to the ridge, in units of the board. The default is 16. */
|
|
3663
|
+
readonly snap: number;
|
|
3664
|
+
/** A highway has this number of edges or more. The default is 2. */
|
|
3665
|
+
readonly minSize: number;
|
|
3666
|
+
}
|
|
3667
|
+
/** The default options of the strategy `ridges`. */
|
|
3668
|
+
export declare const RIDGE_DEFAULTS: Readonly<Required<Omit<RidgeOptions, "margin" | "k">>>;
|
|
3669
|
+
/** The density image: the cells, its size, and the place of its first cell. */
|
|
3670
|
+
interface DensityImage {
|
|
3671
|
+
readonly w: number;
|
|
3672
|
+
readonly h: number;
|
|
3673
|
+
readonly cell: number;
|
|
3674
|
+
readonly x0: number;
|
|
3675
|
+
readonly y0: number;
|
|
3676
|
+
readonly rho: Float64Array;
|
|
3677
|
+
}
|
|
3678
|
+
/**
|
|
3679
|
+
* This function gives the density of the polylines on a grid of cells, after a Gaussian blur of the width `bandwidth`.
|
|
3680
|
+
* Each polyline adds 1 to each cell that it goes through, one time for each polyline.
|
|
3681
|
+
*/
|
|
3682
|
+
export declare function lineDensity(lines: readonly (readonly Point[])[], box: {
|
|
3683
|
+
x: number;
|
|
3684
|
+
y: number;
|
|
3685
|
+
w: number;
|
|
3686
|
+
h: number;
|
|
3687
|
+
}, cellSize: number, bandwidth: number): DensityImage;
|
|
3688
|
+
/** One ridge: its two ends and the length between them. */
|
|
3689
|
+
interface Ridge {
|
|
3690
|
+
readonly a: Point;
|
|
3691
|
+
readonly b: Point;
|
|
3692
|
+
}
|
|
3693
|
+
/**
|
|
3694
|
+
* 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.
|
|
3695
|
+
* Its density is a maximum along the eigenvector of that eigenvalue. Its strength is the density times the size of that eigenvalue.
|
|
3696
|
+
* The cells with `strength` times the largest strength or more join their neighbours with a direction within 30 degrees.
|
|
3697
|
+
* 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.
|
|
3698
|
+
*/
|
|
3699
|
+
export declare function densityRidges(img: DensityImage, strength: number, minLength: number): Ridge[];
|
|
3700
|
+
/**
|
|
3701
|
+
* This function gives the lines of the ridges (HWY-032), each with the edges that snap to it.
|
|
3702
|
+
* An edge snaps to a ridge when the part of its line near the ridge is half of `minLength` or longer.
|
|
3703
|
+
* The angle between the edge and the ridge is 30 degrees or less.
|
|
3704
|
+
* 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.
|
|
3705
|
+
*/
|
|
3706
|
+
export declare function ridgeLines(input: HighwayInput, o: Readonly<RidgeOptions>): SnapLine[];
|
|
3707
|
+
/**
|
|
3708
|
+
* This function gives the highways of the ridges of the line density (HWY-032). One pass draws the density, with no advection.
|
|
3709
|
+
* The ridges of the density are the spines, and the edges near a ridge snap to it between their nearest entry and exit points.
|
|
3710
|
+
*/
|
|
3711
|
+
export declare function ridgePlan(input: HighwayInput, o: Readonly<RidgeOptions>): HighwayPlan;
|
|
3712
|
+
/** The options of the highway strategy `soft-keys` (HWY-019 of the note on highways). */
|
|
3713
|
+
interface SoftKeyOptions {
|
|
3714
|
+
/** The rule that gives the key of each edge. The default is `byCollection`: the string `data.collection`. */
|
|
3715
|
+
readonly rule: GroupRule;
|
|
3716
|
+
/** 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. */
|
|
3717
|
+
readonly lambda: number;
|
|
3718
|
+
/** Two clusters join while their distance is this value or less. The default is 0.5. */
|
|
3719
|
+
readonly tau: number;
|
|
3720
|
+
/** The names of number fields of `data` that add a distance. The default is no field. */
|
|
3721
|
+
readonly attributes: readonly string[];
|
|
3722
|
+
/** The weight of each field of `attributes`. The distance of a field is its difference over its range. The default is 1. */
|
|
3723
|
+
readonly weight: number;
|
|
3724
|
+
/** The linkage of the clustering. The default is `average`. */
|
|
3725
|
+
readonly linkage: Linkage;
|
|
3726
|
+
/** A cluster with this number of edges or more gets highways. The default is 2. */
|
|
3727
|
+
readonly minSize: number;
|
|
3728
|
+
/** The spine of each cluster. The default is `shared`: the router `shared` with the cluster as the key. */
|
|
3729
|
+
readonly spine: GroupSpine;
|
|
3730
|
+
}
|
|
3731
|
+
/** The default options of the strategy `soft-keys`. */
|
|
3732
|
+
export declare const SOFT_KEY_DEFAULTS: Readonly<SoftKeyOptions>;
|
|
3733
|
+
/**
|
|
3734
|
+
* 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)`.
|
|
3735
|
+
* `d_geom` is the flow distance of HWY-023. The key term is 0 when an edge has no key.
|
|
3736
|
+
*/
|
|
3737
|
+
export declare function softDistance(geom: number, keyA: string | undefined, keyB: string | undefined, lambda: number, attributes: number): number;
|
|
3738
|
+
/**
|
|
3739
|
+
* This function gives the soft-key clusters of the edges (HWY-019). It clusters the edges with `softDistance`, with the cut at `tau`.
|
|
3740
|
+
* 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.
|
|
3741
|
+
*/
|
|
3742
|
+
export declare function softKeyClusters(input: HighwayInput, o: Readonly<SoftKeyOptions>): Map<string, EdgeGroup>;
|
|
3743
|
+
/**
|
|
3744
|
+
* 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.
|
|
3745
|
+
* 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.
|
|
3746
|
+
*/
|
|
3747
|
+
export declare function softKeyPlan(input: HighwayInput, o: Readonly<SoftKeyOptions>): HighwayPlan;
|
|
3214
3748
|
/** The end of the edges that gets a field: the target of a fan-in, or the source of a fan-out. */
|
|
3215
3749
|
type FieldEnd = "target" | "source";
|
|
3216
3750
|
/** The options of the highway strategy `flow-field` (EDA-046 with HWY-037 of the notes). */
|
|
@@ -3299,41 +3833,36 @@ export declare function meetMember(spine: readonly Point[], member: HighwayMembe
|
|
|
3299
3833
|
* Each member gets the places of `meetMember`. The spines and the trips do not change.
|
|
3300
3834
|
*/
|
|
3301
3835
|
export declare function meetPlan(input: HighwayInput, o: Readonly<MeetOptions>): HighwayPlan;
|
|
3302
|
-
/**
|
|
3303
|
-
|
|
3304
|
-
|
|
3305
|
-
|
|
3306
|
-
|
|
3307
|
-
|
|
3308
|
-
|
|
3309
|
-
|
|
3310
|
-
|
|
3311
|
-
readonly
|
|
3312
|
-
|
|
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. */
|
|
3836
|
+
/** The options of the highway strategy `mingle` (HWY-003 of the note on highways). */
|
|
3837
|
+
interface MingleOptions {
|
|
3838
|
+
/** Each bundle looks for a merge among this number of nearest bundles in 4D. The default is 8. */
|
|
3839
|
+
readonly k: number;
|
|
3840
|
+
/** 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. */
|
|
3841
|
+
readonly maxTurn: number;
|
|
3842
|
+
/** The number of levels of merges. The default is 6. */
|
|
3843
|
+
readonly levels: number;
|
|
3844
|
+
/** The weight of the trunk in the ink. With 1, the trunk costs its length one time. The default is 1. */
|
|
3845
|
+
readonly weight: number;
|
|
3846
|
+
/** A bundle with this number of edges or more gets highways. The default is 2. */
|
|
3318
3847
|
readonly minSize: number;
|
|
3319
|
-
/**
|
|
3320
|
-
|
|
3321
|
-
* The span is the distance between the two terminals. `Infinity` sets no limit.
|
|
3322
|
-
*/
|
|
3323
|
-
readonly legMax?: number;
|
|
3848
|
+
/** The spine of each bundle. The default is `trunk`: one trunk between the two meeting points. */
|
|
3849
|
+
readonly spine: GroupSpine;
|
|
3324
3850
|
}
|
|
3851
|
+
/** The default options of the strategy `mingle`. */
|
|
3852
|
+
export declare const MINGLE_DEFAULTS: Readonly<MingleOptions>;
|
|
3325
3853
|
/**
|
|
3326
|
-
* This function gives the
|
|
3327
|
-
*
|
|
3854
|
+
* This function gives the bundles of MINGLE (Gansner, Hu, North and Scheidegger 2011) as groups of edges.
|
|
3855
|
+
* Each edge is a point in 4D: its two plugs. At each level, each bundle examines its `k` nearest bundles in 4D.
|
|
3856
|
+
* 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.
|
|
3857
|
+
* A bundle merges one time at most in a level. The levels stop after `levels` levels, or when no merge saves ink.
|
|
3328
3858
|
*/
|
|
3329
|
-
export declare function
|
|
3859
|
+
export declare function mingleBundles(input: HighwayInput, o: Readonly<MingleOptions>): Map<string, EdgeGroup>;
|
|
3330
3860
|
/**
|
|
3331
|
-
* This function gives the highways of
|
|
3332
|
-
*
|
|
3333
|
-
*
|
|
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.
|
|
3861
|
+
* This function gives the highways of MINGLE (HWY-003). The bundles of `mingleBundles` with `minSize` edges or more get highways.
|
|
3862
|
+
* With the spine `trunk`, each bundle gets one trunk between its two meeting points, through the corner graph.
|
|
3863
|
+
* With `shared`, the edges of each bundle share their ways through the corner graph.
|
|
3335
3864
|
*/
|
|
3336
|
-
export declare function
|
|
3865
|
+
export declare function minglePlan(input: HighwayInput, o: Readonly<MingleOptions>): HighwayPlan;
|
|
3337
3866
|
/** The options of the highway strategy `od-cells` (EDA-033 with WILD-032 of the notes). */
|
|
3338
3867
|
interface OdCellOptions {
|
|
3339
3868
|
/** The depth of the cells in the tree of sections. Depth 1 is the level below the root. The default is 2. */
|
|
@@ -3402,6 +3931,104 @@ export declare function quickBundles(input: HighwayInput, o: Readonly<QuickBundl
|
|
|
3402
3931
|
* With the spine `shared`, the edges of each cluster share their ways through the corner graph. With `trunk`, each cluster gets one trunk.
|
|
3403
3932
|
*/
|
|
3404
3933
|
export declare function quickBundlesPlan(input: HighwayInput, o: Readonly<QuickBundlesOptions>): HighwayPlan;
|
|
3934
|
+
/** The options of the highway strategy `nested` (HWY-052 of the note on highways). */
|
|
3935
|
+
interface NestedOptions {
|
|
3936
|
+
/** 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. */
|
|
3937
|
+
readonly theta: number;
|
|
3938
|
+
/** The scale of each level is this value times the scale of the next closer level. The default is 2. */
|
|
3939
|
+
readonly ratio: number;
|
|
3940
|
+
/** The number of levels. The default is 3. */
|
|
3941
|
+
readonly levels: number;
|
|
3942
|
+
/** The level of the plan. Level 0 is the closest level, and level `levels - 1` is the far level. The default is 0. */
|
|
3943
|
+
readonly level: number;
|
|
3944
|
+
/** The number of points of each line after the resampling. The default is 12. */
|
|
3945
|
+
readonly points: number;
|
|
3946
|
+
/** The line of each edge. The default is `routes`. */
|
|
3947
|
+
readonly line: BundleLine;
|
|
3948
|
+
/** The order of the edges. The default is `input`. */
|
|
3949
|
+
readonly order: BundleOrder;
|
|
3950
|
+
/** A cluster with this number of edges or more gets highways. The default is 2. */
|
|
3951
|
+
readonly minSize: number;
|
|
3952
|
+
/** The spine of each cluster. The default is `shared`. */
|
|
3953
|
+
readonly spine: GroupSpine;
|
|
3954
|
+
}
|
|
3955
|
+
/** The default options of the strategy `nested`. */
|
|
3956
|
+
export declare const NESTED_DEFAULTS: Readonly<NestedOptions>;
|
|
3957
|
+
/**
|
|
3958
|
+
* This function gives the groups of edges of each level, from the closest level (index 0) to the far level.
|
|
3959
|
+
* The far level puts all the edges in clusters at the scale `theta × ratio^(levels - 1)`.
|
|
3960
|
+
* 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.
|
|
3961
|
+
*/
|
|
3962
|
+
export declare function nestedGroups(input: HighwayInput, o: Readonly<NestedOptions>): Map<string, EdgeGroup>[];
|
|
3963
|
+
/**
|
|
3964
|
+
* This function gives the number of groups of the closer level `fine` with edges in two groups or more of the level `coarse`.
|
|
3965
|
+
* An edge that is not in `coarse` does not count. The groups of `nestedGroups` give 0.
|
|
3966
|
+
*/
|
|
3967
|
+
export declare function nestingViolations(coarse: ReadonlyMap<string, EdgeGroup>, fine: ReadonlyMap<string, EdgeGroup>): number;
|
|
3968
|
+
/**
|
|
3969
|
+
* 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.
|
|
3970
|
+
* The clusters of that level with `minSize` edges or more get highways, as in the strategy `quickbundles`.
|
|
3971
|
+
*/
|
|
3972
|
+
export declare function nestedPlan(input: HighwayInput, o: Readonly<NestedOptions>): HighwayPlan;
|
|
3973
|
+
/** The options of the highway strategy `lanes` (HWY-051 of the note on highways). */
|
|
3974
|
+
interface LanesOptions {
|
|
3975
|
+
/** The distance from a box to the corners of the graph. The default is 5. */
|
|
3976
|
+
readonly margin?: number;
|
|
3977
|
+
/** The number of visible neighbours of each corner. The default is 8. */
|
|
3978
|
+
readonly k?: number;
|
|
3979
|
+
/** The plan that the strategy changes. The default is `shared-ways`. */
|
|
3980
|
+
readonly from: HighwayBase;
|
|
3981
|
+
/** The gap between two lanes. The default is 4. */
|
|
3982
|
+
readonly laneGap: number;
|
|
3983
|
+
/** The largest width of a highway. The default is 32. */
|
|
3984
|
+
readonly maxWidth: number;
|
|
3985
|
+
/** The number of times that a highway can split, one half after the other. The default is 3. */
|
|
3986
|
+
readonly depth: number;
|
|
3987
|
+
}
|
|
3988
|
+
/** The default options of the strategy `lanes`. */
|
|
3989
|
+
export declare const LANES_DEFAULTS: Readonly<LanesOptions>;
|
|
3990
|
+
/**
|
|
3991
|
+
* This function gives the number of legs of the spines of a plan where the lanes do not fit in the channel.
|
|
3992
|
+
* A leg with two lanes or more needs `min(maxWidth, lanes × laneGap)`. The channel is the free space across the leg (`channelWidth`).
|
|
3993
|
+
*/
|
|
3994
|
+
export declare function channelOverflows(graph: Graph, plan: HighwayPlan, o: Readonly<Pick<LanesOptions, "laneGap" | "maxWidth" | "margin" | "k">>): number;
|
|
3995
|
+
/**
|
|
3996
|
+
* This function gives the plan of `from`, with each highway that does not fit in its channels split in two (HWY-051).
|
|
3997
|
+
* 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.
|
|
3998
|
+
* A highway with fewer than four lanes moves as one to the new spine.
|
|
3999
|
+
* 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.
|
|
4000
|
+
*/
|
|
4001
|
+
export declare function lanesPlan(input: HighwayInput, o: Readonly<LanesOptions>): HighwayPlan;
|
|
4002
|
+
/** The order of the edges in the growth: the longest first route first, or the order of the graph. */
|
|
4003
|
+
type GrowthOrder = "length" | "input";
|
|
4004
|
+
/** The options of the highway strategy `growth` (HWY-055 of the note on highways). */
|
|
4005
|
+
interface GrowthOptions {
|
|
4006
|
+
/** The distance from a box to the corners of the graph. The default is 5. */
|
|
4007
|
+
readonly margin?: number;
|
|
4008
|
+
/** The number of visible neighbours of each corner. The default is 8. */
|
|
4009
|
+
readonly k?: number;
|
|
4010
|
+
/** The order of the edges. The default is `length`. */
|
|
4011
|
+
readonly order: GrowthOrder;
|
|
4012
|
+
/** 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. */
|
|
4013
|
+
readonly share: number;
|
|
4014
|
+
/** 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. */
|
|
4015
|
+
readonly stretch: number;
|
|
4016
|
+
/** A spine end extends when this number of its lanes or more go on together. The default is 3. */
|
|
4017
|
+
readonly extendLanes: number;
|
|
4018
|
+
/** 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. */
|
|
4019
|
+
readonly extendRadius: number;
|
|
4020
|
+
/** A highway with this number of edges or more stays in the plan. The default is 2. */
|
|
4021
|
+
readonly minSize: number;
|
|
4022
|
+
}
|
|
4023
|
+
/** The default options of the strategy `growth`. */
|
|
4024
|
+
export declare const GROWTH_DEFAULTS: Readonly<GrowthOptions>;
|
|
4025
|
+
/**
|
|
4026
|
+
* This function gives the highways of local growth (HWY-055). The edges come one by one, by default the longest first route first.
|
|
4027
|
+
* 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.
|
|
4028
|
+
* After the growth, a spine end can go on to the center of the far ends of its lanes.
|
|
4029
|
+
* This occurs when `extendLanes` of them or more are near that center and the line is clear.
|
|
4030
|
+
*/
|
|
4031
|
+
export declare function growthPlan(input: HighwayInput, o: Readonly<GrowthOptions>): HighwayPlan;
|
|
3405
4032
|
/** The options of the highway strategy `road-classes` (HWY-034 with EDA-050 of the notes). */
|
|
3406
4033
|
interface RoadClassOptions extends Pick<WayOptions, "margin" | "k"> {
|
|
3407
4034
|
/** 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. */
|
|
@@ -3421,40 +4048,6 @@ export declare const ROAD_CLASS_DEFAULTS: Readonly<Required<Omit<RoadClassOption
|
|
|
3421
4048
|
* Each stretch of highway links that `minSize` ways or more share after the second pass is one highway.
|
|
3422
4049
|
*/
|
|
3423
4050
|
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;
|
|
3458
4051
|
/** The options of the highway strategy `shared-ways`: the options of the router `shared`, without the name and the limit of the benchmark. */
|
|
3459
4052
|
type SharedWaysOptions = Omit<SharedOptions, "name" | "maxNodes">;
|
|
3460
4053
|
/**
|
|
@@ -3463,6 +4056,51 @@ type SharedWaysOptions = Omit<SharedOptions, "name" | "maxNodes">;
|
|
|
3463
4056
|
* The function does not change the router: it reads its runs.
|
|
3464
4057
|
*/
|
|
3465
4058
|
export declare function sharedWaysPlan(input: HighwayInput, options: SharedWaysOptions): HighwayPlan;
|
|
4059
|
+
/** The options of the highway strategy `spiral` (HWY-017 with EDA-035 of the notes). */
|
|
4060
|
+
interface SpiralOptions extends Pick<WayOptions, "margin" | "k"> {
|
|
4061
|
+
/** The spiral angle, in degrees: the largest angle between a branch and the line to the root. The default is 25. */
|
|
4062
|
+
readonly alpha: number;
|
|
4063
|
+
/** A node with this number of edges or more gets a spiral tree. The default is 4. */
|
|
4064
|
+
readonly minTargets: number;
|
|
4065
|
+
/** The number of points of the arc of each branch. The default is 4. */
|
|
4066
|
+
readonly arc: number;
|
|
4067
|
+
}
|
|
4068
|
+
/** The default options of the strategy `spiral`. */
|
|
4069
|
+
export declare const SPIRAL_DEFAULTS: Readonly<Required<Omit<SpiralOptions, "margin" | "k">>>;
|
|
4070
|
+
/** One node of a spiral tree, in polar coordinates around the root. A leaf has an edge, and a join has two children. */
|
|
4071
|
+
interface SpiralNode {
|
|
4072
|
+
readonly r: number;
|
|
4073
|
+
readonly theta: number;
|
|
4074
|
+
readonly point: Point;
|
|
4075
|
+
/** 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. */
|
|
4076
|
+
readonly clear: number;
|
|
4077
|
+
readonly edge?: string;
|
|
4078
|
+
readonly children: readonly SpiralNode[];
|
|
4079
|
+
}
|
|
4080
|
+
/**
|
|
4081
|
+
* 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.
|
|
4082
|
+
* Each node can reach the points inside its two spirals toward the root: `|theta - theta_p| <= tan(alpha) ln(r_p / r)`.
|
|
4083
|
+
* The join is the point farthest from the root that both nodes reach, and that is `clear` nearer to the root than each node.
|
|
4084
|
+
* At that radius, the join is at the middle of the angles that both nodes reach.
|
|
4085
|
+
*/
|
|
4086
|
+
export declare function spiralJoin(p: SpiralNode, q: SpiralNode, alpha: number, root: Point): {
|
|
4087
|
+
r: number;
|
|
4088
|
+
theta: number;
|
|
4089
|
+
point: Point;
|
|
4090
|
+
} | undefined;
|
|
4091
|
+
/**
|
|
4092
|
+
* This function gives the spiral tree of the leaves around the root (Buchin, Speckmann and Verbeek 2011), with the greedy sweep.
|
|
4093
|
+
* 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.
|
|
4094
|
+
* 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.
|
|
4095
|
+
*/
|
|
4096
|
+
export declare function spiralTree(leaves: readonly SpiralNode[], alpha: number, root: Point, rMin: number): SpiralNode[];
|
|
4097
|
+
/**
|
|
4098
|
+
* 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.
|
|
4099
|
+
* 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.
|
|
4100
|
+
* 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.
|
|
4101
|
+
* An edge rides the branches from the root to its leaf, or from its leaf to the root when the root is its target.
|
|
4102
|
+
*/
|
|
4103
|
+
export declare function spiralPlan(input: HighwayInput, o: Readonly<SpiralOptions>): HighwayPlan;
|
|
3466
4104
|
/** The ends of the edges that get stubs: the source ends, the target ends, or both. */
|
|
3467
4105
|
type StubEnds = "source" | "target" | "both";
|
|
3468
4106
|
/** The options of the highway strategy `stubs` (HWY-015 with WILD-005 of the notes). */
|
|
@@ -3490,6 +4128,78 @@ export declare const STUB_DEFAULTS: Readonly<StubOptions>;
|
|
|
3490
4128
|
* 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
4129
|
*/
|
|
3492
4130
|
export declare function stubPlan(input: HighwayInput, o: Readonly<StubOptions>): HighwayPlan;
|
|
4131
|
+
/** The options of the highway strategy `traclus` (HWY-025 of the note on highways). */
|
|
4132
|
+
interface TraclusOptions extends Pick<WayOptions, "margin" | "k"> {
|
|
4133
|
+
/** Two segments are neighbours when their distance is this value or less, in units of the board. The default is 2. */
|
|
4134
|
+
readonly eps: number;
|
|
4135
|
+
/** 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. */
|
|
4136
|
+
readonly minLns: number;
|
|
4137
|
+
/** The weight of the perpendicular distance. The default is 1. */
|
|
4138
|
+
readonly wPerp: number;
|
|
4139
|
+
/** The weight of the parallel distance. The default is 1. */
|
|
4140
|
+
readonly wPar: number;
|
|
4141
|
+
/** The weight of the angle distance. The default is 1. */
|
|
4142
|
+
readonly wTheta: number;
|
|
4143
|
+
/** 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. */
|
|
4144
|
+
readonly mdl: number;
|
|
4145
|
+
}
|
|
4146
|
+
/** The default options of the strategy `traclus`. */
|
|
4147
|
+
export declare const TRACLUS_DEFAULTS: Readonly<Required<Omit<TraclusOptions, "margin" | "k">>>;
|
|
4148
|
+
/** One segment of a partitioned route: the edge, the index of the segment in the route, and its two ends. */
|
|
4149
|
+
interface RouteSegment {
|
|
4150
|
+
readonly edge: string;
|
|
4151
|
+
readonly index: number;
|
|
4152
|
+
readonly a: Point;
|
|
4153
|
+
readonly b: Point;
|
|
4154
|
+
}
|
|
4155
|
+
/**
|
|
4156
|
+
* 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`.
|
|
4157
|
+
* `d_perp` is `(l1² + l2²) / (l1 + l2)` with the distances of the ends of the shorter segment to the line of the longer segment.
|
|
4158
|
+
* `d_par` is the gap along the longer segment between the two segments, 0 when they overlap. `d_theta` is `|shorter| sin(theta)`.
|
|
4159
|
+
* The segments have no direction, so the angle is 90 degrees or less.
|
|
4160
|
+
*/
|
|
4161
|
+
export declare function segmentDistance(p: {
|
|
4162
|
+
a: Point;
|
|
4163
|
+
b: Point;
|
|
4164
|
+
}, q: {
|
|
4165
|
+
a: Point;
|
|
4166
|
+
b: Point;
|
|
4167
|
+
}, w: {
|
|
4168
|
+
perp: number;
|
|
4169
|
+
par: number;
|
|
4170
|
+
theta: number;
|
|
4171
|
+
}): number;
|
|
4172
|
+
/**
|
|
4173
|
+
* This function gives the characteristic points of a route by the rule of the minimum description length (MDL) of TRACLUS.
|
|
4174
|
+
* 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.
|
|
4175
|
+
* 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.
|
|
4176
|
+
*/
|
|
4177
|
+
export declare function characteristicPoints(route: readonly Point[], unit: number, ratio: number): Point[];
|
|
4178
|
+
/**
|
|
4179
|
+
* This function gives the clusters of segments of DBSCAN. A segment with `minLns` neighbours or more within `eps` (itself included) is a core segment.
|
|
4180
|
+
* A cluster grows from each core segment through its neighbours. A cluster with segments of fewer than `minLns` edges is dropped.
|
|
4181
|
+
*/
|
|
4182
|
+
export declare function segmentClusters(segments: readonly RouteSegment[], eps: number, minLns: number, w: {
|
|
4183
|
+
perp: number;
|
|
4184
|
+
par: number;
|
|
4185
|
+
theta: number;
|
|
4186
|
+
}): RouteSegment[][];
|
|
4187
|
+
/**
|
|
4188
|
+
* This function gives the representative line of a cluster of segments. The line goes along the mean direction of the segments.
|
|
4189
|
+
* 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.
|
|
4190
|
+
* Two points of the line are at least `gap` apart.
|
|
4191
|
+
*/
|
|
4192
|
+
export declare function representative(cluster: readonly RouteSegment[], minLns: number, gap: number): Point[];
|
|
4193
|
+
/**
|
|
4194
|
+
* This function gives the highways of TRACLUS (HWY-025). Each first route breaks into a few long segments by the rule of MDL.
|
|
4195
|
+
* 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.
|
|
4196
|
+
* 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.
|
|
4197
|
+
* 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.
|
|
4198
|
+
* An edge rides only when both ends of its part are within `eps` of the spine.
|
|
4199
|
+
* Its length on the spine is also at most 1.25 times the length of its own route there.
|
|
4200
|
+
* Each edge rides one highway at most: the highway where it rides the longest length.
|
|
4201
|
+
*/
|
|
4202
|
+
export declare function traclusPlan(input: HighwayInput, o: Readonly<TraclusOptions>): HighwayPlan;
|
|
3493
4203
|
/** The options of the highway strategy `weiszfeld` (HWY-043 of the note on highways). */
|
|
3494
4204
|
interface WeiszfeldOptions {
|
|
3495
4205
|
/** The plan whose highways get new meeting points. The default is `shared-ways`. */
|
|
@@ -3718,6 +4428,20 @@ export declare const highwayStrategies: {
|
|
|
3718
4428
|
readonly wspd: Strategy<"highway", WspdOptions>;
|
|
3719
4429
|
readonly "od-cells": Strategy<"highway", OdCellOptions>;
|
|
3720
4430
|
readonly select: Strategy<"highway", SelectOptions>;
|
|
4431
|
+
readonly mingle: Strategy<"highway", MingleOptions>;
|
|
4432
|
+
readonly spiral: Strategy<"highway", SpiralOptions>;
|
|
4433
|
+
readonly "flow-clusters": Strategy<"highway", FlowClusterOptions>;
|
|
4434
|
+
readonly traclus: Strategy<"highway", TraclusOptions>;
|
|
4435
|
+
readonly diffusion: Strategy<"highway", DiffusionOptions>;
|
|
4436
|
+
readonly nested: Strategy<"highway", NestedOptions>;
|
|
4437
|
+
readonly lanes: Strategy<"highway", LanesOptions>;
|
|
4438
|
+
readonly growth: Strategy<"highway", GrowthOptions>;
|
|
4439
|
+
readonly "edge-paths": Strategy<"highway", EdgePathOptions>;
|
|
4440
|
+
readonly "soft-keys": Strategy<"highway", SoftKeyOptions>;
|
|
4441
|
+
readonly hough: Strategy<"highway", HoughOptions>;
|
|
4442
|
+
readonly ridges: Strategy<"highway", RidgeOptions>;
|
|
4443
|
+
readonly hdbscan: Strategy<"highway", HdbscanOptions>;
|
|
4444
|
+
readonly "hub-arcs": Strategy<"highway", HubArcOptions>;
|
|
3721
4445
|
readonly "corridors+breakeven": Strategy<"highway", CorridorOptions & BreakEvenOptions>;
|
|
3722
4446
|
readonly "corridors+stretch": Strategy<"highway", CorridorOptions & StretchOptions>;
|
|
3723
4447
|
readonly "corridors+ambiguity": Strategy<"highway", CorridorOptions & AmbiguityGuardOptions>;
|
|
@@ -3884,8 +4608,8 @@ export interface LayoutBox {
|
|
|
3884
4608
|
readonly parent?: string;
|
|
3885
4609
|
/** The group of the box. */
|
|
3886
4610
|
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?:
|
|
4611
|
+
/** 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. */
|
|
4612
|
+
readonly locked?: boolean;
|
|
3889
4613
|
/** The reading order that the caller wants. The router ignores it. */
|
|
3890
4614
|
readonly rank?: number;
|
|
3891
4615
|
readonly ports?: readonly LayoutPort[];
|
|
@@ -3919,7 +4643,7 @@ export interface LayoutGenerator {
|
|
|
3919
4643
|
* The packer reads the first six dimensions. The router reads the last four.
|
|
3920
4644
|
*/
|
|
3921
4645
|
export interface LayoutCell {
|
|
3922
|
-
readonly containerSize?: "fixed" | "freeWidth" | "freeAspect";
|
|
4646
|
+
readonly containerSize?: "fixed" | "freeHeight" | "freeWidth" | "freeAspect" | "freeArea";
|
|
3923
4647
|
readonly containerShape?: "rect" | "convex" | "polygon" | "circle" | "ellipse" | "holes";
|
|
3924
4648
|
readonly obstacles?: "none" | "center" | "scattered" | "wall" | "corridors" | "touching" | "edge";
|
|
3925
4649
|
readonly sizes?: "identical" | "uniform" | "heavyTail" | "bimodal" | "extremeAspect" | "nearIdentical";
|
|
@@ -4045,13 +4769,20 @@ export declare function regionBounds(region: Region): {
|
|
|
4045
4769
|
w: number;
|
|
4046
4770
|
h: number;
|
|
4047
4771
|
};
|
|
4772
|
+
/**
|
|
4773
|
+
* The fields of an input that `inputGraph` reads. A contract input, for example the result of `applyPack`, has these fields.
|
|
4774
|
+
* Without `edges`, the input has no edges.
|
|
4775
|
+
*/
|
|
4776
|
+
export type RouteInput = Pick<LayoutInput, "id" | "boxes" | "obstacles"> & {
|
|
4777
|
+
readonly edges?: LayoutInput["edges"];
|
|
4778
|
+
};
|
|
4048
4779
|
/**
|
|
4049
4780
|
* 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
4781
|
* Each obstacle becomes a node without edges, with the bounding box of its region, after the boxes.
|
|
4051
4782
|
* 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
4783
|
* A box without `x` and `y` is an error.
|
|
4053
4784
|
*/
|
|
4054
|
-
export declare function inputGraph(input:
|
|
4785
|
+
export declare function inputGraph(input: RouteInput): Graph;
|
|
4055
4786
|
/**
|
|
4056
4787
|
* This function writes an input file as text: the keys in sorted order, and one box or one edge on each line.
|
|
4057
4788
|
* `JSON.parse` of the text gives the input again.
|
|
@@ -4486,5 +5217,5 @@ export declare function withRepair(router: Router, options?: RepairOptions): Rou
|
|
|
4486
5217
|
* The new strategy has the name `<name>+repair`, and the options and the schema of `strategy`. The strategy `strategy` does not change.
|
|
4487
5218
|
*/
|
|
4488
5219
|
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 };
|
|
5220
|
+
export type { AmbiguityGuardOptions, ArcOptions, ArcSource, BreakEvenOptions, BundleLine, BundleOrder, CandidateSource, ClothoidOptions, CornersOptions, CorridorOptions, CurveSpace, CutObjective, CutOptions, DensityImage, DiffusionOptions, EdgeDistance, EdgeGroup, EdgeLengths, EdgePathOptions, EdgePlugs, FieldEnd, FlowClusterOptions, FlowFieldOptions, FollowOptions, Gate, GroupSpine, GroupedOptions, GrowthOptions, GrowthOrder, HdbscanOptions, Highway, HighwayBase, HighwayInput, HighwayMember, HighwayOptions, HighwayPlan, HoughOptions, HoughPeak, HubArcOptions, HysteresisOptions, JogStyle, KdAxis, KdLine, KdOptions, KeyOptions, KeyedWay, KeysOptions, LaneCurve, LanesOptions, LevelHighwayOptions, Linkage, MeetOptions, MingleOptions, NestedOptions, NodeKey, OdCellOptions, PathStep, QuickBundlesOptions, Ridge, RidgeOptions, RidgeSource, RoadClassOptions, RoomBends, RoundedOptions, RouteSegment, SectionsOptions, SelectOptions, ShareCost, ShareMerge, ShareOrder, SharedOptions, SharedStretchOptions, SharedWaysOptions, SmoothOptions, SnapLine, SnapMember, SnapOptions, SoftKeyOptions, SpiralNode, SpiralOptions, SplineOptions, SplitCell, StableIdOptions, StretchOptions, StubEnds, StubOptions, TraclusOptions, TrunkFan, TrunkSplit, TrunksOptions, WeiszfeldOptions, WspdOptions, Zip, ZipLimits, ZipperOptions };
|
|
4490
5221
|
//# sourceMappingURL=index.d.ts.map
|