@woosh/meep-engine 2.138.19 → 2.139.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/package.json +2 -1
- package/src/core/collection/PairUint32Map.d.ts +100 -0
- package/src/core/collection/PairUint32Map.d.ts.map +1 -0
- package/src/core/collection/PairUint32Map.js +321 -0
- package/src/core/collection/Uint32Map.d.ts +119 -0
- package/src/core/collection/Uint32Map.d.ts.map +1 -0
- package/src/core/collection/Uint32Map.js +345 -0
- package/src/core/collection/array/array_shuffle.d.ts +10 -3
- package/src/core/collection/array/array_shuffle.d.ts.map +1 -1
- package/src/core/collection/array/array_shuffle.js +27 -22
- package/src/core/collection/heap/FibonacciHeap.d.ts +195 -0
- package/src/core/collection/heap/FibonacciHeap.d.ts.map +1 -0
- package/src/core/collection/heap/FibonacciHeap.js +586 -0
- package/src/core/collection/heap/Uint32Heap.js +1 -1
- package/src/core/collection/heap/Uint32Heap4.d.ts +169 -0
- package/src/core/collection/heap/Uint32Heap4.d.ts.map +1 -0
- package/src/core/collection/heap/Uint32Heap4.js +490 -0
- package/src/core/geom/3d/line/line3_closest_points_segment_segment.d.ts +27 -0
- package/src/core/geom/3d/line/line3_closest_points_segment_segment.d.ts.map +1 -0
- package/src/core/geom/3d/line/line3_closest_points_segment_segment.js +88 -0
- package/src/core/geom/3d/shape/BoxShape3D.d.ts +61 -0
- package/src/core/geom/3d/shape/BoxShape3D.d.ts.map +1 -0
- package/src/core/geom/3d/shape/BoxShape3D.js +158 -0
- package/src/core/geom/3d/shape/CapsuleShape3D.d.ts +11 -0
- package/src/core/geom/3d/shape/CapsuleShape3D.d.ts.map +1 -1
- package/src/core/geom/3d/shape/CapsuleShape3D.js +12 -0
- package/src/core/geom/3d/shape/UnitCubeShape3D.d.ts +37 -9
- package/src/core/geom/3d/shape/UnitCubeShape3D.d.ts.map +1 -1
- package/src/core/geom/3d/shape/UnitCubeShape3D.js +45 -98
- package/src/core/geom/3d/shape/UnitSphereShape3D.d.ts +10 -0
- package/src/core/geom/3d/shape/UnitSphereShape3D.d.ts.map +1 -1
- package/src/core/geom/3d/shape/UnitSphereShape3D.js +11 -0
- package/src/core/geom/3d/shape/util/shape3d_voxelize_to_grid.d.ts +61 -0
- package/src/core/geom/3d/shape/util/shape3d_voxelize_to_grid.d.ts.map +1 -0
- package/src/core/geom/3d/shape/util/shape3d_voxelize_to_grid.js +148 -0
- package/src/core/geom/3d/tetrahedra/compute_tetrahedral_mesh_from_surface.d.ts +39 -0
- package/src/core/geom/3d/tetrahedra/compute_tetrahedral_mesh_from_surface.d.ts.map +1 -0
- package/src/core/geom/3d/tetrahedra/compute_tetrahedral_mesh_from_surface.js +147 -0
- package/src/core/geom/3d/tetrahedra/compute_tetrahedron_quality.d.ts +15 -0
- package/src/core/geom/3d/tetrahedra/compute_tetrahedron_quality.d.ts.map +1 -0
- package/src/core/geom/3d/tetrahedra/compute_tetrahedron_quality.js +22 -0
- package/src/core/geom/3d/tetrahedra/prototype_tetrahedrize_mesh.d.ts +2 -0
- package/src/core/geom/3d/tetrahedra/prototype_tetrahedrize_mesh.d.ts.map +1 -0
- package/src/core/geom/3d/tetrahedra/prototype_tetrahedrize_mesh.js +673 -0
- package/src/core/geom/3d/tetrahedra/tetrahedral_mesh_carve_outside_surface.d.ts +26 -0
- package/src/core/geom/3d/tetrahedra/tetrahedral_mesh_carve_outside_surface.d.ts.map +1 -0
- package/src/core/geom/3d/tetrahedra/tetrahedral_mesh_carve_outside_surface.js +222 -0
- package/src/core/geom/3d/tetrahedra/tetrahedral_mesh_find_tets_around_edge.d.ts +34 -0
- package/src/core/geom/3d/tetrahedra/tetrahedral_mesh_find_tets_around_edge.d.ts.map +1 -0
- package/src/core/geom/3d/tetrahedra/tetrahedral_mesh_find_tets_around_edge.js +146 -0
- package/src/core/geom/3d/tetrahedra/tetrahedral_mesh_flip_23.d.ts +36 -0
- package/src/core/geom/3d/tetrahedra/tetrahedral_mesh_flip_23.d.ts.map +1 -0
- package/src/core/geom/3d/tetrahedra/tetrahedral_mesh_flip_23.js +232 -0
- package/src/core/geom/3d/tetrahedra/tetrahedral_mesh_flip_32.d.ts +33 -0
- package/src/core/geom/3d/tetrahedra/tetrahedral_mesh_flip_32.d.ts.map +1 -0
- package/src/core/geom/3d/tetrahedra/tetrahedral_mesh_flip_32.js +255 -0
- package/src/core/geom/3d/tetrahedra/tetrahedral_mesh_improve_quality.d.ts +68 -0
- package/src/core/geom/3d/tetrahedra/tetrahedral_mesh_improve_quality.d.ts.map +1 -0
- package/src/core/geom/3d/tetrahedra/tetrahedral_mesh_improve_quality.js +365 -0
- package/src/core/geom/3d/tetrahedra/tetrahedral_mesh_smooth_vertex.d.ts +31 -0
- package/src/core/geom/3d/tetrahedra/tetrahedral_mesh_smooth_vertex.d.ts.map +1 -0
- package/src/core/geom/3d/tetrahedra/tetrahedral_mesh_smooth_vertex.js +112 -0
- package/src/core/geom/3d/tetrahedra/tetrahedral_mesh_vertex_is_boundary.d.ts +22 -0
- package/src/core/geom/3d/tetrahedra/tetrahedral_mesh_vertex_is_boundary.d.ts.map +1 -0
- package/src/core/geom/3d/tetrahedra/tetrahedral_mesh_vertex_is_boundary.js +55 -0
- package/src/core/geom/3d/tetrahedra/tetrahedron_compute_quality.d.ts +32 -0
- package/src/core/geom/3d/tetrahedra/tetrahedron_compute_quality.d.ts.map +1 -0
- package/src/core/geom/3d/tetrahedra/tetrahedron_compute_quality.js +66 -0
- package/src/core/geom/3d/topology/struct/binary/BinaryElementPool.d.ts +22 -0
- package/src/core/geom/3d/topology/struct/binary/BinaryElementPool.d.ts.map +1 -1
- package/src/core/geom/3d/topology/struct/binary/BinaryElementPool.js +49 -0
- package/src/core/geom/3d/topology/struct/binary/BinaryTopology.d.ts +134 -0
- package/src/core/geom/3d/topology/struct/binary/BinaryTopology.d.ts.map +1 -1
- package/src/core/geom/3d/topology/struct/binary/BinaryTopology.js +276 -3
- package/src/core/geom/3d/topology/struct/binary/io/bt_mesh_close_boundary_holes.d.ts +17 -0
- package/src/core/geom/3d/topology/struct/binary/io/bt_mesh_close_boundary_holes.d.ts.map +1 -0
- package/src/core/geom/3d/topology/struct/binary/io/bt_mesh_close_boundary_holes.js +135 -0
- package/src/core/geom/3d/topology/struct/binary/io/bt_mesh_compact.d.ts +14 -0
- package/src/core/geom/3d/topology/struct/binary/io/bt_mesh_compact.d.ts.map +1 -0
- package/src/core/geom/3d/topology/struct/binary/io/bt_mesh_compact.js +177 -0
- package/src/core/geom/3d/topology/struct/binary/io/bt_mesh_face_decouple.d.ts.map +1 -1
- package/src/core/geom/3d/topology/struct/binary/io/bt_mesh_face_decouple.js +20 -4
- package/src/core/geom/3d/topology/struct/binary/io/bt_mesh_simplify.d.ts.map +1 -1
- package/src/core/geom/3d/topology/struct/binary/io/bt_mesh_simplify.js +5 -3
- package/src/core/geom/3d/topology/struct/binary/io/edge/bt_edge_create.d.ts.map +1 -1
- package/src/core/geom/3d/topology/struct/binary/io/edge/bt_edge_create.js +9 -0
- package/src/core/geom/3d/topology/struct/binary/io/edge/bt_edge_get_or_create.d.ts.map +1 -1
- package/src/core/geom/3d/topology/struct/binary/io/edge/bt_edge_get_or_create.js +21 -45
- package/src/core/geom/3d/topology/struct/binary/io/edge/bt_edge_kill.d.ts.map +1 -1
- package/src/core/geom/3d/topology/struct/binary/io/edge/bt_edge_kill.js +7 -1
- package/src/core/geom/3d/topology/struct/binary/io/edge/bt_edge_kill_parallels.d.ts +8 -6
- package/src/core/geom/3d/topology/struct/binary/io/edge/bt_edge_kill_parallels.d.ts.map +1 -1
- package/src/core/geom/3d/topology/struct/binary/io/edge/bt_edge_kill_parallels.js +8 -6
- package/src/core/geom/3d/topology/struct/binary/io/edge/bt_mesh_kill_short_edges.d.ts +22 -0
- package/src/core/geom/3d/topology/struct/binary/io/edge/bt_mesh_kill_short_edges.d.ts.map +1 -0
- package/src/core/geom/3d/topology/struct/binary/io/edge/bt_mesh_kill_short_edges.js +73 -0
- package/src/core/geom/3d/topology/struct/binary/io/vertex/bt_vertex_replace.d.ts.map +1 -1
- package/src/core/geom/3d/topology/struct/binary/io/vertex/bt_vertex_replace.js +51 -1
- package/src/core/geom/3d/topology/struct/binary/query/bt_edge_get.d.ts +10 -0
- package/src/core/geom/3d/topology/struct/binary/query/bt_edge_get.d.ts.map +1 -0
- package/src/core/geom/3d/topology/struct/binary/query/bt_edge_get.js +42 -0
- package/src/core/geom/3d/topology/struct/binary/query/bt_mesh_sample_interior_grid_points.d.ts +28 -0
- package/src/core/geom/3d/topology/struct/binary/query/bt_mesh_sample_interior_grid_points.d.ts.map +1 -0
- package/src/core/geom/3d/topology/struct/binary/query/bt_mesh_sample_interior_grid_points.js +227 -0
- package/src/core/geom/3d/topology/struct/binary/query/bt_mesh_walk_boundary_loops.d.ts +13 -0
- package/src/core/geom/3d/topology/struct/binary/query/bt_mesh_walk_boundary_loops.d.ts.map +1 -0
- package/src/core/geom/3d/topology/struct/binary/query/bt_mesh_walk_boundary_loops.js +108 -0
- package/src/core/geom/3d/topology/struct/binary/query/bt_query_edge_is_boundary.d.ts +11 -0
- package/src/core/geom/3d/topology/struct/binary/query/bt_query_edge_is_boundary.d.ts.map +1 -0
- package/src/core/geom/3d/topology/struct/binary/query/bt_query_edge_is_boundary.js +20 -0
- package/src/core/geom/3d/triangle/triangle_mesh_compute_signed_volume.d.ts +20 -0
- package/src/core/geom/3d/triangle/triangle_mesh_compute_signed_volume.d.ts.map +1 -0
- package/src/core/geom/3d/triangle/triangle_mesh_compute_signed_volume.js +38 -0
- package/src/core/graph/csr/CSRGraph.d.ts +168 -0
- package/src/core/graph/csr/CSRGraph.d.ts.map +1 -0
- package/src/core/graph/csr/CSRGraph.js +319 -0
- package/src/core/graph/metis/cluster_mesh_metis.d.ts +12 -0
- package/src/core/graph/metis/cluster_mesh_metis.d.ts.map +1 -1
- package/src/core/graph/metis/cluster_mesh_metis.js +12 -0
- package/src/core/graph/metis/metis.d.ts +19 -0
- package/src/core/graph/metis/metis.d.ts.map +1 -1
- package/src/core/graph/metis/metis.js +20 -0
- package/src/core/graph/metis/metis_cluster_bs.d.ts +11 -0
- package/src/core/graph/metis/metis_cluster_bs.d.ts.map +1 -1
- package/src/core/graph/metis/metis_cluster_bs.js +11 -0
- package/src/core/graph/metis/metis_options.d.ts +17 -2
- package/src/core/graph/metis/metis_options.d.ts.map +1 -1
- package/src/core/graph/metis/metis_options.js +17 -2
- package/src/core/graph/metis/native/MetisGraph.d.ts +144 -0
- package/src/core/graph/metis/native/MetisGraph.d.ts.map +1 -0
- package/src/core/graph/metis/native/MetisGraph.js +212 -0
- package/src/core/graph/metis/native/bisection/BisectionScratch.d.ts +72 -0
- package/src/core/graph/metis/native/bisection/BisectionScratch.d.ts.map +1 -0
- package/src/core/graph/metis/native/bisection/BisectionScratch.js +101 -0
- package/src/core/graph/metis/native/bisection/bisect_graph.d.ts +37 -0
- package/src/core/graph/metis/native/bisection/bisect_graph.d.ts.map +1 -0
- package/src/core/graph/metis/native/bisection/bisect_graph.js +100 -0
- package/src/core/graph/metis/native/bisection/compute_2way_params.d.ts +15 -0
- package/src/core/graph/metis/native/bisection/compute_2way_params.d.ts.map +1 -0
- package/src/core/graph/metis/native/bisection/compute_2way_params.js +84 -0
- package/src/core/graph/metis/native/bisection/fm_2way.d.ts +30 -0
- package/src/core/graph/metis/native/bisection/fm_2way.d.ts.map +1 -0
- package/src/core/graph/metis/native/bisection/fm_2way.js +290 -0
- package/src/core/graph/metis/native/bisection/grow_bisection.d.ts +23 -0
- package/src/core/graph/metis/native/bisection/grow_bisection.d.ts.map +1 -0
- package/src/core/graph/metis/native/bisection/grow_bisection.js +137 -0
- package/src/core/graph/metis/native/bisection/split_graph_two_way.d.ts +28 -0
- package/src/core/graph/metis/native/bisection/split_graph_two_way.d.ts.map +1 -0
- package/src/core/graph/metis/native/bisection/split_graph_two_way.js +119 -0
- package/src/core/graph/metis/native/coarsen/coarsen_graph.d.ts +20 -0
- package/src/core/graph/metis/native/coarsen/coarsen_graph.d.ts.map +1 -0
- package/src/core/graph/metis/native/coarsen/coarsen_graph.js +94 -0
- package/src/core/graph/metis/native/coarsen/create_coarse_graph.d.ts +24 -0
- package/src/core/graph/metis/native/coarsen/create_coarse_graph.d.ts.map +1 -0
- package/src/core/graph/metis/native/coarsen/create_coarse_graph.js +158 -0
- package/src/core/graph/metis/native/coarsen/match_shem.d.ts +41 -0
- package/src/core/graph/metis/native/coarsen/match_shem.d.ts.map +1 -0
- package/src/core/graph/metis/native/coarsen/match_shem.js +175 -0
- package/src/core/graph/metis/native/initial/initial_kway_bfs.d.ts +24 -0
- package/src/core/graph/metis/native/initial/initial_kway_bfs.d.ts.map +1 -0
- package/src/core/graph/metis/native/initial/initial_kway_bfs.js +122 -0
- package/src/core/graph/metis/native/initial/initial_kway_recursive_bisection.d.ts +29 -0
- package/src/core/graph/metis/native/initial/initial_kway_recursive_bisection.d.ts.map +1 -0
- package/src/core/graph/metis/native/initial/initial_kway_recursive_bisection.js +170 -0
- package/src/core/graph/metis/native/metis_partition_kway.d.ts +41 -0
- package/src/core/graph/metis/native/metis_partition_kway.d.ts.map +1 -0
- package/src/core/graph/metis/native/metis_partition_kway.js +126 -0
- package/src/core/graph/metis/native/refine/IndexedFloatMaxHeap.d.ts +62 -0
- package/src/core/graph/metis/native/refine/IndexedFloatMaxHeap.d.ts.map +1 -0
- package/src/core/graph/metis/native/refine/IndexedFloatMaxHeap.js +261 -0
- package/src/core/graph/metis/native/refine/RefinementScratch.d.ts +45 -0
- package/src/core/graph/metis/native/refine/RefinementScratch.d.ts.map +1 -0
- package/src/core/graph/metis/native/refine/RefinementScratch.js +53 -0
- package/src/core/graph/metis/native/refine/compute_kway_params.d.ts +18 -0
- package/src/core/graph/metis/native/refine/compute_kway_params.d.ts.map +1 -0
- package/src/core/graph/metis/native/refine/compute_kway_params.js +138 -0
- package/src/core/graph/metis/native/refine/fm_kway.d.ts +63 -0
- package/src/core/graph/metis/native/refine/fm_kway.d.ts.map +1 -0
- package/src/core/graph/metis/native/refine/fm_kway.js +462 -0
- package/src/core/graph/metis/native/refine/project_kway.d.ts +22 -0
- package/src/core/graph/metis/native/refine/project_kway.d.ts.map +1 -0
- package/src/core/graph/metis/native/refine/project_kway.js +43 -0
- package/src/core/graph/metis/native/refine/refine_kway.d.ts +34 -0
- package/src/core/graph/metis/native/refine/refine_kway.d.ts.map +1 -0
- package/src/core/graph/metis/native/refine/refine_kway.js +43 -0
- package/src/core/math/linalg/eigen/matrix_householder_in_place.d.ts +2 -2
- package/src/core/math/linalg/eigen/matrix_householder_in_place.js +2 -2
- package/src/core/math/linalg/eigen/matrix_qr_in_place.d.ts +6 -4
- package/src/core/math/linalg/eigen/matrix_qr_in_place.d.ts.map +1 -1
- package/src/core/math/linalg/eigen/matrix_qr_in_place.js +69 -23
- package/src/engine/EngineHarness.d.ts +3 -1
- package/src/engine/EngineHarness.d.ts.map +1 -1
- package/src/engine/EngineHarness.js +6 -4
- package/src/engine/control/first-person/DESIGN.md +30 -6
- package/src/engine/control/first-person/DESIGN_EXTENSIONS.md +563 -0
- package/src/engine/control/first-person/FirstPersonPlayerController.d.ts +102 -9
- package/src/engine/control/first-person/FirstPersonPlayerController.d.ts.map +1 -1
- package/src/engine/control/first-person/FirstPersonPlayerController.js +38 -3
- package/src/engine/control/first-person/FirstPersonPlayerControllerConfig.d.ts +533 -4
- package/src/engine/control/first-person/FirstPersonPlayerControllerConfig.d.ts.map +1 -1
- package/src/engine/control/first-person/FirstPersonPlayerControllerConfig.js +315 -6
- package/src/engine/control/first-person/FirstPersonPlayerControllerSystem.d.ts +220 -22
- package/src/engine/control/first-person/FirstPersonPlayerControllerSystem.d.ts.map +1 -1
- package/src/engine/control/first-person/FirstPersonPlayerControllerSystem.js +858 -241
- package/src/engine/control/first-person/TODO.md +127 -0
- package/src/engine/control/first-person/abilities/Ability.d.ts +101 -0
- package/src/engine/control/first-person/abilities/Ability.d.ts.map +1 -0
- package/src/engine/control/first-person/abilities/Ability.js +119 -0
- package/src/engine/control/first-person/abilities/AbilitySet.d.ts +86 -0
- package/src/engine/control/first-person/abilities/AbilitySet.d.ts.map +1 -0
- package/src/engine/control/first-person/abilities/AbilitySet.js +185 -0
- package/src/engine/control/first-person/abilities/LedgeGrab.d.ts +62 -0
- package/src/engine/control/first-person/abilities/LedgeGrab.d.ts.map +1 -0
- package/src/engine/control/first-person/abilities/LedgeGrab.js +199 -0
- package/src/engine/control/first-person/abilities/Mantle.d.ts +45 -0
- package/src/engine/control/first-person/abilities/Mantle.d.ts.map +1 -0
- package/src/engine/control/first-person/abilities/Mantle.js +188 -0
- package/src/engine/control/first-person/abilities/Slide.d.ts +33 -0
- package/src/engine/control/first-person/abilities/Slide.d.ts.map +1 -0
- package/src/engine/control/first-person/abilities/Slide.js +158 -0
- package/src/engine/control/first-person/abilities/WallJump.d.ts +45 -0
- package/src/engine/control/first-person/abilities/WallJump.d.ts.map +1 -0
- package/src/engine/control/first-person/abilities/WallJump.js +131 -0
- package/src/engine/control/first-person/abilities/WallRun.d.ts +44 -0
- package/src/engine/control/first-person/abilities/WallRun.d.ts.map +1 -0
- package/src/engine/control/first-person/abilities/WallRun.js +180 -0
- package/src/engine/control/first-person/composer/EyeOffsetStack.d.ts +49 -0
- package/src/engine/control/first-person/composer/EyeOffsetStack.d.ts.map +1 -0
- package/src/engine/control/first-person/composer/EyeOffsetStack.js +60 -0
- package/src/engine/control/first-person/mastery/BreathRhythmEvaluator.d.ts +100 -0
- package/src/engine/control/first-person/mastery/BreathRhythmEvaluator.d.ts.map +1 -0
- package/src/engine/control/first-person/mastery/BreathRhythmEvaluator.js +133 -0
- package/src/engine/control/first-person/mastery/DecisionPoint.d.ts +10 -0
- package/src/engine/control/first-person/mastery/DecisionPoint.d.ts.map +1 -0
- package/src/engine/control/first-person/mastery/DecisionPoint.js +30 -0
- package/src/engine/control/first-person/mastery/FootAsymmetryTurnEvaluator.d.ts +61 -0
- package/src/engine/control/first-person/mastery/FootAsymmetryTurnEvaluator.d.ts.map +1 -0
- package/src/engine/control/first-person/mastery/FootAsymmetryTurnEvaluator.js +109 -0
- package/src/engine/control/first-person/mastery/MasteryEvaluator.d.ts +40 -0
- package/src/engine/control/first-person/mastery/MasteryEvaluator.d.ts.map +1 -0
- package/src/engine/control/first-person/mastery/MasteryEvaluator.js +45 -0
- package/src/engine/control/first-person/mastery/MasteryScore.d.ts +68 -0
- package/src/engine/control/first-person/mastery/MasteryScore.d.ts.map +1 -0
- package/src/engine/control/first-person/mastery/MasteryScore.js +100 -0
- package/src/engine/control/first-person/mastery/MasterySet.d.ts +60 -0
- package/src/engine/control/first-person/mastery/MasterySet.d.ts.map +1 -0
- package/src/engine/control/first-person/mastery/MasterySet.js +86 -0
- package/src/engine/control/first-person/mastery/SlideInitiationTimingEvaluator.d.ts +58 -0
- package/src/engine/control/first-person/mastery/SlideInitiationTimingEvaluator.d.ts.map +1 -0
- package/src/engine/control/first-person/mastery/SlideInitiationTimingEvaluator.js +83 -0
- package/src/engine/control/first-person/mastery/StrideTimingJumpEvaluator.d.ts +69 -0
- package/src/engine/control/first-person/mastery/StrideTimingJumpEvaluator.d.ts.map +1 -0
- package/src/engine/control/first-person/mastery/StrideTimingJumpEvaluator.js +109 -0
- package/src/engine/control/first-person/math/Spring.d.ts +56 -0
- package/src/engine/control/first-person/math/Spring.d.ts.map +1 -0
- package/src/engine/control/first-person/math/Spring.js +71 -0
- package/src/engine/control/first-person/math/computeLRCBreathRate.d.ts +26 -0
- package/src/engine/control/first-person/math/computeLRCBreathRate.d.ts.map +1 -0
- package/src/engine/control/first-person/math/computeLRCBreathRate.js +41 -0
- package/src/engine/control/first-person/math/computeMassRatios.d.ts +35 -0
- package/src/engine/control/first-person/math/computeMassRatios.d.ts.map +1 -0
- package/src/engine/control/first-person/math/computeMassRatios.js +44 -0
- package/src/engine/control/first-person/pose/FirstPersonPose.d.ts +31 -1
- package/src/engine/control/first-person/pose/FirstPersonPose.d.ts.map +1 -1
- package/src/engine/control/first-person/pose/FirstPersonPose.js +49 -3
- package/src/engine/control/first-person/pose/FirstPersonPosture.d.ts +7 -0
- package/src/engine/control/first-person/pose/FirstPersonPosture.d.ts.map +1 -0
- package/src/engine/control/first-person/pose/FirstPersonPosture.js +27 -0
- package/src/engine/control/first-person/prototype_first_person_controller.js +550 -119
- package/src/engine/control/first-person/sensors/FirstPersonSensors.d.ts +58 -0
- package/src/engine/control/first-person/sensors/FirstPersonSensors.d.ts.map +1 -0
- package/src/engine/control/first-person/sensors/FirstPersonSensors.js +77 -0
- package/src/engine/control/first-person/sensors/FirstPersonSensorsSystem.d.ts +80 -0
- package/src/engine/control/first-person/sensors/FirstPersonSensorsSystem.d.ts.map +1 -0
- package/src/engine/control/first-person/sensors/FirstPersonSensorsSystem.js +196 -0
- package/src/engine/control/first-person/test/buildTestPlayer.d.ts +20 -0
- package/src/engine/control/first-person/test/buildTestPlayer.d.ts.map +1 -0
- package/src/engine/control/first-person/test/buildTestPlayer.js +28 -0
- package/src/engine/ecs/EntityManager.d.ts +2 -2
- package/src/engine/ecs/EntityManager.d.ts.map +1 -1
- package/src/engine/ecs/EntityManager.js +13 -8
- package/src/engine/ecs/System.d.ts.map +1 -1
- package/src/engine/ecs/System.js +2 -2
- package/src/engine/graphics/camera/testClippingPlaneComputation.js +0 -2
- package/src/engine/graphics/ecs/light/Light.d.ts.map +1 -1
- package/src/engine/graphics/ecs/light/Light.js +27 -0
- package/src/engine/graphics/ecs/light/LightSystem.js +1 -1
- package/src/engine/graphics/ecs/path/PathDisplaySystem.d.ts.map +1 -1
- package/src/engine/graphics/ecs/path/testPathDisplaySystem.js +0 -2
- package/src/engine/graphics/ecs/path/tube/prototypeAnimatedPathMask.js +0 -2
- package/src/engine/graphics/render/buffer/buffers/prototypeNormalFrameBuffer.js +0 -2
- package/src/engine/graphics/render/forward_plus/plugin/ptototypeFPPlugin.js +0 -2
- package/src/engine/graphics/render/visibility/hiz/prototypeHiZ.js +0 -2
- package/src/engine/navigation/grid/find_path_on_grid_astar.d.ts.map +1 -1
- package/src/engine/navigation/grid/find_path_on_grid_astar.js +11 -2
- package/src/engine/navigation/mesh/bt_mesh_face_find_path.d.ts.map +1 -1
- package/src/engine/navigation/mesh/bt_mesh_face_find_path.js +11 -1
- package/src/engine/physics/PLAN.md +236 -0
- package/src/engine/physics/body/BodyStorage.d.ts +187 -0
- package/src/engine/physics/body/BodyStorage.d.ts.map +1 -0
- package/src/engine/physics/body/BodyStorage.js +427 -0
- package/src/engine/physics/broadphase/PairList.d.ts +62 -0
- package/src/engine/physics/broadphase/PairList.d.ts.map +1 -0
- package/src/engine/physics/broadphase/PairList.js +97 -0
- package/src/engine/physics/broadphase/aabb_transform_oriented.d.ts +30 -0
- package/src/engine/physics/broadphase/aabb_transform_oriented.d.ts.map +1 -0
- package/src/engine/physics/broadphase/aabb_transform_oriented.js +93 -0
- package/src/engine/physics/broadphase/compute_fat_world_aabb.d.ts +16 -0
- package/src/engine/physics/broadphase/compute_fat_world_aabb.d.ts.map +1 -0
- package/src/engine/physics/broadphase/compute_fat_world_aabb.js +61 -0
- package/src/engine/physics/broadphase/generate_pairs.d.ts +38 -0
- package/src/engine/physics/broadphase/generate_pairs.d.ts.map +1 -0
- package/src/engine/physics/broadphase/generate_pairs.js +101 -0
- package/src/engine/physics/contact/ManifoldStore.d.ts +226 -0
- package/src/engine/physics/contact/ManifoldStore.d.ts.map +1 -0
- package/src/engine/physics/contact/ManifoldStore.js +499 -0
- package/src/engine/physics/ecs/BodyKind.d.ts +23 -0
- package/src/engine/physics/ecs/BodyKind.d.ts.map +1 -0
- package/src/engine/physics/ecs/BodyKind.js +24 -0
- package/src/engine/physics/ecs/Collider.d.ts +98 -0
- package/src/engine/physics/ecs/Collider.d.ts.map +1 -0
- package/src/engine/physics/ecs/Collider.js +136 -0
- package/src/engine/physics/ecs/ColliderFlags.d.ts +14 -0
- package/src/engine/physics/ecs/ColliderFlags.d.ts.map +1 -0
- package/src/engine/physics/ecs/ColliderFlags.js +15 -0
- package/src/engine/physics/ecs/ColliderObserverSystem.d.ts +58 -0
- package/src/engine/physics/ecs/ColliderObserverSystem.d.ts.map +1 -0
- package/src/engine/physics/ecs/ColliderObserverSystem.js +103 -0
- package/src/engine/physics/ecs/ColliderSerializationAdapter.d.ts +25 -0
- package/src/engine/physics/ecs/ColliderSerializationAdapter.d.ts.map +1 -0
- package/src/engine/physics/ecs/ColliderSerializationAdapter.js +37 -0
- package/src/engine/physics/ecs/PhysicsEvents.d.ts +15 -0
- package/src/engine/physics/ecs/PhysicsEvents.d.ts.map +1 -0
- package/src/engine/physics/ecs/PhysicsEvents.js +16 -0
- package/src/engine/physics/ecs/PhysicsSystem.d.ts +520 -0
- package/src/engine/physics/ecs/PhysicsSystem.d.ts.map +1 -0
- package/src/engine/physics/ecs/PhysicsSystem.js +1159 -0
- package/src/engine/physics/ecs/RigidBody.d.ts +197 -0
- package/src/engine/physics/ecs/RigidBody.d.ts.map +1 -0
- package/src/engine/physics/ecs/RigidBody.js +240 -0
- package/src/engine/physics/ecs/RigidBodyFlags.d.ts +21 -0
- package/src/engine/physics/ecs/RigidBodyFlags.d.ts.map +1 -0
- package/src/engine/physics/ecs/RigidBodyFlags.js +22 -0
- package/src/engine/physics/ecs/RigidBodySerializationAdapter.d.ts +28 -0
- package/src/engine/physics/ecs/RigidBodySerializationAdapter.d.ts.map +1 -0
- package/src/engine/physics/ecs/RigidBodySerializationAdapter.js +81 -0
- package/src/engine/physics/ecs/SleepState.d.ts +11 -0
- package/src/engine/physics/ecs/SleepState.d.ts.map +1 -0
- package/src/engine/physics/ecs/SleepState.js +12 -0
- package/src/engine/physics/events/ContactEventBuffer.d.ts +46 -0
- package/src/engine/physics/events/ContactEventBuffer.d.ts.map +1 -0
- package/src/engine/physics/events/ContactEventBuffer.js +83 -0
- package/src/engine/physics/events/diff_manifolds.d.ts +25 -0
- package/src/engine/physics/events/diff_manifolds.d.ts.map +1 -0
- package/src/engine/physics/events/diff_manifolds.js +50 -0
- package/src/engine/physics/fluid/FluidField.d.ts +294 -16
- package/src/engine/physics/fluid/FluidField.d.ts.map +1 -1
- package/src/engine/physics/fluid/FluidField.js +510 -66
- package/src/engine/physics/fluid/FluidSimulator.d.ts +188 -5
- package/src/engine/physics/fluid/FluidSimulator.d.ts.map +1 -1
- package/src/engine/physics/fluid/FluidSimulator.js +455 -95
- package/src/engine/physics/fluid/SliceVisualiser.d.ts +29 -6
- package/src/engine/physics/fluid/SliceVisualiser.d.ts.map +1 -1
- package/src/engine/physics/fluid/SliceVisualiser.js +190 -165
- package/src/engine/physics/fluid/ecs/FluidComponent.d.ts +154 -0
- package/src/engine/physics/fluid/ecs/FluidComponent.d.ts.map +1 -0
- package/src/engine/physics/fluid/ecs/FluidComponent.js +238 -0
- package/src/engine/physics/fluid/ecs/FluidEffectorsComponent.d.ts +45 -0
- package/src/engine/physics/fluid/ecs/FluidEffectorsComponent.d.ts.map +1 -0
- package/src/engine/physics/fluid/ecs/FluidEffectorsComponent.js +89 -0
- package/src/engine/physics/fluid/ecs/FluidSystem.d.ts +107 -0
- package/src/engine/physics/fluid/ecs/FluidSystem.d.ts.map +1 -0
- package/src/engine/physics/fluid/ecs/FluidSystem.js +278 -0
- package/src/engine/physics/fluid/effector/AbstractFluidEffector.d.ts +62 -1
- package/src/engine/physics/fluid/effector/AbstractFluidEffector.d.ts.map +1 -1
- package/src/engine/physics/fluid/effector/AbstractFluidEffector.js +81 -6
- package/src/engine/physics/fluid/effector/GlobalFluidEffector.d.ts +17 -4
- package/src/engine/physics/fluid/effector/GlobalFluidEffector.d.ts.map +1 -1
- package/src/engine/physics/fluid/effector/GlobalFluidEffector.js +105 -12
- package/src/engine/physics/fluid/effector/ImpulseFluidEffector.d.ts +43 -0
- package/src/engine/physics/fluid/effector/ImpulseFluidEffector.d.ts.map +1 -0
- package/src/engine/physics/fluid/effector/ImpulseFluidEffector.js +210 -0
- package/src/engine/physics/fluid/effector/WakeFluidEffector.d.ts +62 -1
- package/src/engine/physics/fluid/effector/WakeFluidEffector.d.ts.map +1 -1
- package/src/engine/physics/fluid/effector/WakeFluidEffector.js +302 -8
- package/src/engine/physics/fluid/prototype.js +102 -91
- package/src/engine/physics/fluid/solver/optimal_sor_omega.d.ts +33 -0
- package/src/engine/physics/fluid/solver/optimal_sor_omega.d.ts.map +1 -0
- package/src/engine/physics/fluid/solver/optimal_sor_omega.js +41 -0
- package/src/engine/physics/fluid/solver/v3_grid_apply_advection_forward.d.ts +20 -5
- package/src/engine/physics/fluid/solver/v3_grid_apply_advection_forward.d.ts.map +1 -1
- package/src/engine/physics/fluid/solver/v3_grid_apply_advection_forward.js +60 -38
- package/src/engine/physics/fluid/solver/v3_grid_apply_diffusion.d.ts +25 -4
- package/src/engine/physics/fluid/solver/v3_grid_apply_diffusion.d.ts.map +1 -1
- package/src/engine/physics/fluid/solver/v3_grid_apply_diffusion.js +93 -73
- package/src/engine/physics/fluid/solver/v3_grid_apply_scalar_advection.d.ts +23 -0
- package/src/engine/physics/fluid/solver/v3_grid_apply_scalar_advection.d.ts.map +1 -0
- package/src/engine/physics/fluid/solver/v3_grid_apply_scalar_advection.js +60 -0
- package/src/engine/physics/fluid/solver/v3_grid_compute_divergence.d.ts +23 -0
- package/src/engine/physics/fluid/solver/v3_grid_compute_divergence.d.ts.map +1 -0
- package/src/engine/physics/fluid/solver/v3_grid_compute_divergence.js +68 -0
- package/src/engine/physics/fluid/solver/v3_grid_compute_solid_neighbour_mask.d.ts +30 -0
- package/src/engine/physics/fluid/solver/v3_grid_compute_solid_neighbour_mask.d.ts.map +1 -0
- package/src/engine/physics/fluid/solver/v3_grid_compute_solid_neighbour_mask.js +66 -0
- package/src/engine/physics/fluid/solver/v3_grid_patch_edges_uniform.d.ts +26 -0
- package/src/engine/physics/fluid/solver/v3_grid_patch_edges_uniform.d.ts.map +1 -0
- package/src/engine/physics/fluid/solver/v3_grid_patch_edges_uniform.js +113 -0
- package/src/engine/physics/fluid/solver/v3_grid_shift_in_place.d.ts +30 -0
- package/src/engine/physics/fluid/solver/v3_grid_shift_in_place.d.ts.map +1 -0
- package/src/engine/physics/fluid/solver/v3_grid_shift_in_place.js +107 -0
- package/src/engine/physics/fluid/solver/v3_grid_solve_pressure.d.ts +49 -0
- package/src/engine/physics/fluid/solver/v3_grid_solve_pressure.d.ts.map +1 -0
- package/src/engine/physics/fluid/solver/v3_grid_solve_pressure.js +126 -0
- package/src/engine/physics/fluid/solver/v3_grid_solve_pressure_pcg.d.ts +93 -0
- package/src/engine/physics/fluid/solver/v3_grid_solve_pressure_pcg.d.ts.map +1 -0
- package/src/engine/physics/fluid/solver/v3_grid_solve_pressure_pcg.js +424 -0
- package/src/engine/physics/fluid/solver/v3_grid_solve_pressure_unmasked_legacy.d.ts +20 -0
- package/src/engine/physics/fluid/solver/v3_grid_solve_pressure_unmasked_legacy.d.ts.map +1 -0
- package/src/engine/physics/fluid/solver/v3_grid_solve_pressure_unmasked_legacy.js +83 -0
- package/src/engine/physics/fluid/solver/v3_grid_subtract_pressure_gradient.d.ts +26 -0
- package/src/engine/physics/fluid/solver/v3_grid_subtract_pressure_gradient.d.ts.map +1 -0
- package/src/engine/physics/fluid/solver/v3_grid_subtract_pressure_gradient.js +70 -0
- package/src/engine/physics/gjk/expanding_polytope_algorithm.d.ts.map +1 -1
- package/src/engine/physics/gjk/expanding_polytope_algorithm.js +8 -10
- package/src/engine/physics/inertia/world_inverse_inertia.d.ts +29 -0
- package/src/engine/physics/inertia/world_inverse_inertia.d.ts.map +1 -0
- package/src/engine/physics/inertia/world_inverse_inertia.js +79 -0
- package/src/engine/physics/integration/integrate_position.d.ts +16 -0
- package/src/engine/physics/integration/integrate_position.d.ts.map +1 -0
- package/src/engine/physics/integration/integrate_position.js +48 -0
- package/src/engine/physics/integration/integrate_velocity.d.ts +25 -0
- package/src/engine/physics/integration/integrate_velocity.d.ts.map +1 -0
- package/src/engine/physics/integration/integrate_velocity.js +79 -0
- package/src/engine/physics/integration/quat_integrate.d.ts +27 -0
- package/src/engine/physics/integration/quat_integrate.d.ts.map +1 -0
- package/src/engine/physics/integration/quat_integrate.js +62 -0
- package/src/engine/physics/island/IslandBuilder.d.ts +167 -0
- package/src/engine/physics/island/IslandBuilder.d.ts.map +1 -0
- package/src/engine/physics/island/IslandBuilder.js +411 -0
- package/src/engine/physics/island/union_find.d.ts +51 -0
- package/src/engine/physics/island/union_find.d.ts.map +1 -0
- package/src/engine/physics/island/union_find.js +76 -0
- package/src/engine/physics/narrowphase/PosedShape.d.ts +59 -0
- package/src/engine/physics/narrowphase/PosedShape.d.ts.map +1 -0
- package/src/engine/physics/narrowphase/PosedShape.js +110 -0
- package/src/engine/physics/narrowphase/box_box_manifold.d.ts +32 -0
- package/src/engine/physics/narrowphase/box_box_manifold.d.ts.map +1 -0
- package/src/engine/physics/narrowphase/box_box_manifold.js +543 -0
- package/src/engine/physics/narrowphase/capsule_contacts.d.ts +122 -0
- package/src/engine/physics/narrowphase/capsule_contacts.d.ts.map +1 -0
- package/src/engine/physics/narrowphase/capsule_contacts.js +508 -0
- package/src/engine/physics/narrowphase/narrowphase_step.d.ts +11 -0
- package/src/engine/physics/narrowphase/narrowphase_step.d.ts.map +1 -0
- package/src/engine/physics/narrowphase/narrowphase_step.js +382 -0
- package/src/engine/physics/narrowphase/sphere_box_contact.d.ts +38 -0
- package/src/engine/physics/narrowphase/sphere_box_contact.d.ts.map +1 -0
- package/src/engine/physics/narrowphase/sphere_box_contact.js +130 -0
- package/src/engine/physics/narrowphase/sphere_sphere_contact.d.ts +26 -0
- package/src/engine/physics/narrowphase/sphere_sphere_contact.d.ts.map +1 -0
- package/src/engine/physics/narrowphase/sphere_sphere_contact.js +51 -0
- package/src/engine/physics/queries/PhysicsSurfacePoint.d.ts +83 -0
- package/src/engine/physics/queries/PhysicsSurfacePoint.d.ts.map +1 -0
- package/src/engine/physics/queries/PhysicsSurfacePoint.js +100 -0
- package/src/engine/physics/queries/raycast.d.ts +20 -0
- package/src/engine/physics/queries/raycast.d.ts.map +1 -0
- package/src/engine/physics/queries/raycast.js +249 -0
- package/src/engine/physics/solver/friction_cone.d.ts +16 -0
- package/src/engine/physics/solver/friction_cone.d.ts.map +1 -0
- package/src/engine/physics/solver/friction_cone.js +37 -0
- package/src/engine/physics/solver/solve_contacts.d.ts +36 -0
- package/src/engine/physics/solver/solve_contacts.d.ts.map +1 -0
- package/src/engine/physics/solver/solve_contacts.js +598 -0
- package/src/core/geom/3d/topology/struct/binary/io/edge/OrderedEdge.d.ts +0 -34
- package/src/core/geom/3d/topology/struct/binary/io/edge/OrderedEdge.d.ts.map +0 -1
- package/src/core/geom/3d/topology/struct/binary/io/edge/OrderedEdge.js +0 -66
- package/src/core/geom/3d/topology/struct/binary/io/edge/bt_mesh_calc_edges.d.ts +0 -2
- package/src/core/geom/3d/topology/struct/binary/io/edge/bt_mesh_calc_edges.d.ts.map +0 -1
- package/src/core/geom/3d/topology/struct/binary/io/edge/bt_mesh_calc_edges.js +0 -54
- package/src/core/geom/3d/topology/struct/binary/io/edge/get_or_create_edge_map.d.ts +0 -2
- package/src/core/geom/3d/topology/struct/binary/io/edge/get_or_create_edge_map.d.ts.map +0 -1
- package/src/core/geom/3d/topology/struct/binary/io/edge/get_or_create_edge_map.js +0 -26
- package/src/engine/ecs/components/Motion.d.ts +0 -21
- package/src/engine/ecs/components/Motion.d.ts.map +0 -1
- package/src/engine/ecs/components/Motion.js +0 -27
- package/src/engine/ecs/components/MotionSerializationAdapter.d.ts +0 -20
- package/src/engine/ecs/components/MotionSerializationAdapter.d.ts.map +0 -1
- package/src/engine/ecs/components/MotionSerializationAdapter.js +0 -26
- package/src/engine/ecs/systems/MotionSystem.d.ts +0 -9
- package/src/engine/ecs/systems/MotionSystem.d.ts.map +0 -1
- package/src/engine/ecs/systems/MotionSystem.js +0 -29
- package/src/engine/physics/fluid/Fluid.d.ts +0 -26
- package/src/engine/physics/fluid/Fluid.d.ts.map +0 -1
- package/src/engine/physics/fluid/Fluid.js +0 -221
- package/src/engine/physics/fluid/solver/v3_grid_apply_advection_reverse.d.ts +0 -7
- package/src/engine/physics/fluid/solver/v3_grid_apply_advection_reverse.d.ts.map +0 -1
- package/src/engine/physics/fluid/solver/v3_grid_apply_advection_reverse.js +0 -8
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MetisGraph.d.ts","sourceRoot":"","sources":["../../../../../../src/core/graph/metis/native/MetisGraph.js"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH;IAWQ;;;;OAIG;IACH,mBAFU,WAAW,GAAC,IAAI,CAEG;IAE7B,8BAA8B;IAC9B,eADW,UAAU,GAAC,IAAI,CACD;IACzB,8BAA8B;IAC9B,aADW,UAAU,GAAC,IAAI,CACH;IAIvB;;;OAGG;IACH,kBAFU,WAAW,GAAC,IAAI,CAEE;IAE5B;;;;OAIG;IACH,mBAFU,WAAW,GAAC,IAAI,CAEG;IAE7B;;;;OAIG;IACH,aAFU,MAAM,CAEI;IAEpB;;;OAGG;IACH,gBAFU,MAAM,CAEO;IAEvB;;;;;OAKG;IACH,mBAFU,WAAW,GAAC,IAAI,CAEG;IAE7B;;;;;OAKG;IACH,6BAFU,UAAU,GAAC,IAAI,CAEc;IAIvC;;;;OAIG;IACH,iBAFU,WAAW,GAAC,IAAI,CAEC;IAE3B;;;;OAIG;IACH,iBAFU,WAAW,GAAC,IAAI,CAEC;IAE3B;;;;OAIG;IACH,0BAFU,WAAW,GAAC,IAAI,CAEU;IAEpC;;;;;OAKG;IACH,2BAFU,UAAU,GAAC,IAAI,CAEY;IAErC;;;;;;;;;;;;OAYG;IACH,yBAFU,iBAAiB,GAAC,IAAI,CAEG;IAGvC;;;;;;;;;;;;;;;;OAgBG;IACH,0CAFW,MAAM,QAyBhB;IAED;;;;OAIG;IACH,+BAcC;IAGL,sBAAiC;CAFhC;yBA/MwB,uBAAuB;kCADd,8DAA8D"}
|
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
import { assert } from "../../../assert.js";
|
|
2
|
+
import { BinaryElementPool } from "../../../geom/3d/topology/struct/binary/BinaryElementPool.js";
|
|
3
|
+
import { CSRGraph } from "../../csr/CSRGraph.js";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Holds one graph level of the METIS multilevel pipeline.
|
|
7
|
+
*
|
|
8
|
+
* Extends `CSRGraph` — the CSR adjacency (`edge_addresses`, `adjacency`,
|
|
9
|
+
* `edge_weights`, `vertex_weights`) lives in a single shared `ArrayBuffer`.
|
|
10
|
+
*
|
|
11
|
+
* Adds three groups of fields on top of CSR:
|
|
12
|
+
*
|
|
13
|
+
* - **Multilevel link**: `coarse_vertex_map`, `coarser_graph`, `finer_graph`.
|
|
14
|
+
* `coarse_vertex_map[v]` is the id of v's super-vertex one level coarser.
|
|
15
|
+
*
|
|
16
|
+
* - **Partition state**: `vertex_partition`, `partition_weights`, `current_cut`,
|
|
17
|
+
* plus the boundary list (`boundary_count` / `boundary_vertices` /
|
|
18
|
+
* `boundary_position_of_vertex`).
|
|
19
|
+
*
|
|
20
|
+
* - **K-way refinement bookkeeping**: parallel `internal_degree`,
|
|
21
|
+
* `external_degree`, `neighbor_partition_count`, `neighbor_partition_offset`
|
|
22
|
+
* arrays plus the shared `neighbor_partition_pool` of `(partition_id, edge_weight)`
|
|
23
|
+
* records.
|
|
24
|
+
*
|
|
25
|
+
* Partition / refinement arrays are allocated lazily by
|
|
26
|
+
* `allocate_partition_state(partition_count)` because their sizes depend on `k`,
|
|
27
|
+
* which isn't known at CSR construction time and isn't needed during the
|
|
28
|
+
* coarsening or initial-partitioning phases.
|
|
29
|
+
*
|
|
30
|
+
* Volume objective, multi-constraint balance, separator data, and the various
|
|
31
|
+
* minconn/contig auxiliary fields from libmetis `graph_t` are intentionally
|
|
32
|
+
* omitted — they're not on the path we currently use.
|
|
33
|
+
*/
|
|
34
|
+
export class MetisGraph extends CSRGraph {
|
|
35
|
+
/**
|
|
36
|
+
* @param {number} vertex_count
|
|
37
|
+
* @param {number} adjacency_length total length of the adjacency list (each
|
|
38
|
+
* undirected edge appears twice)
|
|
39
|
+
*/
|
|
40
|
+
constructor(vertex_count, adjacency_length) {
|
|
41
|
+
super(vertex_count, adjacency_length);
|
|
42
|
+
|
|
43
|
+
// --- Multilevel links --------------------------------------------------
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Coarsening map: `coarse_vertex_map[v]` is the id of v's super-vertex
|
|
47
|
+
* in `coarser_graph`. Null until coarsening runs at this level.
|
|
48
|
+
* @type {Uint32Array|null}
|
|
49
|
+
*/
|
|
50
|
+
this.coarse_vertex_map = null;
|
|
51
|
+
|
|
52
|
+
/** @type {MetisGraph|null} */
|
|
53
|
+
this.coarser_graph = null;
|
|
54
|
+
/** @type {MetisGraph|null} */
|
|
55
|
+
this.finer_graph = null;
|
|
56
|
+
|
|
57
|
+
// --- Partition state --------------------------------------------------
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Partition id per vertex, in [0, nparts).
|
|
61
|
+
* @type {Uint32Array|null}
|
|
62
|
+
*/
|
|
63
|
+
this.vertex_partition = null;
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Per-partition total weight (sum of `vertex_weights` for vertices
|
|
67
|
+
* currently assigned to that partition).
|
|
68
|
+
* @type {Uint32Array|null}
|
|
69
|
+
*/
|
|
70
|
+
this.partition_weights = null;
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Current edge cut: sum of weights of edges whose endpoints lie in
|
|
74
|
+
* different partitions. Tracked incrementally during refinement.
|
|
75
|
+
* @type {number}
|
|
76
|
+
*/
|
|
77
|
+
this.current_cut = 0;
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Number of vertices currently on a partition boundary.
|
|
81
|
+
* @type {number}
|
|
82
|
+
*/
|
|
83
|
+
this.boundary_count = 0;
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Boundary list: the first `boundary_count` entries are vertex ids on
|
|
87
|
+
* a partition boundary. Order is not meaningful (entries get swapped
|
|
88
|
+
* with the tail on removal).
|
|
89
|
+
* @type {Uint32Array|null}
|
|
90
|
+
*/
|
|
91
|
+
this.boundary_vertices = null;
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Inverse of `boundary_vertices`: `boundary_position_of_vertex[v]` is
|
|
95
|
+
* the index of v inside `boundary_vertices`, or -1 if v is interior.
|
|
96
|
+
* Int32Array because of the -1 sentinel.
|
|
97
|
+
* @type {Int32Array|null}
|
|
98
|
+
*/
|
|
99
|
+
this.boundary_position_of_vertex = null;
|
|
100
|
+
|
|
101
|
+
// --- K-way refinement bookkeeping (parallel arrays, indexed by vertex)
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Internal degree: sum of edge weights from v to vertices in v's own
|
|
105
|
+
* partition. ("id" in METIS / FM literature.)
|
|
106
|
+
* @type {Uint32Array|null}
|
|
107
|
+
*/
|
|
108
|
+
this.internal_degree = null;
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* External degree: sum of edge weights from v to vertices in other
|
|
112
|
+
* partitions. ("ed" in METIS / FM literature.)
|
|
113
|
+
* @type {Uint32Array|null}
|
|
114
|
+
*/
|
|
115
|
+
this.external_degree = null;
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* Number of distinct neighbouring partitions reachable from v through
|
|
119
|
+
* its edges. ("nnbrs" in METIS.)
|
|
120
|
+
* @type {Uint32Array|null}
|
|
121
|
+
*/
|
|
122
|
+
this.neighbor_partition_count = null;
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* Offset (in record units) into `neighbor_partition_pool` for v's list
|
|
126
|
+
* of (partition_id, edge_weight) entries. -1 if v is interior and no
|
|
127
|
+
* pool slot has been allocated yet. ("inbr" in METIS.)
|
|
128
|
+
* @type {Int32Array|null}
|
|
129
|
+
*/
|
|
130
|
+
this.neighbor_partition_offset = null;
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* Pool of per-(vertex, neighbour-partition) records. Each record is
|
|
134
|
+
* 8 bytes: two uint32 words holding `(partition_id, edge_weight)`.
|
|
135
|
+
* Access record `r` via:
|
|
136
|
+
* const word_base = neighbor_partition_pool.element_word(r);
|
|
137
|
+
* const partition_id = data_uint32[word_base + 2*k ];
|
|
138
|
+
* const edge_weight = data_uint32[word_base + 2*k + 1];
|
|
139
|
+
* where `k` is in `[0, neighbor_partition_count[v])`.
|
|
140
|
+
*
|
|
141
|
+
* ("cnbrpool" in METIS.)
|
|
142
|
+
*
|
|
143
|
+
* @type {BinaryElementPool|null}
|
|
144
|
+
*/
|
|
145
|
+
this.neighbor_partition_pool = null;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* Allocate the k-way refinement bookkeeping arrays. Must be called before
|
|
150
|
+
* any of the refinement routines runs on this graph.
|
|
151
|
+
*
|
|
152
|
+
* **`vertex_partition` is preserved** if it's already set with the correct
|
|
153
|
+
* length. This matters when the initial-partition phase has already
|
|
154
|
+
* computed an assignment (e.g. recursive bisection leaves the result in
|
|
155
|
+
* `vertex_partition` as a buffer that's now owned by this graph) — we
|
|
156
|
+
* don't want to allocate a fresh array just to copy the existing one in.
|
|
157
|
+
* If `vertex_partition` is `null` or the wrong size, it gets allocated
|
|
158
|
+
* fresh and zero-filled.
|
|
159
|
+
*
|
|
160
|
+
* Everything else (`partition_weights`, `internal_degree`, etc.) is always
|
|
161
|
+
* allocated fresh because callers expect a clean refinement-state baseline.
|
|
162
|
+
*
|
|
163
|
+
* @param {number} partition_count
|
|
164
|
+
*/
|
|
165
|
+
allocate_partition_state(partition_count) {
|
|
166
|
+
assert.isNonNegativeInteger(partition_count, 'partition_count');
|
|
167
|
+
|
|
168
|
+
const n = this.vertex_count;
|
|
169
|
+
|
|
170
|
+
if (this.vertex_partition === null || this.vertex_partition.length !== n) {
|
|
171
|
+
this.vertex_partition = new Uint32Array(n);
|
|
172
|
+
}
|
|
173
|
+
this.partition_weights = new Uint32Array(partition_count);
|
|
174
|
+
this.boundary_vertices = new Uint32Array(n);
|
|
175
|
+
this.boundary_position_of_vertex = new Int32Array(n);
|
|
176
|
+
this.boundary_position_of_vertex.fill(-1);
|
|
177
|
+
|
|
178
|
+
this.internal_degree = new Uint32Array(n);
|
|
179
|
+
this.external_degree = new Uint32Array(n);
|
|
180
|
+
this.neighbor_partition_count = new Uint32Array(n);
|
|
181
|
+
this.neighbor_partition_offset = new Int32Array(n);
|
|
182
|
+
this.neighbor_partition_offset.fill(-1);
|
|
183
|
+
|
|
184
|
+
// Each pool record is 8 bytes (uint32 partition_id, uint32 edge_weight).
|
|
185
|
+
// Initial capacity sized to the adjacency length as a rough upper bound;
|
|
186
|
+
// the pool grows on demand.
|
|
187
|
+
this.neighbor_partition_pool = new BinaryElementPool(8, Math.max(64, this.adjacency_length));
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
/**
|
|
191
|
+
* Reset the partition / refinement bookkeeping in place, leaving the CSR
|
|
192
|
+
* adjacency and `coarse_vertex_map` untouched. Used between FM passes when
|
|
193
|
+
* we want to recompute from a fresh `vertex_partition`.
|
|
194
|
+
*/
|
|
195
|
+
reset_refinement_state() {
|
|
196
|
+
if (this.internal_degree !== null) {
|
|
197
|
+
this.internal_degree.fill(0);
|
|
198
|
+
this.external_degree.fill(0);
|
|
199
|
+
this.neighbor_partition_count.fill(0);
|
|
200
|
+
this.neighbor_partition_offset.fill(-1);
|
|
201
|
+
}
|
|
202
|
+
if (this.neighbor_partition_pool !== null) {
|
|
203
|
+
this.neighbor_partition_pool.clear();
|
|
204
|
+
}
|
|
205
|
+
if (this.boundary_position_of_vertex !== null) {
|
|
206
|
+
this.boundary_position_of_vertex.fill(-1);
|
|
207
|
+
}
|
|
208
|
+
this.boundary_count = 0;
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
MetisGraph.prototype.isMetisGraph = true;
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pre-allocated scratch reused by every recursive `bisect_graph` call during
|
|
3
|
+
* the initial-partition phase.
|
|
4
|
+
*
|
|
5
|
+
* Recursive bisection produces O(k) subgraphs that each need their own
|
|
6
|
+
* refinement state and FM scratch — but only at sizes <= the coarsest vertex
|
|
7
|
+
* count. Sharing one set of arrays scoped to that maximum eliminates O(k)
|
|
8
|
+
* typed-array allocations and the corresponding GC pressure.
|
|
9
|
+
*
|
|
10
|
+
* Contents:
|
|
11
|
+
*
|
|
12
|
+
* - **Compute-2way state**: `boundary_vertices`, `boundary_position_of_vertex`,
|
|
13
|
+
* `internal_degree`, `external_degree`, `partition_weights[2]`.
|
|
14
|
+
*
|
|
15
|
+
* - **FM-2way state**: `fm_heaps` (one per side of the bisection),
|
|
16
|
+
* `fm_moved_pass_index`, `fm_swap_history`, `fm_insertion_order`.
|
|
17
|
+
*
|
|
18
|
+
* - **Bisect snapshot**: `best_partition_snapshot` for grow+FM trial selection.
|
|
19
|
+
*
|
|
20
|
+
* - **`vertex_partition_pool`**: a stack of vertex_partition arrays. Each
|
|
21
|
+
* recursive call takes a slot (via `take_vertex_partition_slot`) and
|
|
22
|
+
* releases it on return. New slots are allocated lazily, capped at
|
|
23
|
+
* `log2(k)` total — the maximum recursion depth.
|
|
24
|
+
*
|
|
25
|
+
* The two FM heaps are sized to `max_vertex_count` at construction. Their
|
|
26
|
+
* internal `__slot_of_id` table can hold any id in `[0, max_vertex_count)`, so
|
|
27
|
+
* subgraphs of any size below that work without expanding. `clear()` resets
|
|
28
|
+
* heap state in O(size), not O(capacity).
|
|
29
|
+
*
|
|
30
|
+
* `fm_moved_pass_index` starts initialised to -1. fm_2way's per-pass cleanup
|
|
31
|
+
* resets touched entries back to -1, so the invariant is preserved across
|
|
32
|
+
* calls — no need to refill the whole array between bisect_graph invocations.
|
|
33
|
+
*/
|
|
34
|
+
export class BisectionScratch {
|
|
35
|
+
/**
|
|
36
|
+
* @param {number} max_vertex_count typically the coarsest graph's vertex count
|
|
37
|
+
*/
|
|
38
|
+
constructor(max_vertex_count: number);
|
|
39
|
+
max_vertex_count: number;
|
|
40
|
+
boundary_vertices: Uint32Array;
|
|
41
|
+
boundary_position_of_vertex: Int32Array;
|
|
42
|
+
internal_degree: Uint32Array;
|
|
43
|
+
external_degree: Uint32Array;
|
|
44
|
+
partition_weights: Uint32Array;
|
|
45
|
+
best_partition_snapshot: Uint32Array;
|
|
46
|
+
fm_heaps: IndexedFloatMaxHeap[];
|
|
47
|
+
fm_moved_pass_index: Int32Array;
|
|
48
|
+
fm_swap_history: Uint32Array;
|
|
49
|
+
fm_insertion_order: Uint32Array;
|
|
50
|
+
/** @type {Uint32Array[]} */
|
|
51
|
+
vertex_partition_pool: Uint32Array[];
|
|
52
|
+
vertex_partition_pool_top: number;
|
|
53
|
+
/**
|
|
54
|
+
* Borrow a vertex_partition slot from the pool. The first `vertex_count`
|
|
55
|
+
* entries are zero-filled; values past `vertex_count` may hold stale data
|
|
56
|
+
* from a sibling subgraph and must not be read.
|
|
57
|
+
*
|
|
58
|
+
* Returned slot remains owned by the scratch; release with
|
|
59
|
+
* `release_vertex_partition_slot` once you're done with it.
|
|
60
|
+
*
|
|
61
|
+
* @param {number} vertex_count subgraph's vertex_count
|
|
62
|
+
* @returns {Uint32Array}
|
|
63
|
+
*/
|
|
64
|
+
take_vertex_partition_slot(vertex_count: number): Uint32Array;
|
|
65
|
+
/**
|
|
66
|
+
* Pop the top vertex_partition slot off the pool. Pairs with
|
|
67
|
+
* `take_vertex_partition_slot` — call exactly once per take.
|
|
68
|
+
*/
|
|
69
|
+
release_vertex_partition_slot(): void;
|
|
70
|
+
}
|
|
71
|
+
import { IndexedFloatMaxHeap } from "../refine/IndexedFloatMaxHeap.js";
|
|
72
|
+
//# sourceMappingURL=BisectionScratch.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BisectionScratch.d.ts","sourceRoot":"","sources":["../../../../../../../src/core/graph/metis/native/bisection/BisectionScratch.js"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH;IACI;;OAEG;IACH,8BAFW,MAAM,EA8BhB;IA3BG,yBAAwC;IAIxC,+BAA0D;IAC1D,wCAAmE;IACnE,6BAAwD;IACxD,6BAAwD;IACxD,+BAA2C;IAC3C,qCAAgE;IAIhE,gCAGC;IACD,gCAA2D;IAE3D,6BAAwD;IACxD,gCAA2D;IAI3D,4BAA4B;IAC5B,uBADW,WAAW,EAAE,CACO;IAC/B,kCAAkC;IAGtC;;;;;;;;;;OAUG;IACH,yCAHW,MAAM,GACJ,WAAW,CAavB;IAED;;;OAGG;IACH,sCAEC;CACJ;oCApGmC,kCAAkC"}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { IndexedFloatMaxHeap } from "../refine/IndexedFloatMaxHeap.js";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Pre-allocated scratch reused by every recursive `bisect_graph` call during
|
|
5
|
+
* the initial-partition phase.
|
|
6
|
+
*
|
|
7
|
+
* Recursive bisection produces O(k) subgraphs that each need their own
|
|
8
|
+
* refinement state and FM scratch — but only at sizes <= the coarsest vertex
|
|
9
|
+
* count. Sharing one set of arrays scoped to that maximum eliminates O(k)
|
|
10
|
+
* typed-array allocations and the corresponding GC pressure.
|
|
11
|
+
*
|
|
12
|
+
* Contents:
|
|
13
|
+
*
|
|
14
|
+
* - **Compute-2way state**: `boundary_vertices`, `boundary_position_of_vertex`,
|
|
15
|
+
* `internal_degree`, `external_degree`, `partition_weights[2]`.
|
|
16
|
+
*
|
|
17
|
+
* - **FM-2way state**: `fm_heaps` (one per side of the bisection),
|
|
18
|
+
* `fm_moved_pass_index`, `fm_swap_history`, `fm_insertion_order`.
|
|
19
|
+
*
|
|
20
|
+
* - **Bisect snapshot**: `best_partition_snapshot` for grow+FM trial selection.
|
|
21
|
+
*
|
|
22
|
+
* - **`vertex_partition_pool`**: a stack of vertex_partition arrays. Each
|
|
23
|
+
* recursive call takes a slot (via `take_vertex_partition_slot`) and
|
|
24
|
+
* releases it on return. New slots are allocated lazily, capped at
|
|
25
|
+
* `log2(k)` total — the maximum recursion depth.
|
|
26
|
+
*
|
|
27
|
+
* The two FM heaps are sized to `max_vertex_count` at construction. Their
|
|
28
|
+
* internal `__slot_of_id` table can hold any id in `[0, max_vertex_count)`, so
|
|
29
|
+
* subgraphs of any size below that work without expanding. `clear()` resets
|
|
30
|
+
* heap state in O(size), not O(capacity).
|
|
31
|
+
*
|
|
32
|
+
* `fm_moved_pass_index` starts initialised to -1. fm_2way's per-pass cleanup
|
|
33
|
+
* resets touched entries back to -1, so the invariant is preserved across
|
|
34
|
+
* calls — no need to refill the whole array between bisect_graph invocations.
|
|
35
|
+
*/
|
|
36
|
+
export class BisectionScratch {
|
|
37
|
+
/**
|
|
38
|
+
* @param {number} max_vertex_count typically the coarsest graph's vertex count
|
|
39
|
+
*/
|
|
40
|
+
constructor(max_vertex_count) {
|
|
41
|
+
this.max_vertex_count = max_vertex_count;
|
|
42
|
+
|
|
43
|
+
// --- 2-way refinement state shared with compute_2way_params ---
|
|
44
|
+
|
|
45
|
+
this.boundary_vertices = new Uint32Array(max_vertex_count);
|
|
46
|
+
this.boundary_position_of_vertex = new Int32Array(max_vertex_count);
|
|
47
|
+
this.internal_degree = new Uint32Array(max_vertex_count);
|
|
48
|
+
this.external_degree = new Uint32Array(max_vertex_count);
|
|
49
|
+
this.partition_weights = new Uint32Array(2);
|
|
50
|
+
this.best_partition_snapshot = new Uint32Array(max_vertex_count);
|
|
51
|
+
|
|
52
|
+
// --- FM_2way scratch ---
|
|
53
|
+
|
|
54
|
+
this.fm_heaps = [
|
|
55
|
+
new IndexedFloatMaxHeap(max_vertex_count, Math.min(max_vertex_count, 1024)),
|
|
56
|
+
new IndexedFloatMaxHeap(max_vertex_count, Math.min(max_vertex_count, 1024))
|
|
57
|
+
];
|
|
58
|
+
this.fm_moved_pass_index = new Int32Array(max_vertex_count);
|
|
59
|
+
this.fm_moved_pass_index.fill(-1);
|
|
60
|
+
this.fm_swap_history = new Uint32Array(max_vertex_count);
|
|
61
|
+
this.fm_insertion_order = new Uint32Array(max_vertex_count);
|
|
62
|
+
|
|
63
|
+
// --- vertex_partition stack pool ---
|
|
64
|
+
|
|
65
|
+
/** @type {Uint32Array[]} */
|
|
66
|
+
this.vertex_partition_pool = [];
|
|
67
|
+
this.vertex_partition_pool_top = 0;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Borrow a vertex_partition slot from the pool. The first `vertex_count`
|
|
72
|
+
* entries are zero-filled; values past `vertex_count` may hold stale data
|
|
73
|
+
* from a sibling subgraph and must not be read.
|
|
74
|
+
*
|
|
75
|
+
* Returned slot remains owned by the scratch; release with
|
|
76
|
+
* `release_vertex_partition_slot` once you're done with it.
|
|
77
|
+
*
|
|
78
|
+
* @param {number} vertex_count subgraph's vertex_count
|
|
79
|
+
* @returns {Uint32Array}
|
|
80
|
+
*/
|
|
81
|
+
take_vertex_partition_slot(vertex_count) {
|
|
82
|
+
const slot_index = this.vertex_partition_pool_top;
|
|
83
|
+
let slot = this.vertex_partition_pool[slot_index];
|
|
84
|
+
if (slot === undefined) {
|
|
85
|
+
slot = new Uint32Array(this.max_vertex_count);
|
|
86
|
+
this.vertex_partition_pool.push(slot);
|
|
87
|
+
} else {
|
|
88
|
+
slot.fill(0, 0, vertex_count);
|
|
89
|
+
}
|
|
90
|
+
this.vertex_partition_pool_top = slot_index + 1;
|
|
91
|
+
return slot;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Pop the top vertex_partition slot off the pool. Pairs with
|
|
96
|
+
* `take_vertex_partition_slot` — call exactly once per take.
|
|
97
|
+
*/
|
|
98
|
+
release_vertex_partition_slot() {
|
|
99
|
+
this.vertex_partition_pool_top--;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Bisect a graph into two partitions with `target_weight_for_partition_0` weight
|
|
3
|
+
* landing in partition 0. Runs `bisection_trial_count` independent BFS-grow + FM
|
|
4
|
+
* trials and keeps the best (lowest-cut) result.
|
|
5
|
+
*
|
|
6
|
+
* Mirrors `Init2WayPartition` from libmetis/initpart.c, single-constraint cut
|
|
7
|
+
* branch only.
|
|
8
|
+
*
|
|
9
|
+
* **All scratch state is taken from the supplied `BisectionScratch`**:
|
|
10
|
+
* - the 2-way refinement arrays (`internal_degree`, `external_degree`,
|
|
11
|
+
* boundary list, `partition_weights[2]`),
|
|
12
|
+
* - the FM heaps and pass-local arrays,
|
|
13
|
+
* - the best-cut snapshot,
|
|
14
|
+
* - and `vertex_partition` itself, which the caller borrows from the
|
|
15
|
+
* scratch's stack pool and releases after using the result.
|
|
16
|
+
*
|
|
17
|
+
* The k-way bookkeeping arrays (`neighbor_partition_*`, `neighbor_partition_pool`)
|
|
18
|
+
* are NOT set up here — bisection doesn't need them. They get allocated by
|
|
19
|
+
* `allocate_partition_state(k)` once recursive bisection is done and the graph
|
|
20
|
+
* moves into k-way refinement.
|
|
21
|
+
*
|
|
22
|
+
* On return, `graph.vertex_partition[]` contains 0/1 in `[0, vertex_count)` and
|
|
23
|
+
* `graph.current_cut` is the bisection cut. The vertex_partition slot may be
|
|
24
|
+
* sized larger than vertex_count — only the prefix is meaningful.
|
|
25
|
+
*
|
|
26
|
+
* @param {import('../MetisGraph.js').MetisGraph} graph
|
|
27
|
+
* @param {Uint32Array} vertex_partition pre-zeroed slot from the scratch pool;
|
|
28
|
+
* typically obtained via `scratch.take_vertex_partition_slot(graph.vertex_count)`
|
|
29
|
+
* @param {number} target_weight_for_partition_0
|
|
30
|
+
* @param {number} bisection_trial_count number of independent grow+FM trials
|
|
31
|
+
* @param {number} fm_pass_count FM passes per trial
|
|
32
|
+
* @param {number} ub_factor balance tolerance for `grow_bisection`
|
|
33
|
+
* @param {function():number} random
|
|
34
|
+
* @param {import('./BisectionScratch.js').BisectionScratch} scratch
|
|
35
|
+
*/
|
|
36
|
+
export function bisect_graph(graph: import('../MetisGraph.js').MetisGraph, vertex_partition: Uint32Array, target_weight_for_partition_0: number, bisection_trial_count: number, fm_pass_count: number, ub_factor: number, random: () => number, scratch: import('./BisectionScratch.js').BisectionScratch): void;
|
|
37
|
+
//# sourceMappingURL=bisect_graph.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bisect_graph.d.ts","sourceRoot":"","sources":["../../../../../../../src/core/graph/metis/native/bisection/bisect_graph.js"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,oCAVW,OAAO,kBAAkB,EAAE,UAAU,oBACrC,WAAW,iCAEX,MAAM,yBACN,MAAM,iBACN,MAAM,aACN,MAAM,gBACK,MAAM,WACjB,OAAO,uBAAuB,EAAE,gBAAgB,QA6C1D"}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { compute_2way_params } from "./compute_2way_params.js";
|
|
2
|
+
import { fm_2way } from "./fm_2way.js";
|
|
3
|
+
import { grow_bisection } from "./grow_bisection.js";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Bisect a graph into two partitions with `target_weight_for_partition_0` weight
|
|
7
|
+
* landing in partition 0. Runs `bisection_trial_count` independent BFS-grow + FM
|
|
8
|
+
* trials and keeps the best (lowest-cut) result.
|
|
9
|
+
*
|
|
10
|
+
* Mirrors `Init2WayPartition` from libmetis/initpart.c, single-constraint cut
|
|
11
|
+
* branch only.
|
|
12
|
+
*
|
|
13
|
+
* **All scratch state is taken from the supplied `BisectionScratch`**:
|
|
14
|
+
* - the 2-way refinement arrays (`internal_degree`, `external_degree`,
|
|
15
|
+
* boundary list, `partition_weights[2]`),
|
|
16
|
+
* - the FM heaps and pass-local arrays,
|
|
17
|
+
* - the best-cut snapshot,
|
|
18
|
+
* - and `vertex_partition` itself, which the caller borrows from the
|
|
19
|
+
* scratch's stack pool and releases after using the result.
|
|
20
|
+
*
|
|
21
|
+
* The k-way bookkeeping arrays (`neighbor_partition_*`, `neighbor_partition_pool`)
|
|
22
|
+
* are NOT set up here — bisection doesn't need them. They get allocated by
|
|
23
|
+
* `allocate_partition_state(k)` once recursive bisection is done and the graph
|
|
24
|
+
* moves into k-way refinement.
|
|
25
|
+
*
|
|
26
|
+
* On return, `graph.vertex_partition[]` contains 0/1 in `[0, vertex_count)` and
|
|
27
|
+
* `graph.current_cut` is the bisection cut. The vertex_partition slot may be
|
|
28
|
+
* sized larger than vertex_count — only the prefix is meaningful.
|
|
29
|
+
*
|
|
30
|
+
* @param {import('../MetisGraph.js').MetisGraph} graph
|
|
31
|
+
* @param {Uint32Array} vertex_partition pre-zeroed slot from the scratch pool;
|
|
32
|
+
* typically obtained via `scratch.take_vertex_partition_slot(graph.vertex_count)`
|
|
33
|
+
* @param {number} target_weight_for_partition_0
|
|
34
|
+
* @param {number} bisection_trial_count number of independent grow+FM trials
|
|
35
|
+
* @param {number} fm_pass_count FM passes per trial
|
|
36
|
+
* @param {number} ub_factor balance tolerance for `grow_bisection`
|
|
37
|
+
* @param {function():number} random
|
|
38
|
+
* @param {import('./BisectionScratch.js').BisectionScratch} scratch
|
|
39
|
+
*/
|
|
40
|
+
export function bisect_graph(
|
|
41
|
+
graph,
|
|
42
|
+
vertex_partition,
|
|
43
|
+
target_weight_for_partition_0,
|
|
44
|
+
bisection_trial_count,
|
|
45
|
+
fm_pass_count,
|
|
46
|
+
ub_factor,
|
|
47
|
+
random,
|
|
48
|
+
scratch
|
|
49
|
+
) {
|
|
50
|
+
attach_scratch(graph, vertex_partition, scratch);
|
|
51
|
+
|
|
52
|
+
let best_cut = -1;
|
|
53
|
+
const best_partition = scratch.best_partition_snapshot;
|
|
54
|
+
const vertex_count = graph.vertex_count;
|
|
55
|
+
|
|
56
|
+
for (let trial = 0; trial < bisection_trial_count; trial++) {
|
|
57
|
+
grow_bisection(graph, target_weight_for_partition_0, ub_factor, random);
|
|
58
|
+
compute_2way_params(graph);
|
|
59
|
+
fm_2way(graph, target_weight_for_partition_0, fm_pass_count, random, scratch);
|
|
60
|
+
|
|
61
|
+
if (best_cut === -1 || graph.current_cut < best_cut) {
|
|
62
|
+
best_cut = graph.current_cut;
|
|
63
|
+
// Snapshot only the active subgraph range — best_partition is
|
|
64
|
+
// sized to max_vertex_count and may have stale values past
|
|
65
|
+
// vertex_count from a sibling's earlier bisection.
|
|
66
|
+
for (let v = 0; v < vertex_count; v++) {
|
|
67
|
+
best_partition[v] = vertex_partition[v];
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
if (best_cut === 0) {
|
|
72
|
+
break;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
// Restore the best partition if a later trial wasn't the winner.
|
|
77
|
+
if (best_cut !== graph.current_cut) {
|
|
78
|
+
for (let v = 0; v < vertex_count; v++) {
|
|
79
|
+
vertex_partition[v] = best_partition[v];
|
|
80
|
+
}
|
|
81
|
+
compute_2way_params(graph);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Wire the graph's bisection-state fields to point at the supplied
|
|
87
|
+
* vertex_partition slot and the shared scratch arrays.
|
|
88
|
+
*
|
|
89
|
+
* @param {import('../MetisGraph.js').MetisGraph} graph
|
|
90
|
+
* @param {Uint32Array} vertex_partition pre-zeroed slot owned by the scratch pool
|
|
91
|
+
* @param {import('./BisectionScratch.js').BisectionScratch} scratch
|
|
92
|
+
*/
|
|
93
|
+
function attach_scratch(graph, vertex_partition, scratch) {
|
|
94
|
+
graph.vertex_partition = vertex_partition;
|
|
95
|
+
graph.partition_weights = scratch.partition_weights;
|
|
96
|
+
graph.boundary_vertices = scratch.boundary_vertices;
|
|
97
|
+
graph.boundary_position_of_vertex = scratch.boundary_position_of_vertex;
|
|
98
|
+
graph.internal_degree = scratch.internal_degree;
|
|
99
|
+
graph.external_degree = scratch.external_degree;
|
|
100
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* From a freshly-assigned bisection `vertex_partition[]` (containing only 0
|
|
3
|
+
* and 1), populate the 2-way refinement bookkeeping: per-partition weights,
|
|
4
|
+
* per-vertex internal/external degree, boundary list, and total cut.
|
|
5
|
+
*
|
|
6
|
+
* Mirrors `Compute2WayPartitionParams` from libmetis/refine.c.
|
|
7
|
+
*
|
|
8
|
+
* For 2-way refinement, the neighbour-partition list is trivially "the other
|
|
9
|
+
* partition", so we don't allocate any cnbr pool — only the parallel
|
|
10
|
+
* `internal_degree[v]` and `external_degree[v]` arrays are needed.
|
|
11
|
+
*
|
|
12
|
+
* @param {import('../MetisGraph.js').MetisGraph} graph
|
|
13
|
+
*/
|
|
14
|
+
export function compute_2way_params(graph: import('../MetisGraph.js').MetisGraph): void;
|
|
15
|
+
//# sourceMappingURL=compute_2way_params.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compute_2way_params.d.ts","sourceRoot":"","sources":["../../../../../../../src/core/graph/metis/native/bisection/compute_2way_params.js"],"names":[],"mappings":"AAEA;;;;;;;;;;;;GAYG;AACH,2CAFW,OAAO,kBAAkB,EAAE,UAAU,QAsE/C"}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { assert } from "../../../../assert.js";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* From a freshly-assigned bisection `vertex_partition[]` (containing only 0
|
|
5
|
+
* and 1), populate the 2-way refinement bookkeeping: per-partition weights,
|
|
6
|
+
* per-vertex internal/external degree, boundary list, and total cut.
|
|
7
|
+
*
|
|
8
|
+
* Mirrors `Compute2WayPartitionParams` from libmetis/refine.c.
|
|
9
|
+
*
|
|
10
|
+
* For 2-way refinement, the neighbour-partition list is trivially "the other
|
|
11
|
+
* partition", so we don't allocate any cnbr pool — only the parallel
|
|
12
|
+
* `internal_degree[v]` and `external_degree[v]` arrays are needed.
|
|
13
|
+
*
|
|
14
|
+
* @param {import('../MetisGraph.js').MetisGraph} graph
|
|
15
|
+
*/
|
|
16
|
+
export function compute_2way_params(graph) {
|
|
17
|
+
const vertex_count = graph.vertex_count;
|
|
18
|
+
const edge_addresses = graph.edge_addresses;
|
|
19
|
+
const adjacency = graph.adjacency;
|
|
20
|
+
const edge_weights = graph.edge_weights;
|
|
21
|
+
const vertex_weights = graph.vertex_weights;
|
|
22
|
+
const vertex_partition = graph.vertex_partition;
|
|
23
|
+
const partition_weights = graph.partition_weights;
|
|
24
|
+
const internal_degree = graph.internal_degree;
|
|
25
|
+
const external_degree = graph.external_degree;
|
|
26
|
+
const boundary_vertices = graph.boundary_vertices;
|
|
27
|
+
const boundary_position_of_vertex = graph.boundary_position_of_vertex;
|
|
28
|
+
|
|
29
|
+
assert.equal(vertex_partition !== null, true, 'graph.vertex_partition must be allocated');
|
|
30
|
+
assert.equal(partition_weights.length, 2, 'partition_weights must be sized for 2 partitions');
|
|
31
|
+
|
|
32
|
+
partition_weights[0] = 0;
|
|
33
|
+
partition_weights[1] = 0;
|
|
34
|
+
// internal_degree and external_degree do not need pre-clearing — every
|
|
35
|
+
// vertex in [0, vertex_count) gets written in the per-vertex loop below,
|
|
36
|
+
// and we never read past vertex_count.
|
|
37
|
+
// boundary_position_of_vertex IS read conditionally (only boundary vertices
|
|
38
|
+
// get set), so it does need a clear — but bounded to the active subgraph
|
|
39
|
+
// range, since the scratch may be sized for a larger ancestor graph.
|
|
40
|
+
boundary_position_of_vertex.fill(-1, 0, vertex_count);
|
|
41
|
+
|
|
42
|
+
for (let v = 0; v < vertex_count; v++) {
|
|
43
|
+
partition_weights[vertex_partition[v]] += vertex_weights[v];
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
let boundary_count = 0;
|
|
47
|
+
let cut_doubled = 0;
|
|
48
|
+
|
|
49
|
+
for (let vertex = 0; vertex < vertex_count; vertex++) {
|
|
50
|
+
const my_partition = vertex_partition[vertex];
|
|
51
|
+
|
|
52
|
+
let v_internal_degree = 0;
|
|
53
|
+
let v_external_degree = 0;
|
|
54
|
+
|
|
55
|
+
const edge_start = edge_addresses[vertex];
|
|
56
|
+
const edge_end = edge_addresses[vertex + 1];
|
|
57
|
+
for (let edge_offset = edge_start; edge_offset < edge_end; edge_offset++) {
|
|
58
|
+
const neighbor_partition = vertex_partition[adjacency[edge_offset]];
|
|
59
|
+
const edge_weight = edge_weights[edge_offset];
|
|
60
|
+
if (neighbor_partition === my_partition) {
|
|
61
|
+
v_internal_degree += edge_weight;
|
|
62
|
+
} else {
|
|
63
|
+
v_external_degree += edge_weight;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
internal_degree[vertex] = v_internal_degree;
|
|
68
|
+
external_degree[vertex] = v_external_degree;
|
|
69
|
+
|
|
70
|
+
if (v_external_degree > 0 || edge_start === edge_end) {
|
|
71
|
+
// Add isolated vertices too — they're "boundary" in the degenerate sense
|
|
72
|
+
// that moving them is free. Matches METIS behaviour.
|
|
73
|
+
if (v_external_degree > 0) {
|
|
74
|
+
cut_doubled += v_external_degree;
|
|
75
|
+
boundary_vertices[boundary_count] = vertex;
|
|
76
|
+
boundary_position_of_vertex[vertex] = boundary_count;
|
|
77
|
+
boundary_count++;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
graph.current_cut = cut_doubled >> 1;
|
|
83
|
+
graph.boundary_count = boundary_count;
|
|
84
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 2-way Fiduccia–Mattheyses cut refinement (single-constraint, cut objective).
|
|
3
|
+
*
|
|
4
|
+
* Maintains two max-heaps keyed by per-vertex gain (`external_degree − internal_degree`),
|
|
5
|
+
* one per side of the bisection. Each pass:
|
|
6
|
+
* 1. Insert every boundary vertex into the queue for its current side.
|
|
7
|
+
* 2. Repeatedly pop from whichever side is more overweight, move the vertex,
|
|
8
|
+
* and update neighbours. Track running cut and remember the best snapshot.
|
|
9
|
+
* 3. Stop when both queues drain, or when `LIMIT_NONIMPROVING_MOVES` moves
|
|
10
|
+
* pass without finding a better cut.
|
|
11
|
+
* 4. Roll back any moves made after the best-cut snapshot.
|
|
12
|
+
*
|
|
13
|
+
* Each vertex is locked after moving once (it can't move back in the same pass).
|
|
14
|
+
* Locking is reset between passes.
|
|
15
|
+
*
|
|
16
|
+
* Mirrors `FM_2WayCutRefine` from libmetis/fm.c.
|
|
17
|
+
*
|
|
18
|
+
* All scratch state (heaps, moved-index, swap history, insertion order) is
|
|
19
|
+
* shared via the `BisectionScratch` passed in by the caller, sized to the
|
|
20
|
+
* coarsest graph's vertex_count. This eliminates per-trial allocation.
|
|
21
|
+
*
|
|
22
|
+
* @param {import('../MetisGraph.js').MetisGraph} graph
|
|
23
|
+
* @param {number} target_weight_for_partition_0
|
|
24
|
+
* @param {number} pass_count
|
|
25
|
+
* @param {function():number} random seeded RNG used to shuffle boundary
|
|
26
|
+
* insertion order so ties break differently each pass
|
|
27
|
+
* @param {import('./BisectionScratch.js').BisectionScratch} scratch
|
|
28
|
+
*/
|
|
29
|
+
export function fm_2way(graph: import('../MetisGraph.js').MetisGraph, target_weight_for_partition_0: number, pass_count: number, random: () => number, scratch: import('./BisectionScratch.js').BisectionScratch): void;
|
|
30
|
+
//# sourceMappingURL=fm_2way.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fm_2way.d.ts","sourceRoot":"","sources":["../../../../../../../src/core/graph/metis/native/bisection/fm_2way.js"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,+BAPW,OAAO,kBAAkB,EAAE,UAAU,iCACrC,MAAM,cACN,MAAM,gBACK,MAAM,WAEjB,OAAO,uBAAuB,EAAE,gBAAgB,QAuQ1D"}
|