Center the adjacency matrix by re-weighting edges according to a specified scheme
Usage
center_graph(A, scheme = c(-1, 1), use_splr = TRUE)
Arguments
- A
A matrix, an igraph object. Adjacency matrix.
- scheme
A character vector, number or pair of numbers. Default
c(-1, 1)
. See Details.- use_splr
A boolean indicating whether to use the splrMatrix object when storing the centered graph. Defaults to TRUE.
Value
centered adjacency matrix as a splrMatrix if useSplr = TRUE, otherwise as a Matrix object.
Details
The options for scheme are
"naive" Returns original A
Integer: Returns \(A - A_{scheme}\) where \(A_{scheme}\) is the best rank-scheme approximation of A.
A pair of scalars: Returns s * A + a such that the minimum of the returned matrix is min(scheme) and the maximum is max(scheme).
"center": Same as
scheme=c(-1,1)
Examples
A <- sample_correlated_gnp_pair(n = 10, corr = .5, p = .5)$graph1
center_graph(A, scheme = "naive")
#> 10 x 10 sparse Matrix of class "dgCMatrix"
#>
#> [1,] . 1 . 1 1 . 1 . . .
#> [2,] 1 . . . . . . 1 1 1
#> [3,] . . . 1 . 1 1 . . 1
#> [4,] 1 . 1 . . . 1 . 1 .
#> [5,] 1 . . . . . 1 1 . 1
#> [6,] . . 1 . . . . 1 . .
#> [7,] 1 . 1 1 1 . . 1 . 1
#> [8,] . 1 . . 1 1 1 . 1 1
#> [9,] . 1 . 1 . . . 1 . 1
#> [10,] . 1 1 . 1 . 1 1 1 .
center_graph(A, scheme = "center")
#> Sparse part
#> 10 x 10 sparse Matrix of class "dgCMatrix"
#>
#> [1,] . 2 . 2 2 . 2 . . .
#> [2,] 2 . . . . . . 2 2 2
#> [3,] . . . 2 . 2 2 . . 2
#> [4,] 2 . 2 . . . 2 . 2 .
#> [5,] 2 . . . . . 2 2 . 2
#> [6,] . . 2 . . . . 2 . .
#> [7,] 2 . 2 2 2 . . 2 . 2
#> [8,] . 2 . . 2 2 2 . 2 2
#> [9,] . 2 . 2 . . . 2 . 2
#> [10,] . 2 2 . 2 . 2 2 2 .
#> plus left factor
#> 10 x 1 Matrix of class "dgeMatrix"
#> [,1]
#> [1,] -1
#> [2,] -1
#> [3,] -1
#> [4,] -1
#> [5,] -1
#> [6,] -1
#> [7,] -1
#> [8,] -1
#> [9,] -1
#> [10,] -1
#> times right factor transpose
#> 10 x 1 Matrix of class "dgeMatrix"
#> [,1]
#> [1,] 1
#> [2,] 1
#> [3,] 1
#> [4,] 1
#> [5,] 1
#> [6,] 1
#> [7,] 1
#> [8,] 1
#> [9,] 1
#> [10,] 1
center_graph(A, scheme = 2)
#> Sparse part
#> 10 x 10 sparse Matrix of class "dgCMatrix"
#>
#> [1,] . 1 . 1 1 . 1 . . .
#> [2,] 1 . . . . . . 1 1 1
#> [3,] . . . 1 . 1 1 . . 1
#> [4,] 1 . 1 . . . 1 . 1 .
#> [5,] 1 . . . . . 1 1 . 1
#> [6,] . . 1 . . . . 1 . .
#> [7,] 1 . 1 1 1 . . 1 . 1
#> [8,] . 1 . . 1 1 1 . 1 1
#> [9,] . 1 . 1 . . . 1 . 1
#> [10,] . 1 1 . 1 . 1 1 1 .
#> plus left factor
#> 10 x 2 Matrix of class "dgeMatrix"
#> [,1] [,2]
#> [1,] -1.2808941 1.1728316
#> [2,] -1.3769099 -1.0474221
#> [3,] -1.2282543 0.6177946
#> [4,] -1.2326134 -0.2959305
#> [5,] -1.4954198 -0.7238267
#> [6,] -0.6573596 -0.7250464
#> [7,] -1.9264880 -0.9306699
#> [8,] -1.8670987 1.2354805
#> [9,] -1.3684526 -0.1035349
#> [10,] -1.9671018 0.3725154
#> times right factor transpose
#> 10 x 2 Matrix of class "dgeMatrix"
#> [,1] [,2]
#> [1,] 0.2720233 0.45884029
#> [2,] 0.2924141 -0.40977703
#> [3,] 0.2608442 0.24169631
#> [4,] 0.2617699 -0.11577521
#> [5,] 0.3175821 -0.28317864
#> [6,] 0.1396034 -0.28365580
#> [7,] 0.4091279 -0.36410074
#> [8,] 0.3965154 0.48335005
#> [9,] 0.2906181 -0.04050538
#> [10,] 0.4177531 0.14573711
center_graph(A, scheme = c(-4, 2))
#> Sparse part
#> 10 x 10 sparse Matrix of class "dgCMatrix"
#>
#> [1,] . 6 . 6 6 . 6 . . .
#> [2,] 6 . . . . . . 6 6 6
#> [3,] . . . 6 . 6 6 . . 6
#> [4,] 6 . 6 . . . 6 . 6 .
#> [5,] 6 . . . . . 6 6 . 6
#> [6,] . . 6 . . . . 6 . .
#> [7,] 6 . 6 6 6 . . 6 . 6
#> [8,] . 6 . . 6 6 6 . 6 6
#> [9,] . 6 . 6 . . . 6 . 6
#> [10,] . 6 6 . 6 . 6 6 6 .
#> plus left factor
#> 10 x 1 Matrix of class "dgeMatrix"
#> [,1]
#> [1,] -4
#> [2,] -4
#> [3,] -4
#> [4,] -4
#> [5,] -4
#> [6,] -4
#> [7,] -4
#> [8,] -4
#> [9,] -4
#> [10,] -4
#> times right factor transpose
#> 10 x 1 Matrix of class "dgeMatrix"
#> [,1]
#> [1,] 1
#> [2,] 1
#> [3,] 1
#> [4,] 1
#> [5,] 1
#> [6,] 1
#> [7,] 1
#> [8,] 1
#> [9,] 1
#> [10,] 1