Skip to content

Commit

Permalink
Merge pull request #437 from isaacsas/drop_lightgraphs
Browse files Browse the repository at this point in the history
switch LightGraphs to Graphs
  • Loading branch information
isaacsas committed Nov 8, 2021
2 parents 92f2b62 + 49b5487 commit 4dd14c0
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 14 deletions.
4 changes: 2 additions & 2 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ DataStructures = "864edb3b-99cc-5e75-8d2d-829cb0a9cfe8"
DiffEqBase = "2b5f629d-d688-5b77-993f-72d75c75574e"
DiffEqJump = "c894b116-72e5-5b58-be3c-e6d8d4ac2b12"
DocStringExtensions = "ffbed154-4ef7-542d-bbb7-c09d3a79fcae"
Graphs = "86223c79-3864-5bf0-83f7-82e725a168b6"
Latexify = "23fbe1c1-3f47-55db-b15f-69d7ec21a316"
LightGraphs = "093fc24a-ae57-5d10-9952-331d41423f4d"
MacroTools = "1914dd2f-81c6-5fcd-8719-6d5c9610ff09"
ModelingToolkit = "961ee093-0014-501f-94e3-6117800e7a78"
Parameters = "d96e819e-fc66-5662-9728-84c9c7592b0a"
Expand All @@ -24,8 +24,8 @@ DataStructures = "0.18"
DiffEqBase = "6.54.0"
DiffEqJump = "7.0"
DocStringExtensions = "0.8"
Graphs = "1.4"
Latexify = "0.14, 0.15"
LightGraphs = "1.3"
MacroTools = "0.5.5"
ModelingToolkit = "6.3"
Parameters = "0.12"
Expand Down
3 changes: 1 addition & 2 deletions src/Catalyst.jl
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,9 @@ import ModelingToolkit: get_variables, namespace_expr, namespace_equation, get_v
import ModelingToolkit: check_variables, check_parameters, _iszero, _merge, check_units, get_unit

import Base: (==), hash, size, getindex, setindex, isless, Sort.defalg, length, show
import MacroTools, LightGraphs, AbstractAlgebra
import MacroTools, Graphs, AbstractAlgebra

# globals for the modulate
const LG = LightGraphs
const AA = AbstractAlgebra
const DEFAULT_IV = (@parameters t)[1]

Expand Down
20 changes: 10 additions & 10 deletions src/networkapi.jl
Original file line number Diff line number Diff line change
Expand Up @@ -580,32 +580,32 @@ incidencegraph = incidencematgraph(incidencemat)
function incidencematgraph(incidencemat::Matrix{Int})
@assert all(([-1,0,1]) ,incidencemat)
n = size(incidencemat,1) # no. of nodes/complexes
graph = LG.DiGraph(n)
graph = Graphs.DiGraph(n)
for col in eachcol(incidencemat)
src = 0; dst = 0;
for i in eachindex(col)
(col[i] == -1) && (src = i)
(col[i] == 1) && (dst = i)
(src != 0) && (dst != 0) && break
end
LG.add_edge!(graph, src, dst)
Graphs.add_edge!(graph, src, dst)
end
return graph
end
function incidencematgraph(incidencemat::SparseMatrixCSC{Int,Int})
@assert all(([-1,0,1]) ,incidencemat)
m,n = size(incidencemat)
graph = LG.DiGraph(m)
graph = Graphs.DiGraph(m)
rows = rowvals(incidencemat)
vals = nonzeros(incidencemat)
for j = 1:n
inds=nzrange(incidencemat, j)
row = rows[inds];
val = vals[inds];
if val[1] == -1
LG.add_edge!(graph, row[1], row[2])
Graphs.add_edge!(graph, row[1], row[2])
else
LG.add_edge!(graph, row[2], row[1])
Graphs.add_edge!(graph, row[2], row[1])
end
end
return graph
Expand All @@ -628,7 +628,7 @@ julia> linkageclasses(incidencegraph)
```
"""
function linkageclasses(incidencegraph)
LG.connected_components(incidencegraph)
Graphs.connected_components(incidencegraph)
end


Expand Down Expand Up @@ -658,7 +658,7 @@ netstoich_mat = netstoichmat(sir)
```
"""
function deficiency(ns, ig, lc)
LG.nv(ig) - length(lc) - AA.rank(AA.matrix(AA.ZZ,ns))
Graphs.nv(ig) - length(lc) - AA.rank(AA.matrix(AA.ZZ,ns))
end

function subnetworkmapping(linkageclass, allrxs, complextorxmap, p)
Expand Down Expand Up @@ -737,8 +737,8 @@ For example, continuing the example from [`linkagedeficiencies`](@ref)
isreversible(incidence_graph)
```
"""
function isreversible(ig::LG.SimpleDiGraph)
LG.reverse(ig) == ig
function isreversible(ig::Graphs.SimpleDiGraph)
Graphs.reverse(ig) == ig
end

"""
Expand All @@ -753,7 +753,7 @@ isweaklyreversible(subnets)
"""
function isweaklyreversible(subnets::Vector{ReactionSystem})
igs = [incidencematgraph(reactioncomplexes(subrs)[2]) for subrs in subnets]
all([LG.is_strongly_connected(ig) for ig in igs])
all([Graphs.is_strongly_connected(ig) for ig in igs])
end


Expand Down

0 comments on commit 4dd14c0

Please sign in to comment.