Skip to main content

hypergraph_rs/readwrite/
mod.rs

1//! Read/write hypergraphs in various formats (XGI `xgi/readwrite/*.py` port).
2
3pub mod bigg;
4pub mod bipartite;
5pub mod edgelist;
6pub mod hif;
7pub mod incidence;
8
9use thiserror::Error;
10
11/// Error raised by a read/write operation.
12#[derive(Debug, Error)]
13pub enum ReadWriteError {
14    /// The underlying file could not be read or written.
15    #[error("I/O error: {0}")]
16    Io(#[from] std::io::Error),
17    /// The bytes were not valid JSON.
18    #[error("JSON error: {0}")]
19    Json(#[from] serde_json::Error),
20    /// The data was structurally invalid for the target format.
21    #[error("format error: {0}")]
22    Format(String),
23}
24
25pub use bigg::bigg_dict_to_dihypergraph;
26pub use bipartite::{parse_bipartite_edgelist, read_bipartite_edgelist, write_bipartite_edgelist};
27pub use edgelist::{parse_edgelist, read_edgelist, write_edgelist};
28pub use hif::{from_hif_dict, read_hif, to_hif_dict, write_hif};
29pub use incidence::{read_incidence_matrix, write_incidence_matrix};