|
5 | 5 | m = n * (n - 1) / 2
|
6 | 6 | c = ones(Int, n)
|
7 | 7 | gint = complete_graph(n)
|
8 |
| - for g in testgraphs(gint) |
| 8 | + for g in test_generic_graphs(gint) |
9 | 9 | @test @inferred(modularity(g, c)) == 0
|
10 | 10 | end
|
11 | 11 |
|
12 | 12 | gint = SimpleGraph(n)
|
13 |
| - for g in testgraphs(gint) |
| 13 | + for g in test_generic_graphs(gint) |
14 | 14 | @test @inferred(modularity(g, c)) == 0
|
15 | 15 | end
|
16 | 16 |
|
17 |
| - barbell = blockdiag(complete_graph(3), complete_graph(3)) |
18 |
| - add_edge!(barbell, 1, 4) |
| 17 | + barbell = barbell_graph(3, 3) |
19 | 18 | c = [1, 1, 1, 2, 2, 2]
|
20 | 19 |
|
21 |
| - for g in testgraphs(barbell) |
| 20 | + for g in test_generic_graphs(barbell) |
22 | 21 | Q1 = @inferred(modularity(g, c))
|
23 | 22 | @test isapprox(Q1, 0.35714285714285715, atol=1e-3)
|
24 | 23 | Q2 = @inferred(modularity(g, c, γ=0.5))
|
|
35 | 34 | add_edge!(barbell, 1, 4)
|
36 | 35 | c = [1, 1, 1, 2, 2, 2]
|
37 | 36 |
|
38 |
| - for g in testdigraphs(barbell) |
| 37 | + for g in test_generic_graphs(barbell) |
39 | 38 | Q1 = @inferred(modularity(g, c))
|
40 | 39 | @test isapprox(Q1, 0.3673469387755103, atol=1e-3)
|
41 | 40 |
|
|
44 | 43 | end
|
45 | 44 |
|
46 | 45 | add_edge!(barbell, 4, 1)
|
47 |
| - for g in testdigraphs(barbell) |
| 46 | + for g in test_generic_graphs(barbell) |
48 | 47 | @test @inferred(modularity(g, c)) == 0.25
|
49 | 48 | end
|
50 | 49 |
|
51 | 50 | # 3. weighted test cases
|
52 | 51 | # 3.1. undirected and weighted test cases
|
53 |
| - triangle = SimpleGraph(3) |
54 |
| - add_edge!(triangle, 1, 2) |
55 |
| - add_edge!(triangle, 2, 3) |
56 |
| - add_edge!(triangle, 3, 1) |
57 | 52 |
|
58 |
| - barbell = blockdiag(triangle, triangle) |
59 |
| - add_edge!(barbell, 1, 4) # this edge has a weight of 5 |
| 53 | + # the "handle" of the barbell 3--4 gets a weight of 5 |
| 54 | + barbell = barbell_graph(3, 3) |
60 | 55 | c = [1, 1, 1, 2, 2, 2]
|
61 | 56 | d = [
|
62 |
| - [0 1 1 5 0 0] |
| 57 | + [0 1 1 0 0 0] |
63 | 58 | [1 0 1 0 0 0]
|
64 |
| - [1 1 0 0 0 0] |
65 |
| - [5 0 0 0 1 1] |
| 59 | + [1 1 0 5 0 0] |
| 60 | + [0 0 5 0 1 1] |
66 | 61 | [0 0 0 1 0 1]
|
67 | 62 | [0 0 0 1 1 0]
|
68 | 63 | ]
|
69 |
| - for g in testgraphs(barbell) |
| 64 | + for g in test_generic_graphs(barbell) |
70 | 65 | Q = @inferred(modularity(g, c, distmx=d))
|
71 | 66 | @test isapprox(Q, 0.045454545454545456, atol=1e-3)
|
72 | 67 | end
|
|
88 | 83 | [0 0 0 0 0 1]
|
89 | 84 | [0 0 0 1 0 0]
|
90 | 85 | ]
|
91 |
| - for g in testdigraphs(barbell) |
| 86 | + for g in test_generic_graphs(barbell) |
92 | 87 | Q = @inferred(modularity(g, c, distmx=d))
|
93 | 88 | @test isapprox(Q, 0.1487603305785124, atol=1e-3)
|
94 | 89 | end
|
|
0 commit comments