Skip to contents

This function breaks a (U,W) mixture graph into a dense and sparse component.

Usage

separate_dense_and_sparse(grmix)

Arguments

grmix

The input graph

Value

a list with the following components:

gr_dense

The dense component.

gr_sparse

The sparse component.

data

The original graph.

Examples

library(igraph)
W <- matrix(0.1, nrow = 100, ncol = 100)
wts <- c(0.5, 0.3, 0.2)
ns <- 200
nd <- 100
p <- 0.5
gr <- sample_mixed_graph(W, wts, nd, ns, p = 0.1, option = 2)
out <- separate_dense_and_sparse(gr)
out
#> $dense_part
#> IGRAPH 1b88483 U--- 88 454 -- Star
#> + attr: name_1 (g/c), name_2 (g/c), mode_1 (g/c), mode_2 (g/c),
#> | center_1 (g/n), center_2 (g/n), name (g/c), mode (g/c), center (g/n)
#> + edges from 1b88483:
#>  [1]  1-- 4  1-- 8  2-- 8  5--11  8--13  2--14  8--14  6--15  4--16  8--16
#> [11]  9--16 10--16  5--17  7--17 13--17 15--17  6--18 13--18 13--19  1--22
#> [21] 12--22  9--23 10--23 11--23  3--25 15--25 18--25 24--25  3--26 20--26
#> [31]  2--27  8--27 11--27 11--28 15--28 17--28 11--29 13--29  7--30 25--30
#> [41] 16--31 18--31 20--31 24--31  7--32 30--32  6--33  7--33 12--33 19--33
#> [51] 21--33 27--33 28--33  2--34 15--34 22--34 28--34 11--35 13--35 22--35
#> [61] 23--35 27--35 33--35  7--36  8--36 17--36 18--36 19--36 22--36 26--36
#> + ... omitted several edges
#> 
#> $sparse_part
#> IGRAPH d980da9 U--- 197 194 -- Star
#> + attr: name_1 (g/c), name_2 (g/c), mode_1 (g/c), mode_2 (g/c),
#> | center_1 (g/n), center_2 (g/n), name (g/c), mode (g/c), center (g/n)
#> + edges from d980da9:
#>  [1] 1-- 2 1-- 3 1-- 4 1-- 5 1-- 6 1-- 7 1-- 8 1-- 9 1--10 1--11 1--12 1--13
#> [13] 1--14 1--15 1--16 1--17 1--18 1--19 1--20 1--21 1--22 1--23 1--24 1--25
#> [25] 1--26 1--27 1--28 1--29 1--30 1--31 1--32 1--33 1--34 1--35 1--36 1--37
#> [37] 1--38 1--39 1--40 1--41 1--42 1--43 1--44 1--45 1--46 1--47 1--48 1--49
#> [49] 1--50 1--51 1--52 1--53 1--54 1--55 1--56 1--57 1--58 1--59 1--60 1--61
#> [61] 1--62 1--63 1--64 1--65 1--66 1--67 1--68 1--69 1--70 1--71 1--72 1--73
#> [73] 1--74 1--75 1--76 1--77 1--78 1--79 1--80 1--81 1--82 1--83 1--84 1--85
#> + ... omitted several edges
#> 
#> $data
#> IGRAPH 1e7dee0 U--- 300 751 -- Star
#> + attr: name_1 (g/c), name_2 (g/c), mode_1 (g/c), mode_2 (g/c),
#> | center_1 (g/n), center_2 (g/n), name (g/c), mode (g/c), center (g/n)
#> + edges from 1e7dee0:
#>  [1] 1--  4 1--  9 1-- 24 1-- 40 1-- 46 1-- 63 1-- 64 1-- 74 1-- 76 1-- 83
#> [11] 1-- 91 1--283 2--  5 2--  9 2-- 15 2-- 29 2-- 37 2-- 49 2-- 50 2-- 51
#> [21] 2-- 66 2-- 73 2-- 76 2-- 78 3-- 27 3-- 28 3-- 45 3-- 57 3-- 60 3-- 67
#> [31] 3-- 86 3-- 88 3-- 89 3-- 90 4-- 17 4-- 32 4-- 68 4-- 76 4-- 89 4-- 94
#> [41] 5-- 64 5-- 90 5-- 93 6-- 12 6-- 18 6-- 42 6-- 69 6-- 74 6-- 78 6-- 89
#> [51] 6-- 97 6-- 98 7-- 16 7-- 19 7-- 36 7-- 52 7-- 54 7-- 55 7-- 57 7-- 60
#> [61] 7-- 69 7-- 89 7-- 97 8-- 18 8-- 23 8-- 33 8-- 35 8-- 36 8-- 39 8-- 65
#> + ... omitted several edges
#> 
#> $fitlines
#> $fitlines$num_hubs
#> [1] 3
#> 
#> $fitlines$dense_limit
#> [1] 16
#> 
#> $fitlines$cutoffs
#> [1]  3 16
#> 
#> $fitlines$segment_sizes
#> [1]  3 13  6
#> 
#> $fitlines$elbow_points
#> [1]  3 16
#> 
#> $fitlines$line_equations
#> [1] "y = -0.4508 * x + 5.0481" "y = -0.0709 * x + 3.3875"
#> [3] "y = -0.1933 * x + 5.4212"
#> 
#> $fitlines$models
#> $fitlines$models[[1]]
#> 
#> Call:
#> lm(formula = y ~ x, data = df[1:i, ])
#> 
#> Coefficients:
#> (Intercept)            x  
#>      5.0481      -0.4508  
#> 
#> 
#> $fitlines$models[[2]]
#> 
#> Call:
#> lm(formula = y ~ x, data = df[(i + 1):j, ])
#> 
#> Coefficients:
#> (Intercept)            x  
#>     3.38748     -0.07089  
#> 
#> 
#> $fitlines$models[[3]]
#> 
#> Call:
#> lm(formula = y ~ x, data = df[(j + 1):n, ])
#> 
#> Coefficients:
#> (Intercept)            x  
#>      5.4212      -0.1933  
#> 
#> 
#> 
#> $fitlines$mse
#> [1] 0.001114272
#> 
#> $fitlines$data
#>     x        y
#> 1   1 4.615121
#> 2   2 4.110874
#> 3   3 3.713572
#> 4   4 3.091042
#> 5   5 2.995732
#> 6   6 2.944439
#> 7   7 2.890372
#> 8   8 2.833213
#> 9   9 2.772589
#> 10 10 2.708050
#> 11 11 2.639057
#> 12 12 2.564949
#> 13 13 2.484907
#> 14 14 2.397895
#> 15 15 2.302585
#> 16 16 2.197225
#> 17 17 2.079442
#> 18 18 1.945910
#> 19 19 1.791759
#> 20 20 1.609438
#> 21 21 1.386294
#> 22 22 1.098612
#> 
#> $fitlines$phat
#> [1] 0.5025381 0.2994924 0.1979695
#> 
#> $fitlines$dense_part
#> IGRAPH 6f7bcc6 U--- 88 454 -- Star
#> + attr: name_1 (g/c), name_2 (g/c), mode_1 (g/c), mode_2 (g/c),
#> | center_1 (g/n), center_2 (g/n), name (g/c), mode (g/c), center (g/n)
#> + edges from 6f7bcc6:
#>  [1]  1-- 4  1-- 8  2-- 8  5--11  8--13  2--14  8--14  6--15  4--16  8--16
#> [11]  9--16 10--16  5--17  7--17 13--17 15--17  6--18 13--18 13--19  1--22
#> [21] 12--22  9--23 10--23 11--23  3--25 15--25 18--25 24--25  3--26 20--26
#> [31]  2--27  8--27 11--27 11--28 15--28 17--28 11--29 13--29  7--30 25--30
#> [41] 16--31 18--31 20--31 24--31  7--32 30--32  6--33  7--33 12--33 19--33
#> [51] 21--33 27--33 28--33  2--34 15--34 22--34 28--34 11--35 13--35 22--35
#> [61] 23--35 27--35 33--35  7--36  8--36 17--36 18--36 19--36 22--36 26--36
#> + ... omitted several edges
#> 
#> 
#> $call
#> separate_dense_and_sparse(grmix = gr)
#> 
#> attr(,"class")
#> [1] "separate_dense_and_sparse"