Skip to content

Commit 51f9fae

Browse files
committed
Fix name collision in maximum_clique
Graphs v1.14.0 started exporting `maximum_clique`, which is a function that MolecularGraph also exports. The two names collide, which causes problems for MolecularGraph's test suite. This fixes the problem by renaming MolecularGraph's `maximum_clique` to `maximum_clique_mg`. This also adds a bunch of Aqua tests to check for piracy, etc.
1 parent 5e015a8 commit 51f9fae

7 files changed

Lines changed: 47 additions & 19 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
.DS_Store
22
Manifest.toml
3+
Manifest-v*.toml
34

45
_temp

Project.toml

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
name = "MolecularGraph"
22
uuid = "6c89ec66-9cd8-5372-9f91-fabc50dd27fd"
33
authors = ["Seiji Matsuoka <ms0ae8ti1sj2ui@gmail.com"]
4-
version = "0.22.0"
4+
version = "0.23.0"
55

66
[deps]
77
Colors = "5ae59095-9a9b-59fe-a467-6f913c188581"
88
Dates = "ade2ca70-3891-5945-98fb-dc099432e06a"
99
DelimitedFiles = "8bb1440f-4735-579b-a4ab-409b98df4dab"
10+
EzXML = "8f5d6c58-4d21-5cfd-889c-e3ad7ee6a615"
1011
GeometryBasics = "5c1252a2-5f33-56bf-86c9-59e7332b4326"
1112
Graphs = "86223c79-3864-5bf0-83f7-82e725a168b6"
1213
JSON = "682c06a0-de6a-54ab-a142-c8b1cf79cde6"
13-
EzXML = "8f5d6c58-4d21-5cfd-889c-e3ad7ee6a615"
1414
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
1515
MakieCore = "20f20a25-4f0e-4fdf-b5d1-57303727442b"
1616
OrderedCollections = "bac558e1-5e72-5ebc-8fee-abe8a469f55d"
@@ -30,13 +30,14 @@ CairoExt = "Cairo"
3030
RDKitExt = "RDKitMinimalLib"
3131

3232
[compat]
33+
Aqua = "0.8"
3334
Cairo = "1.1"
3435
Colors = "0.13"
3536
DelimitedFiles = "1"
37+
EzXML = "1"
3638
GeometryBasics = "0.5"
3739
Graphs = "1.12"
3840
JSON = "1"
39-
EzXML = "1"
4041
MakieCore = "0.9,0.10"
4142
OrderedCollections = "1.8"
4243
RDKitMinimalLib = "1.2"
@@ -46,11 +47,16 @@ Test = "1"
4647
YAML = "0.4"
4748
coordgenlibs_jll = "3.0.2"
4849
julia = "1.9"
50+
Dates = "1"
51+
LinearAlgebra = "1"
52+
Printf = "1"
53+
Logging = "1"
4954
libinchi_jll = "1.5"
5055

5156
[extras]
57+
Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595"
5258
Logging = "56ddb016-857b-54e1-b83d-db4d58db5568"
5359
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
5460

5561
[targets]
56-
test = ["Test", "Logging"]
62+
test = ["Test", "Aqua", "Logging"]

src/MolecularGraph.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ export
7777

7878
export
7979
maxcardmap, maxcard,
80-
all_maximal_cliques, maximum_clique,
80+
all_maximal_cliques, maximum_clique_mg,
8181
all_maximal_conn_cliques, maximum_conn_clique,
8282
approx_maximum_clique,
8383
mincyclebasis, edgemincyclebasis, disjoint_union,

