Skip to main content

rust_igraph/
lib.rs

1//! # rust-igraph
2//!
3//! Pure-Rust port of the [igraph](https://igraph.org) network analysis
4//! library. Targets full API parity with igraph C v1.0.x (~850 public
5//! functions), validated continuously against the three official
6//! implementations (igraph C, python-igraph, R-igraph).
7//!
8//! > **Status**: alpha — only the Phase 0 walking-skeleton API is shipped
9//! > (`Graph`, `read_edgelist`, `bfs`). The catalog grows
10//! > algorithm-by-algorithm through Phase 1-10. See the project's
11//! > [master plan](https://github.com/Totoro-jam/rust-igraph/blob/main/docs/plans/MASTER_PLAN.md).
12//!
13//! ## Quick start
14//!
15//! ```
16//! use rust_igraph::{Graph, bfs};
17//!
18//! let mut g = Graph::with_vertices(4);
19//! g.add_edge(0, 1).unwrap();
20//! g.add_edge(0, 2).unwrap();
21//! g.add_edge(1, 3).unwrap();
22//!
23//! let order = bfs(&g, 0).unwrap();
24//! assert_eq!(order, vec![0, 1, 2, 3]);
25//! ```
26//!
27//! ## License
28//!
29//! GPL-2.0-or-later, matching upstream igraph.
30
31pub mod algorithms;
32pub mod core;
33
34// Top-level re-exports for the common case.
35// IMPORTANT: when a function name collides with the file/module it
36// lives in (e.g. `is_simple` in `is_simple.rs`), `pub use
37// crate::algorithms::properties::is_simple` resolves ambiguously to
38// **both** the module and the function, and rustdoc renders the
39// re-export twice on the crate-root page. To suppress that, every
40// re-export below points at the inner module path explicitly so the
41// resolution is unambiguously the function. The submodules
42// themselves are `pub(crate)` (see each algorithm-group `mod.rs`),
43// so the deep paths stay crate-internal at the type-checker level
44// while rustdoc only renders the function entry.
45pub use crate::algorithms::community::modularity::{
46    modularity, modularity_directed, modularity_weighted,
47};
48pub use crate::algorithms::connectivity::articulation::articulation_points;
49pub use crate::algorithms::connectivity::biconnected::{
50    BiconnectedComponents, biconnected_components,
51};
52pub use crate::algorithms::connectivity::bridges::bridges;
53pub use crate::algorithms::connectivity::components::{ConnectedComponents, connected_components};
54pub use crate::algorithms::connectivity::decompose::decompose;
55pub use crate::algorithms::connectivity::is_biconnected::is_biconnected;
56pub use crate::algorithms::connectivity::percolation::{
57    EdgelistPercolation, SitePercolation, bond_percolation, edgelist_percolation, site_percolation,
58};
59pub use crate::algorithms::connectivity::reachability::count_reachable;
60pub use crate::algorithms::connectivity::reachability_matrix::reachability_matrix;
61pub use crate::algorithms::connectivity::strong::strongly_connected_components;
62pub use crate::algorithms::connectivity::transitive_closure::transitive_closure;
63pub use crate::algorithms::io::edgelist::read_edgelist;
64pub use crate::algorithms::operators::complementer::complementer;
65pub use crate::algorithms::operators::difference::difference;
66pub use crate::algorithms::operators::disjoint_union::{disjoint_union, disjoint_union_many};
67pub use crate::algorithms::operators::intersection::intersection;
68pub use crate::algorithms::operators::is_same_graph::is_same_graph;
69pub use crate::algorithms::operators::simplify::simplify;
70pub use crate::algorithms::operators::union::union;
71pub use crate::algorithms::paths::astar::a_star_path;
72pub use crate::algorithms::paths::bellman_ford::{
73    bellman_ford_distances, bellman_ford_distances_with_mode,
74};
75pub use crate::algorithms::paths::dijkstra::{
76    DijkstraAllPaths, DijkstraMode, DijkstraPaths, dijkstra_all_shortest_paths, dijkstra_distances,
77    dijkstra_distances_cutoff, dijkstra_distances_cutoff_with_mode, dijkstra_distances_multi,
78    dijkstra_distances_multi_with_mode, dijkstra_distances_with_mode, dijkstra_path_to,
79    dijkstra_path_to_with_mode, dijkstra_paths, dijkstra_paths_with_mode,
80};
81pub use crate::algorithms::paths::distances::distances;
82pub use crate::algorithms::paths::eulerian::{EulerianClassification, is_eulerian};
83pub use crate::algorithms::paths::eulerian_construct::eulerian_path;
84pub use crate::algorithms::paths::floyd_warshall::floyd_warshall_distances;
85pub use crate::algorithms::paths::johnson::johnson_distances;
86pub use crate::algorithms::paths::radii::{
87    EccMode, diameter, diameter_weighted, diameter_weighted_with_mode, diameter_with_mode,
88    eccentricity, eccentricity_weighted, eccentricity_weighted_with_mode, eccentricity_with_mode,
89    radius, radius_weighted, radius_weighted_with_mode, radius_with_mode,
90};
91pub use crate::algorithms::paths::random_walk::random_walk;
92pub use crate::algorithms::paths::widest_path::{
93    WidestPathResult, WidestPaths, widest_path, widest_path_widths,
94    widest_path_widths_floyd_warshall, widest_path_widths_floyd_warshall_with_mode,
95    widest_path_widths_with_mode, widest_path_with_mode, widest_paths, widest_paths_to,
96    widest_paths_to_with_mode, widest_paths_with_mode,
97};
98pub use crate::algorithms::properties::assortativity::{
99    assortativity_degree, assortativity_degree_directed,
100};
101pub use crate::algorithms::properties::assortativity_weighted::{
102    assortativity_degree_directed_weighted, assortativity_degree_weighted,
103};
104pub use crate::algorithms::properties::basic::{density, mean_distance};
105pub use crate::algorithms::properties::betweenness::betweenness;
106pub use crate::algorithms::properties::betweenness_weighted::betweenness_weighted;
107pub use crate::algorithms::properties::closeness::closeness;
108pub use crate::algorithms::properties::closeness_weighted::closeness_weighted;
109pub use crate::algorithms::properties::convergence_degree::{
110    convergence_degree, convergence_degree_full,
111};
112pub use crate::algorithms::properties::coreness::{CorenessMode, coreness, coreness_with_mode};
113pub use crate::algorithms::properties::edge_betweenness::edge_betweenness;
114pub use crate::algorithms::properties::edge_betweenness_weighted::edge_betweenness_weighted;
115pub use crate::algorithms::properties::efficiency::{
116    average_local_efficiency, global_efficiency, local_efficiency,
117};
118pub use crate::algorithms::properties::eigenvector::eigenvector_centrality;
119pub use crate::algorithms::properties::girth::girth;
120pub use crate::algorithms::properties::harmonic::harmonic_centrality;
121pub use crate::algorithms::properties::harmonic_weighted::harmonic_centrality_weighted;
122pub use crate::algorithms::properties::is_acyclic::is_acyclic;
123pub use crate::algorithms::properties::is_complete::is_complete;
124pub use crate::algorithms::properties::is_dag::is_dag;
125pub use crate::algorithms::properties::is_forest::is_forest;
126pub use crate::algorithms::properties::is_simple::{SimpleMode, is_simple, is_simple_with_mode};
127pub use crate::algorithms::properties::is_tree::is_tree;
128pub use crate::algorithms::properties::knn::{
129    avg_nearest_neighbor_degree, avg_nearest_neighbor_degree_weighted, knnk, knnk_weighted,
130};
131pub use crate::algorithms::properties::multiplicity::{
132    count_loops, count_multiple, has_loop, has_multiple, is_loop, is_multiple,
133};
134pub use crate::algorithms::properties::neighborhood::{
135    NeighborhoodMode, neighborhood, neighborhood_size, neighborhood_size_with_mode,
136    neighborhood_with_mode,
137};
138pub use crate::algorithms::properties::pagerank::pagerank;
139pub use crate::algorithms::properties::pagerank_weighted::pagerank_weighted;
140pub use crate::algorithms::properties::reciprocity::{
141    ReciprocityMode, reciprocity, reciprocity_with_mode,
142};
143pub use crate::algorithms::properties::topological_sorting::topological_sorting;
144pub use crate::algorithms::properties::triangles::{
145    count_adjacent_triangles, count_triangles, transitivity_barrat, transitivity_local_undirected,
146    transitivity_undirected,
147};
148pub use crate::algorithms::traversal::bfs::{BfsTree, bfs, bfs_tree};
149pub use crate::algorithms::traversal::dfs::dfs;
150pub use crate::core::error::{IgraphError, IgraphResult};
151pub use crate::core::graph::{Graph, VertexId};