@@ -260,25 +260,19 @@ end
260
260
Construct a directed simple graph where nodes correspond to reaction complexes and directed
261
261
edges to reactions converting between two complexes.
262
262
263
- Notes:
264
- - Requires the `incidencemat` to already be cached in `rn` by a previous call to
265
- `reactioncomplexes`.
266
-
267
263
For example,
268
264
```julia
269
265
sir = @reaction_network SIR begin
270
266
β, S + I --> 2I
271
267
ν, I --> R
272
268
end
273
- complexes,incidencemat = reactioncomplexes(sir)
274
269
incidencematgraph(sir)
275
270
```
276
271
"""
277
272
function incidencematgraph (rn:: ReactionSystem )
278
273
nps = get_networkproperties (rn)
279
274
if Graphs. nv (nps. incidencegraph) == 0
280
- isempty (nps. incidencemat) &&
281
- error (" Please call reactioncomplexes(rn) first to construct the incidence matrix." )
275
+ isempty (nps. incidencemat) && reactioncomplexes (rn)
282
276
nps. incidencegraph = incidencematgraph (nps. incidencemat)
283
277
end
284
278
nps. incidencegraph
@@ -329,17 +323,12 @@ Given the incidence graph of a reaction network, return a vector of the
329
323
connected components of the graph (i.e. sub-groups of reaction complexes that
330
324
are connected in the incidence graph).
331
325
332
- Notes:
333
- - Requires the `incidencemat` to already be cached in `rn` by a previous call to
334
- `reactioncomplexes`.
335
-
336
326
For example,
337
327
```julia
338
328
sir = @reaction_network SIR begin
339
329
β, S + I --> 2I
340
330
ν, I --> R
341
331
end
342
- complexes,incidencemat = reactioncomplexes(sir)
343
332
linkageclasses(sir)
344
333
```
345
334
gives
@@ -371,17 +360,12 @@ Here the deficiency, ``\delta``, of a network with ``n`` reaction complexes,
371
360
\d elta = n - \e ll - s
372
361
```
373
362
374
- Notes:
375
- - Requires the `incidencemat` to already be cached in `rn` by a previous call to
376
- `reactioncomplexes`.
377
-
378
363
For example,
379
364
```julia
380
365
sir = @reaction_network SIR begin
381
366
β, S + I --> 2I
382
367
ν, I --> R
383
368
end
384
- rcs,incidencemat = reactioncomplexes(sir)
385
369
δ = deficiency(sir)
386
370
```
387
371
"""
@@ -419,17 +403,12 @@ end
419
403
420
404
Find subnetworks corresponding to each linkage class of the reaction network.
421
405
422
- Notes:
423
- - Requires the `incidencemat` to already be cached in `rn` by a previous call to
424
- `reactioncomplexes`.
425
-
426
406
For example,
427
407
```julia
428
408
sir = @reaction_network SIR begin
429
409
β, S + I --> 2I
430
410
ν, I --> R
431
411
end
432
- complexes,incidencemat = reactioncomplexes(sir)
433
412
subnetworks(sir)
434
413
```
435
414
"""
@@ -456,17 +435,12 @@ end
456
435
457
436
Calculates the deficiency of each sub-reaction network within `network`.
458
437
459
- Notes:
460
- - Requires the `incidencemat` to already be cached in `rn` by a previous call to
461
- `reactioncomplexes`.
462
-
463
438
For example,
464
439
```julia
465
440
sir = @reaction_network SIR begin
466
441
β, S + I --> 2I
467
442
ν, I --> R
468
443
end
469
- rcs,incidencemat = reactioncomplexes(sir)
470
444
linkage_deficiencies = linkagedeficiencies(sir)
471
445
```
472
446
"""
@@ -487,17 +461,12 @@ end
487
461
488
462
Given a reaction network, returns if the network is reversible or not.
489
463
490
- Notes:
491
- - Requires the `incidencemat` to already be cached in `rn` by a previous call to
492
- `reactioncomplexes`.
493
-
494
464
For example,
495
465
```julia
496
466
sir = @reaction_network SIR begin
497
467
β, S + I --> 2I
498
468
ν, I --> R
499
469
end
500
- rcs,incidencemat = reactioncomplexes(sir)
501
470
isreversible(sir)
502
471
```
503
472
"""
@@ -511,30 +480,27 @@ end
511
480
512
481
Determine if the reaction network with the given subnetworks is weakly reversible or not.
513
482
514
- Notes:
515
- - Requires the `incidencemat` to already be cached in `rn` by a previous call to
516
- `reactioncomplexes`.
517
-
518
483
For example,
519
484
```julia
520
485
sir = @reaction_network SIR begin
521
486
β, S + I --> 2I
522
487
ν, I --> R
523
488
end
524
- rcs,incidencemat = reactioncomplexes(sir)
525
489
subnets = subnetworks(rn)
526
490
isweaklyreversible(rn, subnets)
527
491
```
528
492
"""
529
493
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)
494
+ nps = get_networkproperties (rn)
495
+ isempty (nps . incidencemat ) && reactioncomplexes (rn)
496
+ sparseig = issparse (nps . incidencemat )
497
+
534
498
for subnet in subnets
535
- nps = get_networkproperties (subnet)
536
- isempty (nps . incidencemat) && reactioncomplexes (subnet; sparse = sparseig)
499
+ subnps = get_networkproperties (subnet)
500
+ isempty (subnps . incidencemat) && reactioncomplexes (subnet; sparse = sparseig)
537
501
end
502
+
503
+ # A network is weakly reversible if all of its subnetworks are strongly connected
538
504
all (Graphs. is_strongly_connected ∘ incidencematgraph, subnets)
539
505
end
540
506
0 commit comments