src/graph/clique.jl

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -134,21 +134,26 @@ all_maximal_cliques(g::SimpleGraph{T}; kwargs...
134134

135135

136136
"""
137-
maximum_clique(::Type{U}, g::SimpleGraph{T}; kwargs...) where {T,U} -> (U, Symbol)
137+
maximum_clique_mg(::Type{U}, g::SimpleGraph{T}; kwargs...) where {T,U} -> (U, Symbol)
138138
139139
Calculate maximum clique.
140+
141+
This is a molecular-mining-oriented variant of `Graphs.maximum_clique`: it accepts
142+
`timeout` and `targetsize` keyword arguments and reports a status alongside the
143+
result, both of which are needed in practice for the substructure-matching tasks in
144+
this package. The `_mg` suffix marks it as intentionally distinct from the like-named
145+
`Graphs.jl` function (#146).
140146
"""
141-
function maximum_clique(::Type{U}, g::SimpleGraph{T}; kwargs...) where {T,U}
147+
function maximum_clique_mg(::Type{U}, g::SimpleGraph{T}; kwargs...) where {T,U}
142148
state = MaxCliqueState{T,U}(g; kwargs...)
143149
expand!(state, Set(vertices(g)), Set(vertices(g)))
144150
if state.status == :ongoing
145151
state.status = :done
146152
end
147153
return state.maxsofar, state.status
148154
end
149-
maximum_clique(g::SimpleGraph{T}; kwargs...
150-
) where T = maximum_clique(Vector{T}, g; kwargs...)
151-
155+
maximum_clique_mg(g::SimpleGraph{T}; kwargs...
156+
) where T = maximum_clique_mg(Vector{T}, g; kwargs...)
152157

153158

154159
# Connected cliques (c-cliques)

src/graph/isomorphism_clique.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ function maximum_common_subgraph(
247247
if connected
248248
maxclique, status = maximum_conn_clique(prod, connfunc=connfuncgen(prod, g, h); kwargs...)
249249
else
250-
maxclique, status = maximum_clique(prod; kwargs...)
250+
maxclique, status = maximum_clique_mg(prod; kwargs...)
251251
end
252252
# modprod reverse mapping
253253
nmap = Dict(div(i - 1, h.nv) + 1 => mod(i - 1, h.nv) + 1 for i in maxclique)
@@ -270,7 +270,7 @@ function maximum_common_subgraph(
270270
Dict{Edge{T},Edge{T}}, prod, connfunc=connfuncgen(prod, g, h),
271271
postprocess=mces_postprocess(g, h); kwargs...)
272272
else
273-
return maximum_clique(
273+
return maximum_clique_mg(
274274
Dict{Edge{T},Edge{T}}, prod, postprocess=mces_postprocess(g, h); kwargs...)
275275
end
276276
end

test/graph/clique.jl

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,31 +7,31 @@
77

88
@testset "max_clique" begin
99
nullg = SimpleGraph()
10-
@test maximum_clique(nullg)[1] == []
10+
@test maximum_clique_mg(nullg)[1] == []
1111

1212
noedges = SimpleGraph(5)
1313
@test length(all_maximal_cliques(noedges)[1]) == 5
14-
@test length(maximum_clique(noedges)[1]) == 1
14+
@test length(maximum_clique_mg(noedges)[1]) == 1
1515

1616
p7 = path_graph(7)
1717
@test length(all_maximal_cliques(p7)[1]) == 6
18-
@test length(maximum_clique(p7)[1]) == 2
18+
@test length(maximum_clique_mg(p7)[1]) == 2
1919

2020
k5 = complete_graph(5)
2121
@test length(all_maximal_cliques(k5)[1]) == 1
22-
@test length(maximum_clique(k5)[1]) == 5
22+
@test length(maximum_clique_mg(k5)[1]) == 5
2323

2424
w8 = wheel_graph(8)
2525
@test length(all_maximal_cliques(w8)[1]) == 7
26-
@test length(maximum_clique(w8)[1]) == 3
26+
@test length(maximum_clique_mg(w8)[1]) == 3
2727

2828
petersen = smallgraph(:petersen)
2929
@test length(all_maximal_cliques(petersen)[1]) == 15
30-
@test length(maximum_clique(petersen)[1]) == 2
30+
@test length(maximum_clique_mg(petersen)[1]) == 2
3131

3232
karate = smallgraph(:karate)
3333
@test length(all_maximal_cliques(karate)[1]) == 36
34-
@test length(maximum_clique(karate)[1]) == 5
34+
@test length(maximum_clique_mg(karate)[1]) == 5
3535

3636
end
3737

test/runtests.jl

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,3 +107,19 @@ include("./draw/svg.jl")
107107
include("./draw/3d.jl")
108108

109109
end
110+
111+
using MolecularGraph
112+
using Aqua
113+
using Test
114+
115+
@testset "Aqua" begin
116+
Aqua.test_ambiguities(MolecularGraph; broken=true)
117+
Aqua.test_unbound_args(MolecularGraph; broken=true)
118+
Aqua.test_undefined_exports(MolecularGraph; broken=true)
119+
Aqua.test_project_extras(MolecularGraph)
120+
Aqua.test_stale_deps(MolecularGraph)
121+
Aqua.test_deps_compat(MolecularGraph)
122+
Aqua.test_piracies(MolecularGraph)
123+
Aqua.test_persistent_tasks(MolecularGraph)
124+
Aqua.test_undocumented_names(MolecularGraph; broken=true)
125+
end

0 commit comments

Comments
 (0)