Skip to contents

This function tests if a set of nodes form a connected set on a gGraph object.

Usage

areConnected(x, nodes)

Arguments

x

a gGraph object

nodes

a vector of node names

Value

a single logical value, being TRUE if nodes form a connected set.

Details

@details This function is very similar to isConnected(), but it allows the user to specify a subset of nodes to test for connectivity, whereas isConnected() tests if all nodes in the object form a connected set. Note that isConnected() is a method for both gGraph and gData objects, whereas areConnected() is only a method for gGraph objects.

This is an implementation of the graph::isConnected() function for data classes in geoGraph.

See also

Examples

# create a small square graph
test_graph <- makeSquareGrid(25, lon.range = c(1, 5), lat.range = c(1, 5))
# test that the function correctly identifies connected sets
# 1, 9, and 10 are connected
areConnected(test_graph, nodes = c("1", "9", "10"))
#> [1] TRUE
# even though they are not neighbours
areNeighbours(V1 = "1", V2 = "9", graph = test_graph)
#>  1->9 
#> FALSE 
areNeighbours(V1 = "1", V2 = "10", graph = test_graph)
#> 1->10 
#> FALSE