@mark1russell7/highways 0.5.0 → 0.6.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.
Files changed (56) hide show
  1. package/README.md +47 -2
  2. package/build/index.d.ts +1489 -63
  3. package/build/index.d.ts.map +1 -1
  4. package/build/index.js +10139 -3356
  5. package/build/index.js.map +1 -1
  6. package/package.json +11 -2
  7. package/src/bench/exact/index.ts +218 -11
  8. package/src/bench/exact/optima-exact-v1-bounds.json +14409 -0
  9. package/src/bench/exact/optima-exact-v1.json +4809 -0
  10. package/src/bench/exact/solve.ts +129 -0
  11. package/src/bench/screen/activation.ts +3 -0
  12. package/src/bench/screen/bounds.ts +140 -0
  13. package/src/bench/screen/compare.ts +26 -0
  14. package/src/bench/screen/exact-set.ts +100 -0
  15. package/src/bench/screen/exercise.ts +290 -0
  16. package/src/bench/screen/forms.ts +14 -0
  17. package/src/bench/screen/gap.ts +316 -0
  18. package/src/bench/screen/hash.ts +7 -76
  19. package/src/bench/screen/index.ts +6 -0
  20. package/src/bench/screen/measures.ts +71 -1
  21. package/src/bench/screen/portfolio-pick.ts +20 -0
  22. package/src/bench/screen/screen.ts +50 -2
  23. package/src/bench/screen/set.ts +3 -2
  24. package/src/highways/areas/index.ts +160 -0
  25. package/src/highways/confluent/index.ts +154 -0
  26. package/src/highways/confluent/k23.test-util.ts +8 -0
  27. package/src/highways/consensus/index.ts +129 -0
  28. package/src/highways/crossbars/index.ts +184 -0
  29. package/src/highways/cubu/index.ts +26 -0
  30. package/src/highways/divided/index.ts +111 -0
  31. package/src/highways/fdeb/index.ts +193 -0
  32. package/src/highways/frechet/index.ts +232 -0
  33. package/src/highways/hierarchy/index.ts +140 -0
  34. package/src/highways/index.ts +64 -0
  35. package/src/highways/kdeeb/index.ts +355 -0
  36. package/src/highways/link-communities/index.ts +189 -0
  37. package/src/highways/mesh/index.ts +209 -0
  38. package/src/highways/mlseb/index.ts +204 -0
  39. package/src/highways/p-hub/index.ts +248 -0
  40. package/src/highways/power/index.ts +117 -0
  41. package/src/highways/resistance/index.ts +159 -0
  42. package/src/highways/sbeb/index.ts +303 -0
  43. package/src/highways/scale-space/index.ts +135 -0
  44. package/src/highways/spectral/index.ts +391 -0
  45. package/src/highways/territories/index.ts +150 -0
  46. package/src/highways/trace.ts +153 -0
  47. package/src/index.ts +3 -0
  48. package/src/portfolio/bands.ts +38 -0
  49. package/src/portfolio/fit.ts +41 -0
  50. package/src/portfolio/index.ts +6 -0
  51. package/src/portfolio/key.ts +98 -0
  52. package/src/portfolio/members.ts +171 -0
  53. package/src/portfolio/router.ts +133 -0
  54. package/src/portfolio/sets.ts +40 -0
  55. package/src/strategies/builtins.ts +222 -1
  56. package/src/strategies/schemas.ts +280 -1
@@ -1,30 +1,50 @@
1
+ import type { AreaOptions } from "../highways/areas/index.ts";
2
+ import type { ConfluentOptions, GroupScope } from "../highways/confluent/index.ts";
3
+ import type { CrossbarOptions } from "../highways/crossbars/index.ts";
4
+ import type { FrechetOptions } from "../highways/frechet/index.ts";
5
+ import type { MlsebOptions } from "../highways/mlseb/index.ts";
6
+ import type { PowerOptions } from "../highways/power/index.ts";
7
+ import type { SbebOptions } from "../highways/sbeb/index.ts";
1
8
  import type { CutOptions } from "../groups/cut/index.ts";
2
9
  import type { KdOptions } from "../groups/kd/index.ts";
3
10
  import type { KeyOptions } from "../groups/keys/index.ts";
