Fixed compute_geodist_PtE() failing with "subscript out of bounds" when
the points contained duplicates or locations that coincide on the graph (for
instance, the end of one edge and the start of the next). The distances are
now computed directly, and the returned matrix has one row and column per
input point, in the input order, duplicates included (#20).
Fixed likelihood_graph_laplacian() failing with "non-conformable matrix
dimensions" whenever the data had more than one replicate.
Removed the per-replicate scans in the likelihood, cross-validation and INLA data paths, which located the rows of each replicate by testing the group column against it inside the loop.
add_observations() is now much faster with many replicates. Row indices are
now built in one pass and the row-wise quantities computed once.
process_data_add_obs() also stopped identifying locations and (location, group)
pairs by pasted character keys, the same information is now encoded as integers
by sorting.
Fixed add_observations() failing with "has a different number of elements
than the number of coordinates" when the grouping variable contained NA.
Such rows are now kept, with NA as their group.
The likelihood functions no longer locate the rows of each replicate with
repl_vec == curr_repl inside the loop over replicates, which rescanned
every observation once per replicate.
Fixed the vertex-to-edge snapping in metric_graph$new(), which decided
whether to split an edge by comparing a position normalized to [0, 1]
against tolerance$vertex_edge, which is a length. The verdict therefore
depended on the edge length: junctions on long edges were missed, and the
same graph rebuilt from its own edges could gain edges. add_vertices() now
compares both quantities as lengths.
Fixed add_vertices() splitting the wrong edge. Splits were applied one at a
time, with each one chained off self$nE; if a split was skipped, self$nE
was an unrelated edge and that edge was split instead. All positions accepted
for an edge are now passed to split_edge() in a single call.
Vertex-to-edge snapping is now repeated until it stops finding work (at most
10 rounds). A single sweep builds its candidate set before any edge is
split, so the vertices and sub-edges the sweep itself creates were never
tested. Over 160 randomly generated graphs the number of junctions within
vertex_edge that should have been split but were not fell from 532 to 23.
fetch_osm() and metric_graph_from_osm() retry transient Overpass failures
(HTTP 429/5xx and connection errors) with exponential backoff, controlled by
the new retries argument, and endpoint may now be a vector of mirrors
tried in order. A failed download no longer leaves the error page behind at
cache_path.
posterior_crossvalidation() is now the S3 generic from rSPDE, re-exported by
MetricGraph, which provides the graph_lme method. Loading rSPDE after
MetricGraph therefore no longer masks MetricGraph's version, and a list of
models may mix graph_lme and rspde_lme fits. Requires rSPDE >= 2.6.0.9001.
Graph construction no longer materializes dense point-by-edge matrices.
metric_graph$new() used to densify the st_is_within_distance() result
into an nEdges x nVertices logical matrix before snapping vertices to
nearby edges, and snapPointsToLines() (used by add_observations() with
data_coords = "spatial", coordinates() and which_component()) built a
full nPoints x nEdges distance matrix. Both are now replaced by sparse
candidate sets and C++ kernels (snap_points_to_edges_cpp() and a
grid-indexed nearest_edge_cpp()), which return the same graphs and the same
snapped locations.
The edge-edge intersection search (tolerance$edge_edge > 0) also keeps its
neighbour list sparse instead of building an nEdges x nEdges logical matrix.
Edge weights are no longer copied once per edge split. add_vertices() now
records which weight row each new edge inherits and materializes the weight
table once, instead of rbind-ing the whole table inside every
split_edge() call. set_edge_weights() builds the per-edge weight rows
without a [.data.frame call per edge. The values are unchanged but row names
of weight rows duplicated by a split are now e.g. "990509915.1" rather than
"9905099151".
prune_vertices() no longer pays a [.data.frame call per edge when
rebuilding the edge attributes, and the serial fallback for closed-loop
chains compacts the weight table once instead of once per removed vertex.
Added metric_graph$get_largest(), which returns only the largest connected
component. It is equivalent to get_components()[[1]] but constructs just
that component.
Added a mirrored closed-form directional OU covariance fast path for out-trees, including direction-reversed K1 continuity graphs. Reversed river networks now share the K1/K2 C++ pairwise kernel, using a cached Euler/RMQ LCA index and source-normalized transfers instead of allocating R objects or walking parent chains for every covariance pair.
Added C++-backed directional alpha-1 edge precision and closed-form directional OU covariance calculations. The C++ paths are now the default, with pure-R reference implementations retained for validation and fallback.
Added a packaged-data Mid-Columbia speed example covering K1, K2, reversed-continuity and covariance likelihood evaluation.
Fixed a sign-convention inconsistency in the exact α = 2 codes. The
observation-/bridge-side covariance blocks treated the
endpoint-derivative states as −u′, while the prior precision (Q00 /
Qalpha2) and the vertex constraints used +u′. Because both enter the same
quadratic forms, α = 2 covariances, likelihoods, posteriors and exact samples
were biased on graphs containing cycles.
Fixed the same α = 2 sign-convention bug in the profiled-likelihood (v2)
code path (profile_lik_core_alpha2 in R/graph_likelihoods_v2.R), which
had reimplemented the affected S-matrix construction independently and was
not covered by the fix above.
Added simulate.metric_graph() S3 method and simulate_parallel() for
unconditional prior simulation of Whittle-Matérn fields: Method A (method = "direct",
O(m³) per edge), Method B (method = "kriging", O(m) per edge), and the extended method
(method = "extended", single sparse Cholesky on the graph with simulation
locations promoted to vertices). Both α = 1 and α = 2 are supported.
C++ (Rcpp/Eigen) implementations of the per-edge bridge draws,
draw_edge_direct_cpp and draw_edge_kriging_cpp, are now the default
(impl = "cpp"); the pure-R reference implementations remain available via
impl = "R".
Updated examples/fast_simulation/run_study.R with warm-up iterations,
n_rep = 5 medians, extended n_pts sweep {8,...,2048}, and all three
simulation methods.
Added examples/fast_simulation/benchmark.R for per-edge R vs C++ speedup
and whole-field method comparison.
metric_graph now fully supports disconnected graphs, and graph_components
has therefore been deprecated.cross_validation() function for inlabru fits on metric
graphs, mirroring rSPDE::cross_validation().rSPDE version to 2.5.0 and added rlang to Imports.inla and inlabru models.precompute_lgcp_graph() to precompute expensive quantities for LGCP models.update_graph() method to update graph objects to newer versions of the package.observations_to_vertex method.fem_basis computation to C for improved performance.graph_lme.graph_lgcp_sim() and lgcp_graph() man pages.graph_lme.parallel option to posterior_crossvalidation.INLA interface for LGCP processes on metric graphs.add_observations() and plot_function() methods.stlnpp objects.alpha=2.R-INLA and inlabru, and updated the graph_spde_data() function for such cases.SSN, osmdata_sp and osmdata_sf objects. In such cases, if available, edge weights and data will be automatically added to the graph.SpatialLinesDataFrame, LINESTRING, MULTILINESTRING, etc., if the object contain edge data, they will be automatically added as edge weights.prune_vertices now has an option to avoid creating circles when pruning.export() method, that allows one to export a MetricGraph object as an sf, sp or SSN2 object.leaflet and mapview as methods.get_edges() and get_vertices() methods were created, that return the edges and vertices, respectively, in either 'sf', 'sp' or the internal formats.format to the get_data() method that allows one to also return the data in sf or sp formats.plot method now has an argument type, that now also allows one to set type to mapview, thus it can return ggplot2, plotly and mapview objects.mutate_weight, select_weights, filter_weights, summarise_weights and drop_na_weights. They have a format argument that allows one to also return sf or sp objects.mutate, filter, select, drop_na and summarise to have a format argument to also return sf or sp objects.observation_to_vertex method.improve_plot option, as now all plots from plot_function() method are improved.merge_strategy option for add_observations() method, for handling observations that are very close.alpha=2, and for building directional constraints.add_observations() for situations where observations are projected at the same location, specifically for the duplicated_strategy argument.simulate method was added for graph_lme objects.Spoints argument in add_observations() has been deprecated. Now, SpatialPointsDataFrame can be added directly in the data argument.sf objects containing data can also be directly added using the add_observations() method in the data argument.graph_lme object to provide starting values when fitting a model using graph_lme() was added.alpha=1 when using graph_lme() was added.kirchhoff_weights argument was added to obtain weights for Kirchhoff vertex conditions from edge_weights.edgeweight_to_data() method was added to turn edge weights into data in the internal metric graph format.edge_weight and edge_width_weight were added to the plot() method so that plots on metric graphs can be produced with the weights providing colors to the edges, and also with (possibly different) weights providing the thickness of the edges.edge_weights were added to graph_components so that the connected components will have the correct corresponding edge weights.edge_weight and edge_width_weight were added to the plot_function() method, where they work in a similar manner to their counterparts for the plot() method. The difference is that the weights are plotted as piecewise constant functions.prune_vertices now has an option to not prune vertices whose edges have incompatible edge weights.plot method has an interactive argument that returns the 2D plot as a plotly object, which is interactive when using ggplotly.viridis package has been removed.data to newdata in predict methods. The argument data was deprecated.vertex_unit and length_unit on graph creations. Units are given in edge lengths with the get_edge_lengths() method.SpatialLines, SpatialLinesDataFrames or MULTILINESTRING.sf package or sp package) for handling longlat by using the which_longlat option.crs (if using sf) and proj4string (if using sp) for handling general coordinate reference systems.data to the private environment.mesh_A() has been deprecated, use fem_basis() instead.plot() method with the option plotly=TRUE.plot_function() method to accept data and newdata.process_data() method for metric graphsget_groups() to get the unique groups, and also to retrieve the columns that were used to create the group variable.get_data() method to get the data in a user-friendly manner.glance() and augment() methods for graph_lme() objects.get_vertices_incomp_dir() method to return vertices with incompatible directions.print(), summary(), compute_characteristics(), check_euclidean(), check_distance_consistency() methods.vertices element in the metric graph object, containing information such as degrees, indegrees, outdegrees.print methods for edges, vertices, and for their entries.improve_plot option on plot_function.plot_function().