Network summary plots
violin_netsummary.Rd
Draw a network summary plot proposed by Maugis et al. (2017). To count k-cycles, Alon et al. (1997) is used.
Usage
violin_netsummary(
A,
subsample_sizes = NA,
max_cycle_order = 4,
R = NA,
Ns = 11,
alpha = 0.05,
y.max = NA,
save.plot = FALSE,
filename = "myplot.pdf"
)
Arguments
- A
an adjacency matrix or igraph object to draw a network summary plot. It must be an undirected and simple graph.
- subsample_sizes
a numeric vector of node subsample sizes. If
NA
, a lengthNs
vector is obtained from the automatic subsample size selection.- max_cycle_order
an integer value of the maximum cycle size. Must be
>=3
and<=7
.- R
an integer value of subsampling replication. If
NA
,R
is automatically selected byalpha
.- Ns
number of different subsample sizes. It is only used when
subsample_sizes = NA
, that is, when automatic subsample size selection is used.- alpha
a pre-specified level used in determining
R
andsubsample_sizes
when they are not specified. It must be in (0,1). Default is 0.05. Smalleralpha
gives largerR
andsubsample_sizes
.- y.max
Upper limit of y-axis of the plot. Must be 0 <
y.max
<= 1. IfNA
, the upper limit is automatically selected.- save.plot
logical variable whether save the generated figure or not. If
TRUE
, the plot is saved byggplot2::ggsave()
in the specified file name. Otherwise, display the generated plot.- filename
file name to save the generated figure.
Details
Vertex sampling is done by simple random sampling without replacement.
Following matrix classes are supported: base::matrix, Matrix::dgCMatrix
References
Maugis et al. (2017). Topology reveals universal features for network comparison. arXiv: 1705.05677
Alon et al. (1997). Finding and counting given length cycles. Algorithmica 17, 209–223 (1997). https://doi.org/10.1007/BF02523189
Examples
if (FALSE) {
set.seed(2022)
#Generating Erdos-Renyi graph
n <- 400
#igraph object
A <- igraph::sample_gnp(n, 0.05)
violin_netsummary(A)
#sparse adjacency matrix
A2 <- igraph::as_adj(A)
violin_netsummary(A2)
#dense adjacency matrix
A2 <- igraph::as_adj(A, sparse = FALSE)
violin_netsummary(A2)
#user-specified R and subsample_sizes
violin_netsummary(A, R = 500, subsample_sizes = 150)
#user-specified alpha
violin_netsummary(A, alpha = 0.1)
#saving the plot with user-specified file name
violin_netsummary(A, save.plot = TRUE, filename = "myfig.pdf")
}