4
11
  import type { HighwayBase } from "../highways/base.ts";
5
12
  import type { CorridorOptions } from "../highways/corridors/index.ts";
13
+ import type { ConsensusOptions } from "../highways/consensus/index.ts";
14
+ import type { CubuOptions } from "../highways/cubu/index.ts";
6
15
  import type { DiffusionOptions } from "../highways/diffusion/index.ts";
16
+ import type { DividedOptions } from "../highways/divided/index.ts";
7
17
  import type { EdgePathOptions } from "../highways/edge-paths/index.ts";
18
+ import type { FdebOptions } from "../highways/fdeb/index.ts";
8
19
  import type { FlowClusterOptions } from "../highways/flow-clusters/index.ts";
9
20
  import type { FlowFieldOptions } from "../highways/flow-field/index.ts";
10
21
  import type { GrowthOptions } from "../highways/growth/index.ts";
11
22
  import type { GroupSpine } from "../highways/grouped.ts";
12
23
  import type { HdbscanOptions } from "../highways/hdbscan/index.ts";
24
+ import type { HierarchyOptions } from "../highways/hierarchy/index.ts";
13
25
  import type { HoughOptions } from "../highways/hough/index.ts";
14
26
  import type { HubArcOptions } from "../highways/hub-arcs/index.ts";
27
+ import type { KdeebOptions } from "../highways/kdeeb/index.ts";
15
28
  import type { LanesOptions } from "../highways/lanes/index.ts";
16
29
  import type { LevelHighwayOptions } from "../highways/level-links/index.ts";
30
+ import type { LinkCommunityOptions } from "../highways/link-communities/index.ts";
17
31
  import type { MeetOptions } from "../highways/meet/index.ts";
32
+ import type { MeshOptions } from "../highways/mesh/index.ts";
18
33
  import type { MingleOptions } from "../highways/mingle/index.ts";
19
34
  import type { NestedOptions } from "../highways/nested/index.ts";
20
35
  import type { OdCellOptions } from "../highways/od-cells/index.ts";
36
+ import type { PHubOptions } from "../highways/p-hub/index.ts";
21
37
  import type { QuickBundlesOptions } from "../highways/quickbundles/index.ts";
38
+ import type { ResistanceOptions } from "../highways/resistance/index.ts";
22
39
  import type { RidgeOptions } from "../highways/ridges/index.ts";
23
40
  import type { RoadClassOptions } from "../highways/road-classes/index.ts";
41
+ import type { ScaleSpaceOptions } from "../highways/scale-space/index.ts";
24
42
  import type { SelectOptions } from "../highways/select/index.ts";
25
43
  import type { SoftKeyOptions } from "../highways/soft-keys/index.ts";
44
+ import type { SpectralOptions } from "../highways/spectral/index.ts";
26
45
  import type { SpiralOptions } from "../highways/spiral/index.ts";
27
46
  import type { StubOptions } from "../highways/stubs/index.ts";
47
+ import type { TerritoryOptions } from "../highways/territories/index.ts";
28
48
  import type { TraclusOptions } from "../highways/traclus/index.ts";
29
49
  import type { WeiszfeldOptions } from "../highways/weiszfeld/index.ts";
30
50
  import type { WspdOptions } from "../highways/wspd/index.ts";
@@ -37,7 +57,7 @@ import type { SectionOptions } from "../sections.ts";
37
57
  import type { WayOptions } from "../ways.ts";
38
58
  import type { RunOrder } from "../segments.ts";
39
59
  import type { ClothoidStrategyOptions, HighwayStrategyOptions, LevelRoomPreset, RadiusOptions, RoomPreset, RouterPreset, SmoothStrategyOptions, TensionOptions } from "./builtins.ts";
40
- import type { EnumOption, OptionSchema } from "./options.ts";
60
+ import type { EnumOption, NumberOption, OptionSchema } from "./options.ts";
41
61
 
42
62
  // The declarations of the options of the built-in strategies. Each `default` is the value that the function uses without the option.
43
63
  // The test of the defaults runs each strategy with `optionDefaults` and with no option, and compares the output.
