| Crates.io | scirs2-graph |
| lib.rs | scirs2-graph |
| version | 0.1.0-beta.2 |
| created_at | 2025-04-12 14:20:14.098644+00 |
| updated_at | 2025-09-20 09:00:26.049111+00 |
| description | Graph processing module for SciRS2 (scirs2-graph) |
| homepage | |
| repository | https://github.com/cool-japan/scirs |
| max_upload_size | |
| id | 1630964 |
| size | 1,869,811 |
Production-ready graph processing module for the SciRS2 scientific computing library.
This is the first beta release (0.1.0-beta.2) featuring a comprehensive, high-performance graph theory and network analysis library designed for scientific computing and machine learning applications.
Graph Traversal & Search
Shortest Paths & Connectivity
Network Flow & Matching
Centrality & Importance
Community Detection
Graph Analytics
Multiple format support with robust parsing:
Add to your Cargo.toml:
[dependencies]
scirs2-graph = "0.1.0-beta.2"
For performance features:
[dependencies]
scirs2-graph = { version = "0.1.0-beta.2", features = ["parallel"] }
use scirs2_graph::{Graph, algorithms, measures};
use scirs2_core::error::CoreResult;
fn main() -> CoreResult<()> {
// Create and populate graph
let mut graph = Graph::new();
graph.add_node(1);
graph.add_node(2);
graph.add_node(3);
graph.add_edge(1, 2, 1.0)?;
graph.add_edge(2, 3, 2.0)?;
graph.add_edge(1, 3, 3.0)?;
// Graph analysis
println!("Nodes: {}, Edges: {}", graph.node_count(), graph.edge_count());
// Shortest path
let path = algorithms::shortest_path(&graph, 1, 3)?;
println!("Shortest path 1→3: {:?}", path);
// Centrality analysis
let centrality = measures::centrality::degree_centrality(&graph)?;
println!("Degree centrality: {:?}", centrality);
Ok(())
}
use scirs2_graph::{algorithms, spectral, generators};
fn advanced_analysis() -> CoreResult<()> {
// Generate test network
let graph = generators::barabasi_albert_graph(100, 3)?;
// Community detection
let communities = algorithms::louvain_communities(&graph)?;
println!("Found {} communities", communities.len());
// Spectral clustering
let adj_matrix = graph.adjacency_matrix();
let clusters = spectral::spectral_clustering(&adj_matrix, 5, None, None)?;
// Centrality analysis
let pagerank = algorithms::pagerank(&graph, 0.85, None)?;
let betweenness = algorithms::betweenness_centrality(&graph)?;
Ok(())
}
use scirs2_graph::io;
fn graph_io_example() -> CoreResult<()> {
// Read from various formats
let graph1 = io::read_graphml("network.graphml")?;
let graph2 = io::read_gml("network.gml")?;
let graph3 = io::read_edgelist("edges.txt", false)?;
// Write to different formats
io::write_dot(&graph1, "output.dot")?;
io::write_json(&graph1, "output.json")?;
Ok(())
}
use scirs2_graph::{
// Graph types
Graph, DiGraph, BipartiteGraph, Hypergraph, TemporalGraph,
// Algorithms by category
algorithms::{
shortest_path::dijkstra,
connectivity::connected_components,
community::louvain_communities,
centrality::pagerank,
flow::dinic_max_flow,
matching::maximum_bipartite_matching,
},
// Graph measures
measures::{
degree_centrality,
clustering_coefficient,
graph_density,
},
// Spectral methods
spectral::{
laplacian_matrix,
spectral_clustering,
normalized_cut,
},
// Graph generation
generators::{
erdos_renyi_graph,
barabasi_albert_graph,
watts_strogatz_graph,
},
// I/O operations
io::{
read_graphml, write_graphml,
read_gml, write_gml,
read_edgelist, write_edgelist,
},
};
This library is designed for production use with:
Run validation suite:
cd tests
./run_validation.sh
✅ Production Ready: Comprehensive feature set with extensive testing
✅ API Stable: First beta with stable public interface
✅ Well Documented: Complete API documentation with examples
✅ Performance Optimized: Benchmarked and optimized for real-world use
✅ Numerically Validated: Accuracy verified against reference implementations
Next: Version 1.0 release with additional performance optimizations and extended documentation.
See the project root CLAUDE.md for development guidelines and contribution instructions.
This project is dual-licensed under:
See the LICENSE file for details.