forked from JuliaGraphs/Graphs.jl
-
Notifications
You must be signed in to change notification settings - Fork 0
/
runtests.jl
171 lines (158 loc) · 4.31 KB
/
runtests.jl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
using Aqua
using Documenter
using Graphs
using Graphs.SimpleGraphs
using Graphs.Experimental
using JET
using JuliaFormatter
using Graphs.Test
using Test
using SparseArrays
using LinearAlgebra
using Compat
using DelimitedFiles
using Base64
using Random
using Statistics: mean, std
using StableRNGs
using Pkg
const testdir = dirname(@__FILE__)
function get_pkg_version(name::AbstractString)
for dep in values(Pkg.dependencies())
if dep.name == name
return dep.version
end
end
return error("Dependency not available")
end
@testset "Code quality (JET.jl)" begin
if VERSION >= v"1.9"
@assert get_pkg_version("JET") >= v"0.8.4"
JET.test_package(
Graphs; target_defined_modules=true, ignore_missing_comparison=true
)
end
end
@testset verbose = true "Code quality (Aqua.jl)" begin
Aqua.test_all(Graphs; ambiguities=false)
end
@testset verbose = true "Code formatting (JuliaFormatter.jl)" begin
@test format(Graphs; verbose=false, overwrite=false)
end
doctest(Graphs)
function testgraphs(g)
return if is_directed(g)
[g, DiGraph{UInt8}(g), DiGraph{Int16}(g)]
else
[g, Graph{UInt8}(g), Graph{Int16}(g)]
end
end
testgraphs(gs...) = vcat((testgraphs(g) for g in gs)...)
testdigraphs = testgraphs
# some operations will create a large graph from two smaller graphs. We
# might error out on very small eltypes.
function testlargegraphs(g)
return if is_directed(g)
[g, DiGraph{UInt16}(g), DiGraph{Int32}(g)]
else
[g, Graph{UInt16}(g), Graph{Int32}(g)]
end
end
testlargegraphs(gs...) = vcat((testlargegraphs(g) for g in gs)...)
function test_generic_graphs(g; eltypes=[UInt8, Int16], skip_if_too_large::Bool=false)
SG = is_directed(g) ? SimpleDiGraph : SimpleGraph
GG = is_directed(g) ? GenericDiGraph : GenericGraph
result = GG[]
for T in eltypes
if skip_if_too_large && nv(g) > typemax(T)
continue
end
push!(result, GG(SG{T}(g)))
end
return result
end
function test_generic_graphs(gs...; kwargs...)
return vcat((test_generic_graphs(g; kwargs...) for g in gs)...)
end
function test_large_generic_graphs(g; skip_if_too_large::Bool=false)
return test_generic_graphs(
g; eltypes=[UInt16, Int32], skip_if_too_large=skip_if_too_large
)
end
tests = [
"simplegraphs/runtests",
"linalg/runtests",
"parallel/runtests",
"interface",
"core",
"operators",
"degeneracy",
"distance",
"digraph/transitivity",
"cycles/hawick-james",
"cycles/johnson",
"cycles/karp",
"cycles/basis",
"cycles/limited_length",
"cycles/incremental",
"edit_distance",
"connectivity",
"persistence/persistence",
"shortestpaths/astar",
"shortestpaths/bellman-ford",
"shortestpaths/desopo-pape",
"shortestpaths/dijkstra",
"shortestpaths/johnson",
"shortestpaths/floyd-warshall",
"shortestpaths/yen",
"shortestpaths/spfa",
"traversals/bfs",
"traversals/bipartition",
"traversals/greedy_color",
"traversals/dfs",
"traversals/maxadjvisit",
"traversals/randomwalks",
"traversals/diffusion",
"traversals/eulerian",
"community/cliques",
"community/core-periphery",
"community/label_propagation",
"community/modularity",
"community/clustering",
"community/clique_percolation",
"community/assortativity",
"community/rich_club",
"centrality/betweenness",
"centrality/closeness",
"centrality/degree",
"centrality/katz",
"centrality/pagerank",
"centrality/eigenvector",
"centrality/stress",
"centrality/radiality",
"utils",
"deprecations",
"spanningtrees/boruvka",
"spanningtrees/kruskal",
"spanningtrees/prim",
"steinertree/steiner_tree",
"biconnectivity/articulation",
"biconnectivity/biconnect",
"biconnectivity/bridge",
"graphcut/normalized_cut",
"graphcut/karger_min_cut",
"dominatingset/degree_dom_set",
"dominatingset/minimal_dom_set",
"independentset/degree_ind_set",
"independentset/maximal_ind_set",
"vertexcover/degree_vertex_cover",
"vertexcover/random_vertex_cover",
"trees/prufer",
"experimental/experimental",
]
@testset verbose = true "Graphs" begin
for t in tests
tp = joinpath(testdir, "$(t).jl")
include(tp)
end
end;