Skip to content

Commit e26430e

Browse files
committed
add terminal linkage classes
1 parent 1f8523a commit e26430e

File tree

1 file changed

+44
-1
lines changed

1 file changed

+44
-1
lines changed

src/network_analysis.jl

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -359,6 +359,48 @@ end
359359

360360
linkageclasses(incidencegraph) = Graphs.connected_components(incidencegraph)
361361

362+
"""
363+
stronglinkageclasses(rn::ReactionSystem)
364+
365+
Return the strongly connected components of a reaction network's incidence graph (i.e. sub-groups of reaction complexes such that every complex is reachable from every other one in the sub-group).
366+
"""
367+
368+
function stronglinkageclasses(rn::ReactionSystem)
369+
nps = get_networkproperties(rn)
370+
if isempty(nps.stronglinkageclasses)
371+
nps.stronglinkageclasses = stronglinkageclasses(incidencematgraph(rn))
372+
end
373+
nps.stronglinkageclasses
374+
end
375+
376+
stronglinkageclasses(incidencegraph) = Graphs.strongly_connected_components(g)
377+
378+
"""
379+
terminallinkageclasses(rn::ReactionSystem)
380+
381+
Return the terminal strongly connected components of a reaction network's incidence graph (i.e. sub-groups of reaction complexes that are 1) strongly connected and 2) every reaction in the component produces a complex in the component).
382+
"""
383+
384+
function terminallinkageclasses(rn::ReactionSystem)
385+
slcs = stronglinkageclasses(rn)
386+
387+
tslcs = filter!(slcs, lc->isterminal(lc))
388+
tslcs
389+
end
390+
391+
function isterminal(lc::Vector, rn::ReactionSystem)
392+
imat = incidencemat(rn)
393+
394+
for col in columns(imat)
395+
s = findfirst(==(-1), @view D[:, r])
396+
if s in Set(lc)
397+
p = findfirst(==(1), @view D[:, r])
398+
p in Set(lc) ? continue : return false
399+
end
400+
end
401+
true
402+
end
403+
362404
@doc raw"""
363405
deficiency(rn::ReactionSystem)
364406
@@ -925,6 +967,7 @@ end
925967
See documentation for [`cycles`](@ref).
926968
"""
927969

928-
function fluxvectors(rs::ReactionSystem)
970+
function fluxmodebasis(rs::ReactionSystem)
929971
cycles(rs)
930972
end
973+

0 commit comments

Comments
 (0)