diff --git a/Project.toml b/Project.toml index 5132f635d..0d3b64f09 100644 --- a/Project.toml +++ b/Project.toml @@ -20,7 +20,7 @@ ArnoldiMethod = "0.4" DataStructures = "0.17, 0.18" Documenter = "0.27" Inflate = "0.1.3" -JuliaFormatter = "1" +JuliaFormatter = "1, 2" SimpleTraits = "0.9" StableRNGs = "1" Statistics = "1" diff --git a/src/Experimental/Traversals/bfs.jl b/src/Experimental/Traversals/bfs.jl index 40b663fc9..267039fbf 100644 --- a/src/Experimental/Traversals/bfs.jl +++ b/src/Experimental/Traversals/bfs.jl @@ -1,4 +1,5 @@ -import Base.Sort, Base.Sort.Algorithm +using Base.Sort: Sort +using Base.Sort.Algorithm: Algorithm import Base: sort! struct NOOPSortAlg <: Base.Sort.Algorithm end diff --git a/src/Experimental/vf2.jl b/src/Experimental/vf2.jl index d4286fe4b..7b6efbc4e 100644 --- a/src/Experimental/vf2.jl +++ b/src/Experimental/vf2.jl @@ -489,7 +489,7 @@ function has_induced_subgraphisomorph( edge_relation::Union{Nothing,Function}=nothing, )::Bool result = false - callback(vmap) = (result = true; return false) + callback(vmap) = (result=true; return false) vf2( callback, g1, @@ -509,7 +509,7 @@ function has_subgraphisomorph( edge_relation::Union{Nothing,Function}=nothing, )::Bool result = false - callback(vmap) = (result = true; return false) + callback(vmap) = (result=true; return false) vf2( callback, g1, @@ -531,7 +531,7 @@ function has_isomorph( !could_have_isomorph(g1, g2) && return false result = false - callback(vmap) = (result = true; return false) + callback(vmap) = (result=true; return false) vf2( callback, g1, @@ -647,9 +647,6 @@ function all_subgraphisomorph( return ch end -#! format: off -# Turns off formatting from this point onwards - function all_isomorph( g1::AbstractGraph, g2::AbstractGraph, @@ -658,7 +655,7 @@ function all_isomorph( edge_relation::Union{Nothing,Function}=nothing, )::Channel{Vector{Tuple{eltype(g1),eltype(g2)}}} T = Vector{Tuple{eltype(g1),eltype(g2)}} - !could_have_isomorph(g1, g2) && return Channel(_ -> nothing, ctype = T) + !could_have_isomorph(g1, g2) && return Channel(_ -> nothing; ctype=T) make_callback(c) = vmap -> (put!(c, collect(zip(vmap, 1:length(vmap)))), return true) ch::Channel{T} = Channel(; ctype=T) do c vf2( @@ -672,6 +669,3 @@ function all_isomorph( end return ch end - -#! format: on -# Turns on formatting from this point onwards diff --git a/src/SimpleGraphs/generators/randgraphs.jl b/src/SimpleGraphs/generators/randgraphs.jl index 750e22b5a..0f2a04468 100644 --- a/src/SimpleGraphs/generators/randgraphs.jl +++ b/src/SimpleGraphs/generators/randgraphs.jl @@ -1164,7 +1164,7 @@ function stochastic_block_model( for b in a:K ((a == b) && !(c[a, b] <= n[b] - 1)) || ((a != b) && !(c[a, b] <= n[b])) && error( - "Mean degree cannot be greater than available neighbors in the block.", + "Mean degree cannot be greater than available neighbors in the block." ) # TODO 0.7: turn into some other error? m = a == b ? div(n[a] * (n[a] - 1), 2) : n[a] * n[b] diff --git a/src/SimpleGraphs/generators/smallgraphs.jl b/src/SimpleGraphs/generators/smallgraphs.jl index 0706d5d81..60a846711 100644 --- a/src/SimpleGraphs/generators/smallgraphs.jl +++ b/src/SimpleGraphs/generators/smallgraphs.jl @@ -81,179 +81,173 @@ diamond_graph() = SimpleGraph(SimpleEdge.([(1, 2), (1, 3), (2, 3), (2, 4), (3, 4 bull_graph() = SimpleGraph(SimpleEdge.([(1, 2), (1, 3), (2, 3), (2, 4), (3, 5)])) function chvatal_graph() - e = - SimpleEdge.([ - (1, 2), - (1, 5), - (1, 7), - (1, 10), - (2, 3), - (2, 6), - (2, 8), - (3, 4), - (3, 7), - (3, 9), - (4, 5), - (4, 8), - (4, 10), - (5, 6), - (5, 9), - (6, 11), - (6, 12), - (7, 11), - (7, 12), - (8, 9), - (8, 12), - (9, 11), - (10, 11), - (10, 12), - ]) + e = SimpleEdge.([ + (1, 2), + (1, 5), + (1, 7), + (1, 10), + (2, 3), + (2, 6), + (2, 8), + (3, 4), + (3, 7), + (3, 9), + (4, 5), + (4, 8), + (4, 10), + (5, 6), + (5, 9), + (6, 11), + (6, 12), + (7, 11), + (7, 12), + (8, 9), + (8, 12), + (9, 11), + (10, 11), + (10, 12), + ]) return SimpleGraph(e) end function cubical_graph() - e = - SimpleEdge.([ - (1, 2), - (1, 4), - (1, 5), - (2, 3), - (2, 8), - (3, 4), - (3, 7), - (4, 6), - (5, 6), - (5, 8), - (6, 7), - (7, 8), - ]) + e = SimpleEdge.([ + (1, 2), + (1, 4), + (1, 5), + (2, 3), + (2, 8), + (3, 4), + (3, 7), + (4, 6), + (5, 6), + (5, 8), + (6, 7), + (7, 8), + ]) return SimpleGraph(e) end function desargues_graph() - e = - SimpleEdge.([ - (1, 2), - (1, 6), - (1, 20), - (2, 3), - (2, 17), - (3, 4), - (3, 12), - (4, 5), - (4, 15), - (5, 6), - (5, 10), - (6, 7), - (7, 8), - (7, 16), - (8, 9), - (8, 19), - (9, 10), - (9, 14), - (10, 11), - (11, 12), - (11, 20), - (12, 13), - (13, 14), - (13, 18), - (14, 15), - (15, 16), - (16, 17), - (17, 18), - (18, 19), - (19, 20), - ]) + e = SimpleEdge.([ + (1, 2), + (1, 6), + (1, 20), + (2, 3), + (2, 17), + (3, 4), + (3, 12), + (4, 5), + (4, 15), + (5, 6), + (5, 10), + (6, 7), + (7, 8), + (7, 16), + (8, 9), + (8, 19), + (9, 10), + (9, 14), + (10, 11), + (11, 12), + (11, 20), + (12, 13), + (13, 14), + (13, 18), + (14, 15), + (15, 16), + (16, 17), + (17, 18), + (18, 19), + (19, 20), + ]) return SimpleGraph(e) end function dodecahedral_graph() - e = - SimpleEdge.([ - (1, 2), - (1, 11), - (1, 20), - (2, 3), - (2, 9), - (3, 4), - (3, 7), - (4, 5), - (4, 20), - (5, 6), - (5, 18), - (6, 7), - (6, 16), - (7, 8), - (8, 9), - (8, 15), - (9, 10), - (10, 11), - (10, 14), - (11, 12), - (12, 13), - (12, 19), - (13, 14), - (13, 17), - (14, 15), - (15, 16), - (16, 17), - (17, 18), - (18, 19), - (19, 20), - ]) + e = SimpleEdge.([ + (1, 2), + (1, 11), + (1, 20), + (2, 3), + (2, 9), + (3, 4), + (3, 7), + (4, 5), + (4, 20), + (5, 6), + (5, 18), + (6, 7), + (6, 16), + (7, 8), + (8, 9), + (8, 15), + (9, 10), + (10, 11), + (10, 14), + (11, 12), + (12, 13), + (12, 19), + (13, 14), + (13, 17), + (14, 15), + (15, 16), + (16, 17), + (17, 18), + (18, 19), + (19, 20), + ]) return SimpleGraph(e) end function frucht_graph() - e = - SimpleEdge.([ - (1, 2), - (1, 7), - (1, 8), - (2, 3), - (2, 8), - (3, 4), - (3, 9), - (4, 5), - (4, 10), - (5, 6), - (5, 10), - (6, 7), - (6, 11), - (7, 11), - (8, 12), - (9, 10), - (9, 12), - (11, 12), - ]) + e = SimpleEdge.([ + (1, 2), + (1, 7), + (1, 8), + (2, 3), + (2, 8), + (3, 4), + (3, 9), + (4, 5), + (4, 10), + (5, 6), + (5, 10), + (6, 7), + (6, 11), + (7, 11), + (8, 12), + (9, 10), + (9, 12), + (11, 12), + ]) return SimpleGraph(e) end function heawood_graph() - e = - SimpleEdge.([ - (1, 2), - (1, 6), - (1, 14), - (2, 3), - (2, 11), - (3, 4), - (3, 8), - (4, 5), - (4, 13), - (5, 6), - (5, 10), - (6, 7), - (7, 8), - (7, 12), - (8, 9), - (9, 10), - (9, 14), - (10, 11), - (11, 12), - (12, 13), - (13, 14), - ]) + e = SimpleEdge.([ + (1, 2), + (1, 6), + (1, 14), + (2, 3), + (2, 11), + (3, 4), + (3, 8), + (4, 5), + (4, 13), + (5, 6), + (5, 10), + (6, 7), + (7, 8), + (7, 12), + (8, 9), + (9, 10), + (9, 14), + (10, 11), + (11, 12), + (12, 13), + (13, 14), + ]) return SimpleGraph(e) end @@ -270,263 +264,255 @@ function house_x_graph() end function icosahedral_graph() - e = - SimpleEdge.([ - (1, 2), - (1, 6), - (1, 8), - (1, 9), - (1, 12), - (2, 3), - (2, 6), - (2, 7), - (2, 9), - (3, 4), - (3, 7), - (3, 9), - (3, 10), - (4, 5), - (4, 7), - (4, 10), - (4, 11), - (5, 6), - (5, 7), - (5, 11), - (5, 12), - (6, 7), - (6, 12), - (8, 9), - (8, 10), - (8, 11), - (8, 12), - (9, 10), - (10, 11), - (11, 12), - ]) + e = SimpleEdge.([ + (1, 2), + (1, 6), + (1, 8), + (1, 9), + (1, 12), + (2, 3), + (2, 6), + (2, 7), + (2, 9), + (3, 4), + (3, 7), + (3, 9), + (3, 10), + (4, 5), + (4, 7), + (4, 10), + (4, 11), + (5, 6), + (5, 7), + (5, 11), + (5, 12), + (6, 7), + (6, 12), + (8, 9), + (8, 10), + (8, 11), + (8, 12), + (9, 10), + (10, 11), + (11, 12), + ]) return SimpleGraph(e) end function karate_graph() - e = - SimpleEdge.([ - (1, 2), - (1, 3), - (1, 4), - (1, 5), - (1, 6), - (1, 7), - (1, 8), - (1, 9), - (1, 11), - (1, 12), - (1, 13), - (1, 14), - (1, 18), - (1, 20), - (1, 22), - (1, 32), - (2, 3), - (2, 4), - (2, 8), - (2, 14), - (2, 18), - (2, 20), - (2, 22), - (2, 31), - (3, 4), - (3, 8), - (3, 9), - (3, 10), - (3, 14), - (3, 28), - (3, 29), - (3, 33), - (4, 8), - (4, 13), - (4, 14), - (5, 7), - (5, 11), - (6, 7), - (6, 11), - (6, 17), - (7, 17), - (9, 31), - (9, 33), - (9, 34), - (10, 34), - (14, 34), - (15, 33), - (15, 34), - (16, 33), - (16, 34), - (19, 33), - (19, 34), - (20, 34), - (21, 33), - (21, 34), - (23, 33), - (23, 34), - (24, 26), - (24, 28), - (24, 30), - (24, 33), - (24, 34), - (25, 26), - (25, 28), - (25, 32), - (26, 32), - (27, 30), - (27, 34), - (28, 34), - (29, 32), - (29, 34), - (30, 33), - (30, 34), - (31, 33), - (31, 34), - (32, 33), - (32, 34), - (33, 34), - ]) + e = SimpleEdge.([ + (1, 2), + (1, 3), + (1, 4), + (1, 5), + (1, 6), + (1, 7), + (1, 8), + (1, 9), + (1, 11), + (1, 12), + (1, 13), + (1, 14), + (1, 18), + (1, 20), + (1, 22), + (1, 32), + (2, 3), + (2, 4), + (2, 8), + (2, 14), + (2, 18), + (2, 20), + (2, 22), + (2, 31), + (3, 4), + (3, 8), + (3, 9), + (3, 10), + (3, 14), + (3, 28), + (3, 29), + (3, 33), + (4, 8), + (4, 13), + (4, 14), + (5, 7), + (5, 11), + (6, 7), + (6, 11), + (6, 17), + (7, 17), + (9, 31), + (9, 33), + (9, 34), + (10, 34), + (14, 34), + (15, 33), + (15, 34), + (16, 33), + (16, 34), + (19, 33), + (19, 34), + (20, 34), + (21, 33), + (21, 34), + (23, 33), + (23, 34), + (24, 26), + (24, 28), + (24, 30), + (24, 33), + (24, 34), + (25, 26), + (25, 28), + (25, 32), + (26, 32), + (27, 30), + (27, 34), + (28, 34), + (29, 32), + (29, 34), + (30, 33), + (30, 34), + (31, 33), + (31, 34), + (32, 33), + (32, 34), + (33, 34), + ]) return SimpleGraph(e) end function krackhardt_kite_graph() - e = - SimpleEdge.([ - (1, 2), - (1, 3), - (1, 4), - (1, 6), - (2, 4), - (2, 5), - (2, 7), - (3, 4), - (3, 6), - (4, 5), - (4, 6), - (4, 7), - (5, 7), - (6, 7), - (6, 8), - (7, 8), - (8, 9), - (9, 10), - ]) + e = SimpleEdge.([ + (1, 2), + (1, 3), + (1, 4), + (1, 6), + (2, 4), + (2, 5), + (2, 7), + (3, 4), + (3, 6), + (4, 5), + (4, 6), + (4, 7), + (5, 7), + (6, 7), + (6, 8), + (7, 8), + (8, 9), + (9, 10), + ]) return SimpleGraph(e) end function moebius_kantor_graph() - e = - SimpleEdge.([ - (1, 2), - (1, 6), - (1, 16), - (2, 3), - (2, 13), - (3, 4), - (3, 8), - (4, 5), - (4, 15), - (5, 6), - (5, 10), - (6, 7), - (7, 8), - (7, 12), - (8, 9), - (9, 10), - (9, 14), - (10, 11), - (11, 12), - (11, 16), - (12, 13), - (13, 14), - (14, 15), - (15, 16), - ]) + e = SimpleEdge.([ + (1, 2), + (1, 6), + (1, 16), + (2, 3), + (2, 13), + (3, 4), + (3, 8), + (4, 5), + (4, 15), + (5, 6), + (5, 10), + (6, 7), + (7, 8), + (7, 12), + (8, 9), + (9, 10), + (9, 14), + (10, 11), + (11, 12), + (11, 16), + (12, 13), + (13, 14), + (14, 15), + (15, 16), + ]) return SimpleGraph(e) end function octahedral_graph() - e = - SimpleEdge.([ - (1, 2), - (1, 3), - (1, 4), - (1, 5), - (2, 3), - (2, 4), - (2, 6), - (3, 5), - (3, 6), - (4, 5), - (4, 6), - (5, 6), - ]) + e = SimpleEdge.([ + (1, 2), + (1, 3), + (1, 4), + (1, 5), + (2, 3), + (2, 4), + (2, 6), + (3, 5), + (3, 6), + (4, 5), + (4, 6), + (5, 6), + ]) return SimpleGraph(e) end function pappus_graph() - e = - SimpleEdge.([ - (1, 2), - (1, 6), - (1, 18), - (2, 3), - (2, 9), - (3, 4), - (3, 14), - (4, 5), - (4, 11), - (5, 6), - (5, 16), - (6, 7), - (7, 8), - (7, 12), - (8, 9), - (8, 15), - (9, 10), - (10, 11), - (10, 17), - (11, 12), - (12, 13), - (13, 14), - (13, 18), - (14, 15), - (15, 16), - (16, 17), - (17, 18), - ]) + e = SimpleEdge.([ + (1, 2), + (1, 6), + (1, 18), + (2, 3), + (2, 9), + (3, 4), + (3, 14), + (4, 5), + (4, 11), + (5, 6), + (5, 16), + (6, 7), + (7, 8), + (7, 12), + (8, 9), + (8, 15), + (9, 10), + (10, 11), + (10, 17), + (11, 12), + (12, 13), + (13, 14), + (13, 18), + (14, 15), + (15, 16), + (16, 17), + (17, 18), + ]) return SimpleGraph(e) end function petersen_graph() - e = - SimpleEdge.([ - (1, 2), - (1, 5), - (1, 6), - (2, 3), - (2, 7), - (3, 4), - (3, 8), - (4, 5), - (4, 9), - (5, 10), - (6, 8), - (6, 9), - (7, 9), - (7, 10), - (8, 10), - ]) + e = SimpleEdge.([ + (1, 2), + (1, 5), + (1, 6), + (2, 3), + (2, 7), + (3, 4), + (3, 8), + (4, 5), + (4, 9), + (5, 10), + (6, 8), + (6, 9), + (7, 9), + (7, 10), + (8, 10), + ]) return SimpleGraph(e) end function sedgewick_maze_graph() - e = - SimpleEdge.([ - (1, 3), (1, 6), (1, 8), (2, 8), (3, 7), (4, 5), (4, 6), (5, 6), (5, 7), (5, 8) - ]) + e = SimpleEdge.([ + (1, 3), (1, 6), (1, 8), (2, 8), (3, 7), (4, 5), (4, 6), (5, 6), (5, 7), (5, 8) + ]) return SimpleGraph(e) end @@ -535,170 +521,166 @@ function tetrahedral_graph() end function truncated_cube_graph() - e = - SimpleEdge.([ - (1, 2), - (1, 3), - (1, 5), - (2, 12), - (2, 15), - (3, 4), - (3, 5), - (4, 7), - (4, 9), - (5, 6), - (6, 17), - (6, 19), - (7, 8), - (7, 9), - (8, 11), - (8, 13), - (9, 10), - (10, 18), - (10, 21), - (11, 12), - (11, 13), - (12, 15), - (13, 14), - (14, 22), - (14, 23), - (15, 16), - (16, 20), - (16, 24), - (17, 18), - (17, 19), - (18, 21), - (19, 20), - (20, 24), - (21, 22), - (22, 23), - (23, 24), - ]) + e = SimpleEdge.([ + (1, 2), + (1, 3), + (1, 5), + (2, 12), + (2, 15), + (3, 4), + (3, 5), + (4, 7), + (4, 9), + (5, 6), + (6, 17), + (6, 19), + (7, 8), + (7, 9), + (8, 11), + (8, 13), + (9, 10), + (10, 18), + (10, 21), + (11, 12), + (11, 13), + (12, 15), + (13, 14), + (14, 22), + (14, 23), + (15, 16), + (16, 20), + (16, 24), + (17, 18), + (17, 19), + (18, 21), + (19, 20), + (20, 24), + (21, 22), + (22, 23), + (23, 24), + ]) return SimpleGraph(e) end function truncated_tetrahedron_graph() - e = - SimpleEdge.([ - (1, 2), - (1, 3), - (1, 10), - (2, 3), - (2, 7), - (3, 4), - (4, 5), - (4, 12), - (5, 6), - (5, 12), - (6, 7), - (6, 8), - (7, 8), - (8, 9), - (9, 10), - (9, 11), - (10, 11), - (11, 12), - ]) + e = SimpleEdge.([ + (1, 2), + (1, 3), + (1, 10), + (2, 3), + (2, 7), + (3, 4), + (4, 5), + (4, 12), + (5, 6), + (5, 12), + (6, 7), + (6, 8), + (7, 8), + (8, 9), + (9, 10), + (9, 11), + (10, 11), + (11, 12), + ]) return SimpleGraph(e) end function truncated_tetrahedron_digraph() - e = - SimpleEdge.([ - (1, 2), - (1, 3), - (1, 10), - (2, 3), - (2, 7), - (3, 4), - (4, 5), - (4, 12), - (5, 6), - (5, 12), - (6, 7), - (6, 8), - (7, 8), - (8, 9), - (9, 10), - (9, 11), - (10, 11), - (11, 12), - ]) + e = SimpleEdge.([ + (1, 2), + (1, 3), + (1, 10), + (2, 3), + (2, 7), + (3, 4), + (4, 5), + (4, 12), + (5, 6), + (5, 12), + (6, 7), + (6, 8), + (7, 8), + (8, 9), + (9, 10), + (9, 11), + (10, 11), + (11, 12), + ]) return SimpleDiGraph(e) end function tutte_graph() - e = - SimpleEdge.([ - (1, 2), - (1, 3), - (1, 4), - (2, 5), - (2, 27), - (3, 11), - (3, 12), - (4, 19), - (4, 20), - (5, 6), - (5, 34), - (6, 7), - (6, 30), - (7, 8), - (7, 28), - (8, 9), - (8, 15), - (9, 10), - (9, 39), - (10, 11), - (10, 38), - (11, 40), - (12, 13), - (12, 40), - (13, 14), - (13, 36), - (14, 15), - (14, 16), - (15, 35), - (16, 17), - (16, 23), - (17, 18), - (17, 45), - (18, 19), - (18, 44), - (19, 46), - (20, 21), - (20, 46), - (21, 22), - (21, 42), - (22, 23), - (22, 24), - (23, 41), - (24, 25), - (24, 28), - (25, 26), - (25, 33), - (26, 27), - (26, 32), - (27, 34), - (28, 29), - (29, 30), - (29, 33), - (30, 31), - (31, 32), - (31, 34), - (32, 33), - (35, 36), - (35, 39), - (36, 37), - (37, 38), - (37, 40), - (38, 39), - (41, 42), - (41, 45), - (42, 43), - (43, 44), - (43, 46), - (44, 45), - ]) + e = SimpleEdge.([ + (1, 2), + (1, 3), + (1, 4), + (2, 5), + (2, 27), + (3, 11), + (3, 12), + (4, 19), + (4, 20), + (5, 6), + (5, 34), + (6, 7), + (6, 30), + (7, 8), + (7, 28), + (8, 9), + (8, 15), + (9, 10), + (9, 39), + (10, 11), + (10, 38), + (11, 40), + (12, 13), + (12, 40), + (13, 14), + (13, 36), + (14, 15), + (14, 16), + (15, 35), + (16, 17), + (16, 23), + (17, 18), + (17, 45), + (18, 19), + (18, 44), + (19, 46), + (20, 21), + (20, 46), + (21, 22), + (21, 42), + (22, 23), + (22, 24), + (23, 41), + (24, 25), + (24, 28), + (25, 26), + (25, 33), + (26, 27), + (26, 32), + (27, 34), + (28, 29), + (29, 30), + (29, 33), + (30, 31), + (31, 32), + (31, 34), + (32, 33), + (35, 36), + (35, 39), + (36, 37), + (37, 38), + (37, 40), + (38, 39), + (41, 42), + (41, 45), + (42, 43), + (43, 44), + (43, 46), + (44, 45), + ]) return SimpleGraph(e) end diff --git a/src/SimpleGraphs/generators/staticgraphs.jl b/src/SimpleGraphs/generators/staticgraphs.jl index 65fbb0bdb..9f37cb689 100644 --- a/src/SimpleGraphs/generators/staticgraphs.jl +++ b/src/SimpleGraphs/generators/staticgraphs.jl @@ -530,12 +530,12 @@ function binary_tree(k::T) where {T<:Integer} fadjlist = Vector{Vector{T}}(undef, n) @inbounds fadjlist[1] = T[2, 3] @inbounds for i in 1:(k - 2) - @simd for j in (2^i):(2^(i + 1) - 1) + @simd for j in (2 ^ i):(2 ^ (i + 1) - 1) fadjlist[j] = T[j ÷ 2, 2j, 2j + 1] end end i = k - 1 - @inbounds @simd for j in (2^i):(2^(i + 1) - 1) + @inbounds @simd for j in (2 ^ i):(2 ^ (i + 1) - 1) fadjlist[j] = T[j ÷ 2] end return SimpleGraph(ne, fadjlist) diff --git a/src/SimpleGraphs/simpleedgeiter.jl b/src/SimpleGraphs/simpleedgeiter.jl index 3c33fc95f..509319c68 100644 --- a/src/SimpleGraphs/simpleedgeiter.jl +++ b/src/SimpleGraphs/simpleedgeiter.jl @@ -30,7 +30,7 @@ eltype(::Type{SimpleEdgeIter{SimpleDiGraph{T}}}) where {T} = SimpleDiGraphEdge{T @traitfn @inline function iterate( eit::SimpleEdgeIter{G}, state=(one(eltype(eit.g)), 1) -) where {G <: AbstractSimpleGraph; !IsDirected{G}} +) where {G<:AbstractSimpleGraph;!IsDirected{G}} g = eit.g T = eltype(g) n = T(nv(g)) @@ -57,7 +57,7 @@ end @traitfn @inline function iterate( eit::SimpleEdgeIter{G}, state=(one(eltype(eit.g)), 1) -) where {G <: AbstractSimpleGraph; IsDirected{G}} +) where {G<:AbstractSimpleGraph;IsDirected{G}} g = eit.g T = eltype(g) n = T(nv(g)) diff --git a/src/linalg/nonbacktracking.jl b/src/linalg/nonbacktracking.jl index ddbae17dd..208e92bf5 100644 --- a/src/linalg/nonbacktracking.jl +++ b/src/linalg/nonbacktracking.jl @@ -118,16 +118,15 @@ function mul!(C, nbt::Nonbacktracking, B) end function coo_sparse(nbt::Nonbacktracking) - m = nbt.m - #= I,J = zeros(Int, m), zeros(Int, m) =# + m = nbt.m#= I,J = zeros(Int, m), zeros(Int, m) =# + I, J = zeros(Int, 0), zeros(Int, 0) for (e, u) in nbt.edgeidmap i, j = src(e), dst(e) for k in inneighbors(nbt.g, i) k == j && continue - v = nbt.edgeidmap[Edge(k, i)] - #= J[u] = v =# - #= I[u] = u =# + v = nbt.edgeidmap[Edge(k, i)]#= J[u] = v =##= I[u] = u =# + push!(I, v) push!(J, u) end diff --git a/src/linalg/spectral.jl b/src/linalg/spectral.jl index 756a37dde..f80e2afbe 100644 --- a/src/linalg/spectral.jl +++ b/src/linalg/spectral.jl @@ -180,7 +180,7 @@ function spectral_distance end # can't use Traitor syntax here (https://github.com/mauro3/SimpleTraits.jl/issues/36) @traitfn function spectral_distance( G₁::G, G₂::G, k::Integer -) where {G <: AbstractGraph; !IsDirected{G}} +) where {G<:AbstractGraph;!IsDirected{G}} A₁ = adjacency_matrix(G₁) A₂ = adjacency_matrix(G₂) @@ -199,7 +199,7 @@ function spectral_distance end end # can't use Traitor syntax here (https://github.com/mauro3/SimpleTraits.jl/issues/36) -@traitfn function spectral_distance(G₁::G, G₂::G) where {G <: AbstractGraph; !IsDirected{G}} +@traitfn function spectral_distance(G₁::G, G₂::G) where {G<:AbstractGraph;!IsDirected{G}} nv(G₁) == nv(G₂) || throw(ArgumentError("Spectral distance not defined for |G₁| != |G₂|")) return spectral_distance(G₁, G₂, nv(G₁)) diff --git a/src/operators.jl b/src/operators.jl index d8aeb2172..d1e5a9f55 100644 --- a/src/operators.jl +++ b/src/operators.jl @@ -504,11 +504,11 @@ sparse(g::AbstractGraph) = adjacency_matrix(g) length(g::AbstractGraph) = widen(nv(g)) * widen(nv(g)) ndims(g::AbstractGraph) = 2 -@traitfn function issymmetric(g::AG) where {AG <: AbstractGraph; !IsDirected{AG}} +@traitfn function issymmetric(g::AG) where {AG<:AbstractGraph;!IsDirected{AG}} return true end -@traitfn function issymmetric(g::AG) where {AG <: AbstractGraph; IsDirected{AG}} +@traitfn function issymmetric(g::AG) where {AG<:AbstractGraph;IsDirected{AG}} for e in edges(g) if !has_edge(g, reverse(e)) return false diff --git a/src/spanningtrees/kruskal.jl b/src/spanningtrees/kruskal.jl index b9efba367..039bb237d 100644 --- a/src/spanningtrees/kruskal.jl +++ b/src/spanningtrees/kruskal.jl @@ -25,7 +25,7 @@ function kruskal_mst end push!(weights, distmx[src(e), dst(e)]) end - for e in edge_list[sortperm(weights; rev=!minimize)] + for e in edge_list[sortperm(weights; rev=(!minimize))] if !in_same_set(connected_vs, src(e), dst(e)) union!(connected_vs, src(e), dst(e)) push!(mst, e) diff --git a/test/biconnectivity/articulation.jl b/test/biconnectivity/articulation.jl index 0ebaff9bd..d9481c03f 100644 --- a/test/biconnectivity/articulation.jl +++ b/test/biconnectivity/articulation.jl @@ -27,7 +27,7 @@ btree = Graphs.binary_tree(level) for tree in test_generic_graphs(btree; eltypes=[Int, UInt8, Int16]) artpts = @inferred(articulation(tree)) - @test artpts == collect(1:(2^(level - 1) - 1)) + @test artpts == collect(1:(2 ^ (level - 1) - 1)) end end diff --git a/test/centrality/eigenvector.jl b/test/centrality/eigenvector.jl index af13508b7..5fb69d9b3 100644 --- a/test/centrality/eigenvector.jl +++ b/test/centrality/eigenvector.jl @@ -4,8 +4,7 @@ for g in test_generic_graphs(g1) y = @inferred(eigenvector_centrality(g)) - @test round.(y, digits=3) == - round.( + @test round.(y, digits=3) == round.( [ 0.3577513877490464, 0.3577513877490464, diff --git a/test/simplegraphs/runtests.jl b/test/simplegraphs/runtests.jl index 576110f14..21e665e19 100644 --- a/test/simplegraphs/runtests.jl +++ b/test/simplegraphs/runtests.jl @@ -1,7 +1,8 @@ using Graphs.SimpleGraphs import Graphs.SimpleGraphs: fadj, badj, adj -import Graphs.edgetype, Graphs.has_edge +using Graphs.edgetype: edgetype +using Graphs.has_edge: has_edge using Statistics: mean struct DummySimpleGraph <: AbstractSimpleGraph{Int} end diff --git a/test/simplegraphs/simplegraphs.jl b/test/simplegraphs/simplegraphs.jl index 78b5145ef..cbc372117 100644 --- a/test/simplegraphs/simplegraphs.jl +++ b/test/simplegraphs/simplegraphs.jl @@ -322,8 +322,9 @@ using Graphs.Test SimpleGraph(0) ) E = edgetype(g) - edge_list = - E.([(4, 4), (1, 2), (4, 4), (1, 2), (4, 4), (2, 1), (0, 1), (1, 0), (0, 0)]) + edge_list = E.([ + (4, 4), (1, 2), (4, 4), (1, 2), (4, 4), (2, 1), (0, 1), (1, 0), (0, 0) + ]) edge_iter = (e for e in edge_list) edge_set = Set(edge_list) edge_set_any = Set{Any}(edge_list) @@ -352,8 +353,9 @@ using Graphs.Test SimpleDiGraph(0) ) E = edgetype(g) - edge_list = - E.([(4, 4), (1, 2), (4, 4), (1, 2), (4, 4), (2, 1), (0, 1), (1, 0), (0, 0)]) + edge_list = E.([ + (4, 4), (1, 2), (4, 4), (1, 2), (4, 4), (2, 1), (0, 1), (1, 0), (0, 0) + ]) edge_iter = (e for e in edge_list) edge_set = Set(edge_list) edge_set_any = Set{Any}(edge_list)