@@ -277,8 +277,7 @@ incidencematgraph(sir)
277
277
function incidencematgraph (rn:: ReactionSystem )
278
278
nps = get_networkproperties (rn)
279
279
if Graphs. nv (nps. incidencegraph) == 0
280
- isempty (nps. incidencemat) &&
281
- error (" Please call reactioncomplexes(rn) first to construct the incidence matrix." )
280
+ isempty (nps. incidencemat) && reactioncomplexes (rn)
282
281
nps. incidencegraph = incidencematgraph (nps. incidencemat)
283
282
end
284
283
nps. incidencegraph
@@ -329,17 +328,12 @@ Given the incidence graph of a reaction network, return a vector of the
329
328
connected components of the graph (i.e. sub-groups of reaction complexes that
330
329
are connected in the incidence graph).
331
330
332
- Notes:
333
- - Requires the `incidencemat` to already be cached in `rn` by a previous call to
334
- `reactioncomplexes`.
335
-
336
331
For example,
337
332
```julia
338
333
sir = @reaction_network SIR begin
339
334
β, S + I --> 2I
340
335
ν, I --> R
341
336
end
342
- complexes,incidencemat = reactioncomplexes(sir)
343
337
linkageclasses(sir)
344
338
```
345
339
gives
@@ -371,17 +365,12 @@ Here the deficiency, ``\delta``, of a network with ``n`` reaction complexes,
371
365
\d elta = n - \e ll - s
372
366
```
373
367
374
- Notes:
375
- - Requires the `incidencemat` to already be cached in `rn` by a previous call to
376
- `reactioncomplexes`.
377
-
378
368
For example,
379
369
```julia
380
370
sir = @reaction_network SIR begin
381
371
β, S + I --> 2I
382
372
ν, I --> R
383
373
end
384
- rcs,incidencemat = reactioncomplexes(sir)
385
374
δ = deficiency(sir)
386
375
```
387
376
"""
@@ -419,17 +408,12 @@ end
419
408
420
409
Find subnetworks corresponding to each linkage class of the reaction network.
421
410
422
- Notes:
423
- - Requires the `incidencemat` to already be cached in `rn` by a previous call to
424
- `reactioncomplexes`.
425
-
426
411
For example,
427
412
```julia
428
413
sir = @reaction_network SIR begin
429
414
β, S + I --> 2I
430
415
ν, I --> R
431
416
end
432
- complexes,incidencemat = reactioncomplexes(sir)
433
417
subnetworks(sir)
434
418
```
435
419
"""
@@ -456,17 +440,12 @@ end
456
440
457
441
Calculates the deficiency of each sub-reaction network within `network`.
458
442
459
- Notes:
460
- - Requires the `incidencemat` to already be cached in `rn` by a previous call to
461
- `reactioncomplexes`.
462
-
463
443
For example,
464
444
```julia
465
445
sir = @reaction_network SIR begin
466
446
β, S + I --> 2I
467
447
ν, I --> R
468
448
end
469
- rcs,incidencemat = reactioncomplexes(sir)
470
449
linkage_deficiencies = linkagedeficiencies(sir)
471
450
```
472
451
"""
@@ -487,17 +466,12 @@ end
487
466
488
467
Given a reaction network, returns if the network is reversible or not.
489
468
490
- Notes:
491
- - Requires the `incidencemat` to already be cached in `rn` by a previous call to
492
- `reactioncomplexes`.
493
-
494
469
For example,
495
470
```julia
496
471
sir = @reaction_network SIR begin
497
472
β, S + I --> 2I
498
473
ν, I --> R
499
474
end
500
- rcs,incidencemat = reactioncomplexes(sir)
501
475
isreversible(sir)
502
476
```
503
477
"""
@@ -511,30 +485,28 @@ end
511
485
512
486
Determine if the reaction network with the given subnetworks is weakly reversible or not.
513
487
514
- Notes:
515
- - Requires the `incidencemat` to already be cached in `rn` by a previous call to
516
- `reactioncomplexes`.
517
-
518
488
For example,
519
489
```julia
520
490
sir = @reaction_network SIR begin
521
491
β, S + I --> 2I
522
492
ν, I --> R
523
493
end
524
- rcs,incidencemat = reactioncomplexes(sir)
525
494
subnets = subnetworks(rn)
526
495
isweaklyreversible(rn, subnets)
527
496
```
528
497
"""
529
498
function isweaklyreversible (rn:: ReactionSystem , subnets)
530
- im = get_networkproperties (rn). incidencemat
531
- isempty (im) &&
532
- error (" Error, please call reactioncomplexes(rn::ReactionSystem) to ensure the incidence matrix has been cached." )
533
- sparseig = issparse (im)
499
+ nps = get_networkproperties (rn)
500
+ isempty (nps. incidencemat) && reactioncomplexes (rn)
501
+ imat = nps. incidencemat
502
+ sparseig = issparse (imat)
503
+
534
504
for subnet in subnets
535
- nps = get_networkproperties (subnet)
536
- isempty (nps . incidencemat) && reactioncomplexes (subnet; sparse = sparseig)
505
+ subnps = get_networkproperties (subnet)
506
+ isempty (subnps . incidencemat) && reactioncomplexes (subnet; sparse = sparseig)
537
507
end
508
+
509
+ # A network is weakly reversible if all of its subnetworks are strongly connected
538
510
all (Graphs. is_strongly_connected ∘ incidencematgraph, subnets)
539
511
end
540
512
@@ -902,6 +874,6 @@ function satisfiesdeficiencyone(rn::ReactionSystem)
902
874
complexes, D = reactioncomplexes (rn)
903
875
lcs = linkageclasses (rn); tslcs = terminallinkageclasses (rn)
904
876
905
- δ_l .<= 1 && sum (δ_l) = δ && length (lcs) == length (tslcs)
877
+ δ_l .<= 1 && ( sum (δ_l) == δ) && length (lcs) == length (tslcs)
906
878
end
907
879
0 commit comments