@@ -583,3 +603,262 @@ export const HUB_ARC_SCHEMA: OptionSchema<HubArcOptions> = {
583
603
  minSize: { type: "integer", min: 2, max: 16, step: 1, default: 2, describe: "An arc with fewer edges than this number is not a highway." },
584
604
  generators: { type: "list", default: ["runs", "corridors", "road-classes"], describe: "The generators of the candidate arcs." },
585
605
  };
606
+
607
+ /** The declarations of the options of the highway strategy `divided` (HWY-011). */
608
+ export const DIVIDED_SCHEMA: OptionSchema<DividedOptions> = {
609
+ margin: WAY_SCHEMA.margin,
610
+ k: WAY_SCHEMA.k,
611
+ from: HIGHWAY_BASE,
612
+ rule: { type: "enum", values: ["right", "left"], default: "right", describe: "The side of the road of the traffic of each direction." },
613
+ gap: { type: "number", min: 0, max: 4, step: 0.5, marks: [1, 2], default: 1, describe: "The gap between the two carriageways, in lanes." },
614
+ laneWidth: { type: "number", min: 1, max: 12, step: 1, marks: [4], default: 4, describe: "The width of one lane, in units of the board." },
615
+ minSize: { type: "integer", min: 1, max: 16, step: 1, default: 2, describe: "A highway divides only when each direction has this number of edges or more." },
616
+ };
617
+
618
+ /** The declarations of the options of the highway strategy `hierarchy` (HWY-001). */
619
+ export const HIERARCHY_SCHEMA: OptionSchema<HierarchyOptions> = {
620
+ margin: WAY_SCHEMA.margin,
621
+ k: WAY_SCHEMA.k,
622
+ group: { type: "enum", values: ["quadtree", "kd", "cut"], default: "quadtree", describe: "The tree of sections that gives the hubs." },
623
+ cap: { type: "integer", min: 1, max: 32, step: 1, marks: [4, 8, 16], default: 8, describe: "A section with more nodes splits." },
624
+ beta: { type: "number", min: 0, max: 1, step: 0.05, marks: [0.5, 0.85], default: 0.85, describe: "The pull of the hubs. The value 0 gives the straight line, and 1 goes through each hub." },
625
+ hubs: {
626
+ type: "integer",
627
+ min: 0,
628
+ max: 8,
629
+ step: 1,
630
+ special: [Infinity],
631
+ default: Infinity,
632
+ describe: "The largest number of hubs on each side of the lowest common section. `Infinity` uses each hub.",
633
+ },
634
+ snap: { type: "number", min: 0, max: 32, step: 2, marks: [8, 16], default: 8, describe: "The side of the grid that the hubs snap to, in units of the board." },
635
+ minSize: { type: "integer", min: 2, max: 16, step: 1, default: 2, describe: "A highway has this number of edges or more." },
636
+ };
637
+
638
+ /** The declarations of the options of the highway strategy `fdeb` (HWY-002 with RULE-002). */
639
+ export const FDEB_SCHEMA: OptionSchema<FdebOptions> = {
640
+ margin: WAY_SCHEMA.margin,
641
+ k: WAY_SCHEMA.k,
642
+ compatibility: { type: "number", min: 0.05, max: 1, step: 0.05, marks: [0.4, 0.6, 0.8], default: 0.6, describe: "Two edges attract each other when their compatibility is this value or more." },
643
+ spring: { type: "number", min: 0, max: 0.5, step: 0.05, default: 0.1, describe: "The spring constant that keeps each edge smooth." },
644
+ cycles: { type: "integer", min: 0, max: 7, step: 1, default: 5, describe: "The number of cycles. Each cycle doubles the points of each edge." },
645
+ iterations: { type: "integer", min: 0, max: 200, step: 10, marks: [50], default: 50, describe: "The number of steps of the first cycle." },
646
+ repulsion: { type: "number", min: 0, max: 4, step: 0.25, marks: [0, 1], default: 1, describe: "The weight of the push of the boxes. The value 0 turns it off." },
647
+ pullLimit: {
648
+ type: "number",
649
+ min: 1,
650
+ max: 3,
651
+ step: 0.05,
652
+ special: [Infinity],
653
+ marks: [1.25, 1.5, Infinity],
654
+ default: 1.25,
655
+ describe: "An edge longer than this value times its straight line gets no pull. `Infinity` sets no budget.",
656
+ },
657
+ snap: { type: "number", min: 0, max: 32, step: 2, marks: [8, 16], default: 8, describe: "The side of the grid that the points of the edges snap to, in units of the board." },
658
+ minSize: { type: "integer", min: 2, max: 16, step: 1, default: 2, describe: "A highway has this number of edges or more." },
659
+ };
660
+
661
+ /** The declarations of the options of the highway strategy `mesh` (HWY-004). */
662
+ export const MESH_SCHEMA: OptionSchema<MeshOptions> = {
663
+ margin: WAY_SCHEMA.margin,
664
+ k: WAY_SCHEMA.k,
665
+ cell: { type: "number", min: 1, max: 16, step: 0.5, marks: [2, 4, 8], default: 4, describe: "The side of a cell of the mesh, in units of the boxes." },
666
+ capacity: { type: "integer", min: 1, max: 32, step: 1, marks: [4, 8, 16], default: 8, describe: "A cluster of crossings has at most about this number of edges." },
667
+ merge: { type: "number", min: 0, max: 4, step: 0.25, marks: [1], default: 1, describe: "Two clusters nearer than this value, in units of the boxes, become one." },
668
+ angle: { type: "number", min: 0, max: 90, step: 5, marks: [30, 45], default: 45, describe: "A line crosses a segment of the mesh only within this angle in degrees to the main direction." },
669
+ minSize: { type: "integer", min: 2, max: 16, step: 1, default: 2, describe: "A highway has this number of edges or more." },
670
+ };
671
+
672
+ /** The declarations of the options of the highway strategy `kdeeb` (RULE-028 with HWY-006). */
673
+ export const KDEEB_SCHEMA: OptionSchema<KdeebOptions> = {
674
+ margin: WAY_SCHEMA.margin,
675
+ k: WAY_SCHEMA.k,
676
+ source: { type: "enum", values: ["lines", "routes"], default: "lines", describe: "The lines of the first density: the straight lines of the edges, or their first routes." },
677
+ cell: { type: "number", min: 2, max: 32, step: 1, marks: [4, 8, 16], default: 8, describe: "The size of a cell of the density image, in units of the board." },
678
+ bandwidth: { type: "number", min: 4, max: 64, step: 2, marks: [12, 24, 48], default: 24, describe: "The width of the kernel at the first step, in units of the board." },
679
+ decay: { type: "number", min: 0.3, max: 1, step: 0.05, marks: [0.7], default: 0.7, describe: "Each step multiplies the width of the kernel by this value." },
680
+ steps: { type: "integer", min: 0, max: 30, step: 1, marks: [10], default: 10, describe: "The number of steps." },
681
+ smoothing: { type: "number", min: 0, max: 1, step: 0.05, marks: [0.5], default: 0.5, describe: "The share of the smoothing of each polyline after each step." },
682
+ mask: { type: "boolean", default: true, describe: "With `true`, the density is 0 in the boxes, so no ridge forms over a box." },
683
+ snap: { type: "number", min: 0, max: 32, step: 2, marks: [8, 16], default: 8, describe: "The side of the grid that the points of the edges snap to, in units of the board." },
684
+ minSize: { type: "integer", min: 2, max: 16, step: 1, default: 2, describe: "A highway has this number of edges or more." },
685
+ };
686
+
687
+ /** The declarations of the options of the highway strategy `cubu` (HWY-007). */
688
+ export const CUBU_SCHEMA: OptionSchema<CubuOptions> = {
689
+ ...KDEEB_SCHEMA,
690
+ kernel: { type: "enum", values: ["separable", "fft"], default: "separable", describe: "The blur of the counts of the cells: a separable kernel (CUBu) or a Fourier transform (FFTEB)." },
691
+ resample: { type: "number", min: 0, max: 32, step: 2, marks: [0, 8], default: 8, describe: "The spacing of the sample points after each step, in units of the board. The value 0 keeps the points." },
692
+ };
693
+
694
+ /** The declarations of the options of the highway strategy `mlseb` (HWY-008). */
695
+ export const MLSEB_SCHEMA: OptionSchema<MlsebOptions> = {
696
+ margin: WAY_SCHEMA.margin,
697
+ k: WAY_SCHEMA.k,
698
+ source: { type: "enum", values: ["lines", "routes"], default: "lines", describe: "The first lines of the edges: their straight lines, or their first routes." },
699
+ radius: { type: "number", min: 0.25, max: 8, step: 0.25, marks: [1, 2, 4], default: 2, describe: "The radius of the fit at the first step, as a multiple of the median short side of the boxes." },
700
+ decay: { type: "number", min: 0.3, max: 1, step: 0.05, marks: [0.8], default: 0.8, describe: "Each step multiplies the radius by this value." },
701
+ steps: { type: "integer", min: 0, max: 20, step: 1, marks: [6], default: 6, describe: "The number of steps." },
702
+ fit: { type: "enum", values: ["line", "parabola"], default: "line", describe: "The local fit of the moving least squares: a line, or a parabola along the line." },
703
+ angleWeight: { type: "number", min: 0, max: 4, step: 0.25, marks: [0, 1], default: 1, describe: "The weight of the angle in the weight of a near point. The value 0 uses only the distance." },
704
+ spacing: { type: "number", min: 2, max: 32, step: 1, marks: [8, 16], default: 8, describe: "The distance between two sample points of a line, in units of the board." },
705
+ snap: { type: "number", min: 0, max: 32, step: 2, marks: [8, 16], default: 8, describe: "The side of the grid that the points of the edges snap to, in units of the board." },
706
+ minSize: { type: "integer", min: 2, max: 16, step: 1, default: 2, describe: "A highway has this number of edges or more." },
707
+ };
708
+
709
+ /** The declarations of the options of the highway strategy `sbeb` (HWY-009). */
710
+ export const SBEB_SCHEMA: OptionSchema<SbebOptions> = {
711
+ margin: WAY_SCHEMA.margin,
712
+ k: WAY_SCHEMA.k,
713
+ group: { type: "enum", values: ["quickbundles", "keys"], default: "quickbundles", describe: "The clusterer of the groups: `quickbundles`, or the key of each edge." },
714
+ source: { type: "enum", values: ["lines", "routes"], default: "lines", describe: "The lines of the edges that make the shape: their straight lines, or their first routes." },
715
+ radius: { type: "number", min: 0.25, max: 8, step: 0.25, marks: [1, 1.5, 3], default: 1.5, describe: "The radius of the shape of a group, as a multiple of the median short side of the boxes." },
716
+ attraction: { type: "number", min: 0, max: 1, step: 0.05, marks: [0.5], default: 0.5, describe: "The share of the move of each point to its target at each step." },
717
+ steps: { type: "integer", min: 0, max: 20, step: 1, marks: [4], default: 4, describe: "The number of steps." },
718
+ smoothing: { type: "number", min: 0, max: 1, step: 0.05, marks: [0.5], default: 0.5, describe: "The share of the smoothing of each polyline after each step." },
719
+ target: { type: "enum", values: ["skeleton", "mean"], default: "skeleton", describe: "The target of the points: the skeleton of the shape, or the mean line of the group." },
720
+ cell: { type: "number", min: 1, max: 16, step: 1, marks: [4, 8], default: 4, describe: "The side of a cell of the image of the shape, in units of the board." },
721
+ snap: { type: "number", min: 0, max: 32, step: 2, marks: [8, 16], default: 8, describe: "The side of the grid that the points of the edges snap to, in units of the board." },
722
+ minSize: { type: "integer", min: 2, max: 16, step: 1, default: 2, describe: "A highway has this number of edges or more." },
723
+ };
724
+
725
+ /** The declarations of the options of the highway strategy `areas` (HWY-010). */
726
+ export const AREA_SCHEMA: OptionSchema<AreaOptions> = {
727
+ margin: WAY_SCHEMA.margin,
728
+ k: WAY_SCHEMA.k,
729
+ group: SBEB_SCHEMA.group,
730
+ source: SBEB_SCHEMA.source,
731
+ radius: SBEB_SCHEMA.radius,
732
+ width: { type: "enum", values: ["spread", "count"], default: "spread", describe: "The half width of an area: the spread of the edges of the group, or the number of its lanes." },
733
+ laneWidth: { type: "number", min: 1, max: 12, step: 1, marks: [4], default: 4, describe: "The width of one lane for the rule `count`, in units of the board." },
734
+ cell: SBEB_SCHEMA.cell,
735
+ minSize: { type: "integer", min: 2, max: 16, step: 1, default: 2, describe: "A highway has this number of edges or more." },
736
+ };
737
+
738
+ /** The declaration of the limit of the legs of a trunk for the strategies `confluent` and `power`. */
739
+ const LEG_MAX: NumberOption = {
740
+ type: "number",
741
+ min: 0.1,
742
+ max: 1,
743
+ step: 0.05,
744
+ special: [Infinity],
745
+ marks: [0.3, 1, Infinity],
746
+ default: 1,
747
+ describe: "An edge rides the trunk only when each of its legs is this share of the trunk or shorter. `Infinity` sets no limit.",
748
+ };
749
+
750
+ /** The declaration of the edges that one group holds for the strategies `confluent` and `power`. */
751
+ const GROUP_SCOPE: EnumOption<GroupScope> = {
752
+ type: "enum",
753
+ values: ["collection", "all"],
754
+ default: "all",
755
+ describe: "The edges of one group: the edges of one collection, or each edge.",
756
+ };
757
+
758
+ /** The declarations of the options of the highway strategy `confluent` (HWY-013). */
759
+ export const CONFLUENT_SCHEMA: OptionSchema<ConfluentOptions> = {
760
+ margin: WAY_SCHEMA.margin,
761
+ k: WAY_SCHEMA.k,
762
+ minBiclique: { type: "integer", min: 2, max: 32, step: 1, marks: [4, 6, 9], default: 4, describe: "A biclique becomes a track when the product of the sizes of its two sets is this value or more." },
763
+ scope: GROUP_SCOPE,
764
+ spine: { ...GROUP_SPINE, default: "trunk" },
765
+ legMax: LEG_MAX,
766
+ };
767
+
768
+ /** The declarations of the options of the highway strategy `power` (HWY-014). */
769
+ export const POWER_SCHEMA: OptionSchema<PowerOptions> = {
770
+ margin: WAY_SCHEMA.margin,
771
+ k: WAY_SCHEMA.k,
772
+ modules: { type: "enum", values: ["exact", "near"], default: "exact", describe: "The rule of a module: the same neighbours, or near neighbours by the Jaccard index." },
773
+ jaccard: { type: "number", min: 0.3, max: 1, step: 0.05, marks: [0.6, 0.8], default: 0.8, describe: "With the rule `near`, a node joins a module at this Jaccard index or more." },
774
+ minSaved: { type: "integer", min: 1, max: 16, step: 1, marks: [1, 2, 4], default: 2, describe: "A power edge becomes a highway when it saves this number of edges or more." },
775
+ scope: GROUP_SCOPE,
776
+ spine: { ...GROUP_SPINE, default: "trunk" },
777
+ legMax: LEG_MAX,
778
+ };
779
+
780
+ /** The declarations of the options of the highway strategy `crossbars` (HWY-022). */
781
+ export const CROSSBAR_SCHEMA: OptionSchema<CrossbarOptions> = {
782
+ margin: WAY_SCHEMA.margin,
783
+ k: WAY_SCHEMA.k,
784
+ from: HIGHWAY_BASE,
785
+ tolerance: { type: "number", min: 0, max: 45, step: 1, marks: [5, 15, 30], default: 15, describe: "Two segments are parallel when the angle between them is this value or less, in degrees." },
786
+ minBar: { type: "integer", min: 1, max: 8, step: 1, marks: [2, 3], default: 2, describe: "Each side of a crossbar has this number of edges or more." },
787
+ reach: { type: "number", min: 0.5, max: 8, step: 0.5, marks: [2, 3, 4], default: 3, describe: "The crossings of one crossbar are this distance or nearer to its first crossing, as a multiple of the median short side of the boxes." },
788
+ };
789
+
790
+ /** The declarations of the options of the highway strategy `frechet` (HWY-027). */
791
+ export const FRECHET_SCHEMA: OptionSchema<FrechetOptions> = {
792
+ margin: WAY_SCHEMA.margin,
793
+ k: WAY_SCHEMA.k,
794
+ eps: { type: "number", min: 0.1, max: 4, step: 0.1, marks: [0.5, 1, 2], default: 1, describe: "The largest discrete Fréchet distance in a bundle, as a multiple of the median short side of the boxes." },
795
+ minSize: { type: "integer", min: 2, max: 16, step: 1, default: 2, describe: "A bundle has this number of edges or more." },
796
+ minLength: { type: "number", min: 0.5, max: 16, step: 0.5, marks: [2, 4], default: 2, describe: "The reference part of a bundle is this length or longer, as a multiple of the median short side of the boxes." },
797
+ step: { type: "number", min: 0.1, max: 2, step: 0.1, marks: [0.5], default: 0.5, describe: "The distance between two samples of a route, as a multiple of the median short side of the boxes." },
798
+ stride: { type: "integer", min: 1, max: 8, step: 1, marks: [1, 2, 4], default: 2, describe: "A search starts at each sample of this number along each route." },
799
+ };
800
+
801
+ /** The declarations of the options of the highway strategy `spectral` (HWY-029). */
802
+ export const SPECTRAL_SCHEMA: OptionSchema<SpectralOptions> = {
803
+ c0: { type: "number", min: 0.05, max: 0.95, step: 0.05, marks: [0.3, 0.5, 0.7], default: 0.5, describe: "Two edges are a pair of the graph only when their compatibility is this value or more." },
804
+ clusters: { type: "integer", min: 0, max: 32, step: 1, default: 0, describe: "The number of clusters of each part of the graph. The value 0 lets the largest eigengap choose it." },
805
+ kMax: { type: "integer", min: 2, max: 32, step: 1, marks: [8, 16], default: 16, describe: "The eigengap chooses at most this number of clusters in each part of the graph." },
806
+ minSize: { type: "integer", min: 2, max: 16, step: 1, default: 2, describe: "A cluster with this number of edges or more gets highways." },
807
+ spine: { ...GROUP_SPINE, default: "trunk" },
808
+ };
809
+
810
+ /** The declarations of the options of the highway strategy `resistance` (HWY-021). */
811
+ export const RESISTANCE_SCHEMA: OptionSchema<ResistanceOptions> = {
812
+ ...SPECTRAL_SCHEMA,
813
+ projections: { type: "integer", min: 1, max: 64, step: 1, marks: [8, 16, 32], default: 16, describe: "The number of random projections of the estimate of the resistance." },
814
+ weight: { type: "number", min: 0, max: 1, step: 0.05, marks: [0.5, 1], default: 0.5, describe: "The weight of the resistance. A pair gets the weight `C (1 - weight R_e R_f)`." },
815
+ sparsify: { type: "boolean", default: false, describe: "With `true`, an edge with a resistance of 0.99 or more (a bridge) gets no pair." },
816
+ };
817
+
818
+ /** The declarations of the options of the highway strategy `link-communities` (HWY-030). */
819
+ export const LINK_COMMUNITY_SCHEMA: OptionSchema<LinkCommunityOptions> = {
820
+ threshold: { type: "number", min: 0, max: 1, step: 0.05, marks: [0, 0.3, 0.5], default: 0, describe: "The cut of the tree of the edges. The value 0 cuts at the best partition density." },
821
+ minSize: { type: "integer", min: 2, max: 16, step: 1, default: 2, describe: "A community with this number of edges or more gets highways, after the check of the geometry." },
822
+ spread: { type: "number", min: 1, max: 20, step: 1, marks: [3, 6, 12], default: 6, describe: "The largest distance of an end of an edge to the Weber point of its end of the community, in units of the board." },
823
+ spine: GROUP_SPINE,
824
+ };
825
+
826
+ /** The declarations of the options of the highway strategy `territories` (HWY-033). */
827
+ export const TERRITORY_SCHEMA: OptionSchema<TerritoryOptions> = {
828
+ radius: { type: "number", min: 1, max: 20, step: 0.5, marks: [2, 4, 8], default: 4, describe: "The radius of a group of points, in units of the board." },
829
+ minSize: { type: "integer", min: 2, max: 16, step: 1, default: 2, describe: "A flow between two cells becomes a highway when this number of edges or more cross it." },
830
+ points: { type: "enum", values: ["plugs", "bends", "both"], default: "both", describe: "The characteristic points: the plugs, the bends of the first routes, or both." },
831
+ };
832
+
833
+ /** The declarations of the options of the highway strategy `consensus` (HWY-035). */
834
+ export const CONSENSUS_SCHEMA: OptionSchema<ConsensusOptions> = {
835
+ members: { type: "list", default: ["corridors", "quickbundles", "wspd", "road-classes"], describe: "The finders that vote." },
836
+ cut: { type: "number", min: 0.1, max: 0.9, step: 0.05, marks: [0.3, 0.5, 0.7], default: 0.5, describe: "Two clusters join while their distance `1 - A` is below this value." },
837
+ linkage: { type: "enum", values: ["average", "single"], default: "average", describe: "The linkage of the clusters: the mean distance of the pairs, or the nearest pair." },
838
+ minSize: { type: "integer", min: 2, max: 16, step: 1, default: 2, describe: "A cluster with this number of edges or more gets highways." },
839
+ spine: GROUP_SPINE,
840
+ };
841
+
842
+ /** The declarations of the options of the highway strategy `p-hub` (HWY-041). */
843
+ export const P_HUB_SCHEMA: OptionSchema<PHubOptions> = {
844
+ p: { type: "integer", min: 0, max: 32, step: 1, marks: [0, 4, 8], default: 0, describe: "The number of hubs. The value 0 gives the root of the number of nodes, rounded." },
845
+ alpha: { type: "number", min: 0, max: 1, step: 0.05, marks: [0.2, 0.5, 0.8], default: 0.5, describe: "The cost of a length on a link between two hubs against a length off the links." },
846
+ allocation: { type: "enum", values: ["single", "multiple"], default: "single", describe: "The allocation: each node to its nearest hub, or each edge to its best pair of hubs." },
847
+ candidates: { type: "enum", values: ["corners", "sections"], default: "corners", describe: "The candidate points of the hubs: the corners of the corner graph, or the centres of the sections." },
848
+ detour: { type: "number", min: 1, max: 3, step: 0.05, marks: [1.25, 1.5], default: 1.25, describe: "An edge rides a link only when its way through the two hubs is this many times its first route or less." },
849
+ swaps: { type: "integer", min: 0, max: 4, step: 1, default: 1, describe: "The number of passes of the local search with one swap of a hub." },
850
+ minSize: { type: "integer", min: 2, max: 16, step: 1, default: 2, describe: "A link with fewer edges than this number is not a highway." },
851
+ };
852
+
853
+ /** The declarations of the options of the highway strategy `scale-space` (HWY-053). */
854
+ export const SCALE_SPACE_SCHEMA: OptionSchema<ScaleSpaceOptions> = {
855
+ theta: { type: "number", min: 0.5, max: 6, step: 0.5, marks: [1.5, 3], default: 1.5, describe: "The first scale, in units of the board." },
856
+ ratio: { type: "number", min: 1.1, max: 3, step: 0.1, marks: [1.5, 2], default: Math.SQRT2, describe: "The scale of each next scale is this value times the scale before it." },
857
+ scales: { type: "integer", min: 2, max: 16, step: 1, marks: [4, 8], default: 8, describe: "The number of scales." },
858
+ level: { type: "integer", min: 0, max: 15, step: 1, marks: [2, 4, 6], default: 2, describe: "The scale of the plan, from 0 (the first scale)." },
859
+ p0: { type: "number", min: 0, max: 3, step: 0.1, marks: [0.3, 0.6, 1.2], default: 0.6, describe: "A cluster gets highways only when its persistence (the log of the ratio of its last scale to its first scale) is this value or more." },
860
+ points: { type: "integer", min: 6, max: 24, step: 2, default: 12, describe: "The number of points of each line after the resampling." },
861
+ line: { type: "enum", values: ["routes", "lines"], default: "routes", describe: "The line of each edge: its first route, or the straight line between its plugs." },
862
+ minSize: { type: "integer", min: 2, max: 16, step: 1, default: 2, describe: "A cluster with this number of edges or more gets highways." },
863
+ spine: GROUP_SPINE,
864
+ };