| graph_components | R Documentation |
Class representing connected components of a metric graph.
A list of metric_graph objects (representing the different
connected components in the full graph) created from vertex and edge matrices,
or from an sp::SpatialLines object where each line is representing and edge.
For more details, see the vignette:
vignette("metric_graph", package = "MetricGraph")
Object of R6Class for creating metric graph components.
graphsList of the graphs representing the connected components.
nThe number of graphs.
sizesNumber of vertices for each of the graphs.
lengthsTotal edge lengths for each of the graphs. Create metric graphs for connected components
new()graph_components$new( edges = NULL, V = NULL, E = NULL, by_length = TRUE, edge_weights = NULL, ..., lines = deprecated() )
edgesA list containing coordinates as m x 2 matrices (that is, of matrix type) or m x 2 data frames (data.frame type) of sequence of points connected by straightlines. Alternatively, you can also prove an object of type SpatialLinesDataFrame or SpatialLines (from sp package) or MULTILINESTRING (from sf package).
Vn x 2 matrix with Euclidean coordinates of the n vertices.
Em x 2 matrix where each row represents an edge.
by_lengthSort the components by total edge length? If FALSE,
the components are sorted by the number of vertices.
edge_weightsEither a number, a numerical vector with length given by the number of edges, providing the edge weights, or a data.frame with the number of rows being equal to the number of edges, where
...Additional arguments used when specifying the graphs
linesvertex_unitThe unit in which the vertices are specified. The options are 'degree' (the great circle distance in km), 'km', 'm' and 'miles'. The default is NULL, which means no unit. However, if you set length_unit, you need to set vertex_unit.
length_unitThe unit in which the lengths will be computed. The options are 'km', 'm' and 'miles'. The default is vertex_unit. Observe that if vertex_unit is NULL, length_unit can only be NULL.
If vertex_unit is 'degree', then the default value for length_unit is 'km'.
longlatIf TRUE, then it is assumed that the coordinates are given.
in Longitude/Latitude and that distances should be computed in meters. It takes precedence over
vertex_unit and length_unit, and is equivalent to vertex_unit = 'degree' and length_unit = 'm'.
toleranceVertices that are closer than this number are merged when
constructing the graph (default = 1e-10). If longlat = TRUE, the
tolerance is given in km.
A graph_components object.
get_largest()Returns the largest component in the graph.
graph_components$get_largest()
A metric_graph object.
plot()Plots all components.
graph_components$plot(edge_colors = NULL, vertex_colors = NULL, ...)
edge_colorsA 3 x nc matrix with RGB values for the edge colors to be used when plotting each graph.
vertex_colorsA 3 x nc matrix with RGB values for the edge colors to be used when plotting each graph.
...Additional arguments for plotting the individual graphs.
A ggplot object.
clone()The objects of this class are cloneable with this method.
graph_components$clone(deep = FALSE)
deepWhether to make a deep clone.
library(sp)
edge1 <- rbind(c(0, 0), c(1, 0))
edge2 <- rbind(c(1, 0), c(2, 0))
edge3 <- rbind(c(1, 1), c(2, 1))
edges <- list(edge1, edge2, edge3)
graphs <- graph_components$new(edges)
graphs$plot()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.