Skip to contents

Reports a lower bound for dense distance storage, not peak memory or runtime. This arithmetic-only helper does not construct a graph or allocate its cache.

Usage

estimate.preparation(
  n,
  n.edges = NA_integer_,
  pair_mode = c("all_pairs", "landmark_sparse", "distance_matrix_only", "edge_only"),
  local_nbrs = 20L,
  landmark_count = 8L
)

Arguments

n

Number of vertices.

n.edges

Number of undirected edges, or NA if unknown.

pair_mode

Preparation mode: full paths, landmark paths, distances only, or edges only.

local_nbrs, landmark_count

Counts used by landmark preparation.

Value

A one-row data frame containing graph counts, pair mode, a pair-count upper bound, and the dense-distance storage lower bound in bytes and GiB.

Details

One dense double matrix needs 8 * n^2 bytes. Full and landmark preparations currently compute dense distances; landmark mode reduces retained pairs, not that matrix. Trees, routes, copies, R object overhead, and solver workspace require additional memory and are not estimated. Edge-only preparation has no dense distance matrix, but still stores the graph. Use prepare.edge.kk() when only edge constraints are needed, or ordinary grip() when a full geodesic cache is unnecessary.

Dense preparation warns before its searches/allocations when this bound exceeds getOption("grip.preparation.warn.bytes", 512 * 1024^2). Set that option to another positive byte count, or Inf to acknowledge and disable the advisory warning. It is not a hard memory limit. Small calls are quiet. Native refinement checks for cancellation between rounds or optimizer evaluations; worker threads finish an evaluation before interruption is raised on the main thread. Cancellation does not return a partial fit.

Examples

estimate.preparation(10000, n.edges = 20000)
#>   n.vertices n.edges pair.mode pair.count.upper.bound
#> 1      10000   20000 all_pairs               49995000
#>   dense.distance.bytes.lower.bound dense.distance.GiB.lower.bound
#> 1                            8e+08                      0.7450581
estimate.preparation(10000, n.edges = 20000, pair_mode = "edge_only")
#>   n.vertices n.edges pair.mode pair.count.upper.bound
#> 1      10000   20000 edge_only                      0
#>   dense.distance.bytes.lower.bound dense.distance.GiB.lower.bound
#> 1                                0                              0