Count the number of vertices/edges/slices in a graph

nvertices(graph)

nnodes(graph)

nedges(graph)

nlinks(graph)

nslices(graph)

Arguments

graph

Any class of accepted graph format (see netdiffuseR-graphs).

Value

For nvertices and nslices, an integer scalar equal to the number of vertices and slices in the graph. Otherwise, from nedges, either a list of size \(t\) with the counts of edges (non-zero elements in the adjacency matrices) at each time period, or, when graph is static, a single scalar with such number.

Details

nnodes and nlinks are just aliases for nvertices and nedges respectively.

Examples

# Creating a dynamic graph (we will use this for all the classes) ----------- set.seed(13133) diffnet <- rdiffnet(100, 4) # Lets use the first time period as a static graph graph_mat <- diffnet$graph[[1]] graph_dgCMatrix <- methods::as(graph_mat, "dgCMatrix") # Now lets generate the other dynamic graphs graph_list <- diffnet$graph graph_array <- as.array(diffnet) # using the as.array method for diffnet objects # Now we can compare vertices counts nvertices(diffnet)
#> [1] 100
nvertices(graph_list)
#> [1] 100
nvertices(graph_array)
#> [1] 100
nvertices(graph_mat)
#> [1] 100
nvertices(graph_dgCMatrix)
#> [1] 100
# ... and edges count nedges(diffnet)
#> $`1` #> [1] 100 #> #> $`2` #> [1] 100 #> #> $`3` #> [1] 100 #> #> $`4` #> [1] 100 #>
nedges(graph_list)
#> $`1` #> [1] 100 #> #> $`2` #> [1] 100 #> #> $`3` #> [1] 100 #> #> $`4` #> [1] 100 #>
nedges(graph_array)
#> $`1` #> [1] 100 #> #> $`2` #> [1] 100 #> #> $`3` #> [1] 100 #> #> $`4` #> [1] 100 #>
nedges(graph_mat)
#> [1] 100
nedges(graph_dgCMatrix)
#> [1] 100