1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
//! `oxygraph` is a crate to aid in the analysis
//! of ecological bipartite graphs. Still in development
//! and *might* support other ecological graph types in the
//! future.
//!
//! Creation of `BipartiteGraph` structs can be done through
//! an input TSV:
//!
//! ```rust
//! use oxygraph;
//! use oxygraph::bipartite::Strata;
//! use std::path::PathBuf;
//!
//! let path = PathBuf::from("./path/to/bipartite.tsv");
//!
//! // load into a BipartiteGraph structure
//! // a quick peek at the source codes shows you
//! // it's a thin wrapper over `petgraph`.
//! let bpgraph = oxygraph::BipartiteGraph::from_dsv(&path, b'\t').unwrap();
//!
//! // check it's bipartite
//! let check = match bpgraph.is_bipartite() {
//! Strata::Yes(_) => "it's bipartite!",
//! Strata::No => "it's not bipartite :(",
//! };
//!
//!
//! // create an interaction matrix
//! let int_mat = oxygraph::InteractionMatrix::from_bipartite(bpgraph);
//! // and look at some basic stats
//! let stats = int_mat.stats();
//!
//! ```
//!
//! Or by creating a `petgraph` graph e.g.:
//!
//! ```rust
//! use petgraph::Graph;
//! use oxygraph::BipartiteGraph;
//! use oxygraph::bipartite::SpeciesNode;
//!
//! let mut graph: Graph<SpeciesNode, f64> = Graph::new();
//!
//! // add nodes/edges etc...
//!
//! // now wrap in `BipartiteGraph` and access
//! // all the methods associated.
//! let bpgraph = BipartiteGraph(graph);
//!
//! ```
//!
//! More information and tutorials to follow.
/// Create, analyse, and visualise bipartite
/// graphs from tab delimited input data.
pub use BipartiteGraph;
pub use BipartiteStats;
/// Create, analyse, and visualise
/// interaction matrices generated from a
/// `BipartiteGraph`.
pub use InteractionMatrix;
pub use InteractionMatrixStats;
/// The derived graphs of a bipartite graph.
///
/// There are two derived graphs, one for each stratum,
/// and the edges in the graph correspond to how frequent
/// shared connections are between two nodes in that stratum.
pub use DerivedGraphStats;
pub use DerivedGraphs;
/// Modularity calculations are in their own module, but they
/// are built on top of an interaction matrix. Included are
/// two algorithms from Beckett 2016.
pub use LpaWbPlus;
/// Sorting algorithms on arrays.
/// The margins for the all the graph plots
/// used in this crate.
const MARGIN_LR: f64 = 20.0;
/// Scale a number between zero and 1, given a min/max.