R/n_vertices.R

Defines functions n_vertices.igraph n_vertices.matrix n_vertices

Documented in n_vertices n_vertices.igraph n_vertices.matrix

#' Count the number of edges in the graph
#'
#' A common interface for matrix and igraph representations of graph structure.
#'
#' @return Number of edges
n_vertices <- function(x) {
    UseMethod("n_vertices", x)
}

#' @rdname n_vertices
#' @param x An adjacency matrix
#' @export
n_vertices.matrix <- function(x) {
    return(nrow(x))
}

#' @rdname n_vertices
#' @param g An igraph object.
#' @export
n_vertices.igraph <- function(g) {
    return(igraph::vcount(g))
}
crcox/latticize documentation built on Dec. 19, 2021, 6:19 p.m.