get_graph_stats: Get graph statistics

View source: R/get_graph_stats.R

get_graph_statsR Documentation

Get graph statistics

Description

For a given igraph or list of igraph objects, this function summarize the number of vertices/edges and other vertex attributes.

Usage

get_graph_stats(X)

Arguments

X

an 'igraph' or 'list.igraph' object

Value

It returns a long data.frame with number of nodes/edges, and the count of the different attributes (if X is a list of graph, each row describes a graph)

Examples

graph1 <- igraph::graph_from_data_frame(
    list(from = c('A', 'B', 'A', 'D', 'C', 'A', 'C'),
         to = c('B', 'C', 'D', 'E', 'D', 'F', 'G')), 
    directed = FALSE)
graph1 <- igraph::set_vertex_attr(graph = graph1, 
                                  name = 'type', 
                                  index = c('A','B','C'), 
                                  value = '1')
graph1 <- igraph::set_vertex_attr(graph = graph1, 
                                  name = 'type', 
                                  index = c('D','E'),
                                  value = '2')
graph1 <- igraph::set_vertex_attr(graph = graph1, 
                                  name = 'type', 
                                  index = c('F', 'G'),
                                  value = '-1')

get_graph_stats(graph1)

graph1.list <- list(graph1 = graph1, 
                    graph2 = graph1)
get_graph_stats(graph1.list)


abodein/netOmics documentation built on Oct. 20, 2024, 9:25 a.m.