Skip to main content

Crate scirs2_graph

Crate scirs2_graph 

Source
Expand description

ยงSciRS2 Graph - Graph Algorithms and Network Analysis

scirs2-graph provides comprehensive graph algorithms and data structures for network analysis, offering shortest paths, centrality measures, community detection, spectral methods, and graph embeddings with parallel processing and memory-efficient implementations.

ยง๐ŸŽฏ Key Features

  • Graph Representations: Directed, undirected, weighted, multi-graphs
  • Classic Algorithms: BFS, DFS, Dijkstra, A*, Bellman-Ford, Floyd-Warshall
  • Centrality Measures: Betweenness, closeness, eigenvector, PageRank
  • Community Detection: Louvain, label propagation, spectral clustering
  • Spectral Methods: Graph Laplacian, spectral clustering, graph embeddings
  • Network Metrics: Clustering coefficient, diameter, average path length
  • Performance: Parallel algorithms, memory profiling

ยง๐Ÿ“ฆ Module Overview

SciRS2 ModuleNetworkX/igraph EquivalentDescription
algorithmsnetworkx.algorithmsCore graph algorithms (BFS, DFS, shortest paths)
measuresnetworkx.centralityCentrality and network metrics
spectralscipy.sparse.linalgSpectral graph theory and embeddings
generatorsnetworkx.generatorsGraph generation (random, regular, etc.)
ionetworkx.readwriteGraph I/O (GML, GraphML, edge lists)

ยง๐Ÿš€ Quick Start

[dependencies]
scirs2-graph = "0.4.3"
use scirs2_graph::{Graph, breadth_first_search, betweenness_centrality};

// Create graph and run BFS
let mut g: Graph<i32, f64> = Graph::new();
let n0 = g.add_node(0);
let n1 = g.add_node(1);
g.add_edge(0, 1, 1.0);

ยง๐Ÿ”’ Version: 0.4.3

ยงAPI Stability and Versioning

scirs2-graph follows strict semantic versioning with clear stability guarantees:

ยงStability Classifications

  • โœ… Stable: Core APIs guaranteed until next major version (2.0.0)
  • โš ๏ธ Experimental: May change in minor versions, marked with #[cfg(feature = "experimental")]
  • ๐Ÿ“‹ Deprecated: Will be removed in next major version, use alternatives

ยงVersion Guarantees

  • MAJOR (1.x.x โ†’ 2.x.x): Breaking changes to stable APIs allowed
  • MINOR (1.0.x โ†’ 1.1.x): New features, deprecations only (no breaks to stable APIs)
  • PATCH (1.0.0 โ†’ 1.0.1): Bug fixes only, no API changes

ยงStable Core APIs (v0.4.0+)

  • Graph data structures (Graph, DiGraph, MultiGraph)
  • Basic algorithms (traversal, shortest paths, connectivity)
  • Graph generators and I/O operations
  • Community detection with _result suffix functions
  • Error handling and core types

Re-exportsยง

pub use algorithms::articulation_points;
pub use algorithms::astar_search_digraph;
pub use algorithms::betweenness_centrality;
pub use algorithms::bidirectional_search_digraph;
pub use algorithms::breadth_first_search_digraph;
pub use algorithms::bridges;
pub use algorithms::capacity_scaling_max_flow;
pub use algorithms::center_nodes;
pub use algorithms::closeness_centrality;
pub use algorithms::complement;
pub use algorithms::connected_components;
pub use algorithms::cosine_similarity;
pub use algorithms::depth_first_search_digraph;
pub use algorithms::diameter;
pub use algorithms::dijkstra_path;
pub use algorithms::dinic_max_flow;
pub use algorithms::dinic_max_flow_full;
pub use algorithms::edge_subgraph;
pub use algorithms::edmonds_karp_max_flow;
pub use algorithms::eigenvector_centrality;
pub use algorithms::eulerian_type;
pub use algorithms::floyd_warshall;
pub use algorithms::floyd_warshall_digraph;
pub use algorithms::fluid_communities_result;
pub use algorithms::ford_fulkerson_max_flow;
pub use algorithms::girvan_newman_communities_result;
pub use algorithms::girvan_newman_result;
pub use algorithms::greedy_coloring;
pub use algorithms::greedy_modularity_optimization_result;
pub use algorithms::hierarchical_communities_result;
pub use algorithms::hopcroft_karp;
pub use algorithms::infomap_communities;
pub use algorithms::is_bipartite;
pub use algorithms::isap_max_flow;
pub use algorithms::jaccard_similarity;
pub use algorithms::k_core_decomposition;
pub use algorithms::k_shortest_paths;
pub use algorithms::label_propagation_result;
pub use algorithms::line_digraph;
pub use algorithms::line_graph;
pub use algorithms::louvain_communities_result;
pub use algorithms::maximal_matching;
pub use algorithms::maximum_bipartite_matching;
pub use algorithms::maximum_cardinality_matching;
pub use algorithms::min_cost_max_flow;
pub use algorithms::min_cost_max_flow_graph;
pub use algorithms::minimum_cut;
pub use algorithms::minimum_spanning_tree;
pub use algorithms::minimum_st_cut;
pub use algorithms::minimum_weight_bipartite_matching;
pub use algorithms::modularity;
pub use algorithms::modularity;
pub use algorithms::modularity_optimization_result;
pub use algorithms::multi_commodity_flow;
pub use algorithms::multi_source_multi_sink_max_flow;
pub use algorithms::pagerank;
pub use algorithms::parallel_max_flow;
pub use algorithms::personalized_pagerank;
pub use algorithms::push_relabel_max_flow;
pub use algorithms::push_relabel_max_flow_full;
pub use algorithms::radius;
pub use algorithms::random_walk;
pub use algorithms::random_walk;
pub use algorithms::stable_marriage;
pub use algorithms::strongly_connected_components;
pub use algorithms::subdigraph;
pub use algorithms::subgraph;
pub use algorithms::tensor_product;
pub use algorithms::topological_sort;
pub use algorithms::transition_matrix;
pub use algorithms::weight_filtered_subgraph;
pub use algorithms::AStarResult;
pub use algorithms::BipartiteMatching;
pub use algorithms::BipartiteResult;
pub use algorithms::CommunityResult;
pub use algorithms::CommunityStructure;
pub use algorithms::CostEdge;
pub use algorithms::DendrogramLevel;
pub use algorithms::EulerianType;
pub use algorithms::GirvanNewmanConfig;
pub use algorithms::GirvanNewmanResult;
pub use algorithms::GraphColoring;
pub use algorithms::HopcroftKarpResult;
pub use algorithms::InfomapResult;
pub use algorithms::MaxFlowResult;
pub use algorithms::MaximumMatching;
pub use algorithms::MinCostFlowResult;
pub use algorithms::MotifType;
pub use algorithms::MultiCommodityFlowResult;
pub use algorithms::parallel_label_propagation_result;
pub use algorithms::parallel_louvain_communities_result;
pub use algorithms::parallel_modularity;
pub use spectral::parallel_laplacian;
pub use spectral::parallel_spectral_clustering;
pub use algorithms::are_graphs_isomorphic;
pub use algorithms::are_graphs_isomorphic_enhanced;
pub use algorithms::cartesian_product;
pub use algorithms::chromatic_number;
pub use algorithms::find_isomorphism;
pub use algorithms::find_isomorphism_vf2;
pub use algorithms::find_motifs;
pub use algorithms::find_subgraph_matches;
pub use algorithms::graph_edit_distance;
pub use algorithms::has_hamiltonian_circuit;
pub use algorithms::has_hamiltonian_path;
pub use algorithms::coloring::chromatic_bounds;
pub use algorithms::coloring::dsatur_coloring;
pub use algorithms::coloring::edge_coloring;
pub use algorithms::coloring::greedy_coloring_with_order;
pub use algorithms::coloring::list_coloring;
pub use algorithms::coloring::verify_coloring;
pub use algorithms::coloring::welsh_powell;
pub use algorithms::coloring::ChromaticBounds;
pub use algorithms::coloring::ColoringOrder;
pub use algorithms::coloring::EdgeColoring;
pub use algorithms::coloring::ListColoring;
pub use algorithms::motifs::count_3node_motifs;
pub use algorithms::motifs::count_4node_motifs;
pub use algorithms::motifs::count_motif_frequencies;
pub use algorithms::motifs::frequent_subgraph_mining;
pub use algorithms::motifs::graphlet_degree_distribution;
pub use algorithms::motifs::sample_motif_frequencies;
pub use algorithms::motifs::vf2_subgraph_isomorphism;
pub use algorithms::motifs::wl_subtree_kernel;
pub use algorithms::motifs::FrequentPattern;
pub use algorithms::motifs::GraphletDDResult;
pub use algorithms::motifs::GraphletDegreeVector;
pub use algorithms::motifs::VF2Result;
pub use algorithms::motifs::WLKernelResult;
pub use link_prediction::adamic_adar_all;
pub use link_prediction::adamic_adar_index;
pub use link_prediction::common_neighbors_all;
pub use link_prediction::common_neighbors_score;
pub use link_prediction::compute_auc;
pub use link_prediction::jaccard_coefficient;
pub use link_prediction::jaccard_coefficient_all;
pub use link_prediction::katz_similarity;
pub use link_prediction::katz_similarity_all;
pub use link_prediction::preferential_attachment;
pub use link_prediction::preferential_attachment_all;
pub use link_prediction::resource_allocation_all;
pub use link_prediction::resource_allocation_index;
pub use link_prediction::simrank;
pub use link_prediction::simrank_score;
pub use link_prediction::LinkPredictionConfig;
pub use link_prediction::LinkPredictionEval;
pub use link_prediction::LinkScore;
pub use base::BipartiteGraph;
pub use base::DiGraph;
pub use base::Edge;
pub use base::EdgeWeight;
pub use base::Graph;
pub use base::Hyperedge;
pub use base::Hypergraph;
pub use base::MultiDiGraph;
pub use base::MultiGraph;
pub use base::Node;
pub use error::ErrorContext;
pub use error::GraphError;
pub use error::Result;
pub use generators::barabasi_albert_graph;
pub use generators::complete_graph;
pub use generators::cycle_graph;
pub use generators::erdos_renyi_graph;
pub use generators::grid_2d_graph;
pub use generators::grid_3d_graph;
pub use generators::hexagonal_lattice_graph;
pub use generators::path_graph;
pub use generators::planted_partition_model;
pub use generators::power_law_cluster_graph;
pub use generators::random_geometric_graph;
pub use generators::star_graph;
pub use generators::stochastic_block_model;
pub use generators::triangular_lattice_graph;
pub use generators::two_community_sbm;
pub use generators::watts_strogatz_graph;
pub use measures::centrality;
pub use measures::clustering_coefficient;
pub use measures::graph_density;
pub use measures::hits_algorithm;
pub use measures::katz_centrality;
pub use measures::katz_centrality_digraph;
pub use measures::pagerank_centrality;
pub use measures::pagerank_centrality_digraph;
pub use measures::CentralityType;
pub use measures::HitsScores;
pub use measures::parallel_pagerank_centrality;
pub use spectral::laplacian;
pub use spectral::normalized_cut;
pub use spectral::spectral_radius;
pub use weighted::MultiWeight;
pub use weighted::NormalizationMethod;
pub use weighted::WeightStatistics;
pub use weighted::WeightTransform;
pub use weighted::WeightedOps;
pub use attributes::AttributeSummary;
pub use attributes::AttributeValue;
pub use attributes::AttributeView;
pub use attributes::AttributedDiGraph;
pub use attributes::AttributedGraph;
pub use attributes::Attributes;
pub use memory::suggest_optimizations;
pub use memory::BitPackedGraph;
pub use memory::CSRGraph;
pub use memory::CompressedAdjacencyList;
pub use memory::FragmentationReport;
pub use memory::HybridGraph;
pub use memory::MemoryProfiler;
pub use memory::MemorySample;
pub use memory::MemoryStats;
pub use memory::OptimizationSuggestions;
pub use memory::OptimizedGraphBuilder;
pub use performance::LargeGraphIterator;
pub use performance::LargeGraphOps;
pub use performance::MemoryMetrics;
pub use performance::ParallelConfig;
pub use performance::PerformanceMonitor;
pub use performance::PerformanceReport;
pub use performance::StreamingGraphProcessor;
pub use embeddings::DeepWalk;
pub use embeddings::DeepWalkConfig;
pub use embeddings::DeepWalkMode;
pub use embeddings::Embedding;
pub use embeddings::EmbeddingModel;
pub use embeddings::LINEConfig;
pub use embeddings::LINEOrder;
pub use embeddings::Node2Vec;
pub use embeddings::Node2VecConfig;
pub use embeddings::RandomWalk;
pub use embeddings::RandomWalkGenerator;
pub use embeddings::SpectralEmbedding;
pub use embeddings::SpectralEmbeddingConfig;
pub use embeddings::SpectralLaplacianType;
pub use embeddings::LINE;
pub use layout::circular_layout;
pub use layout::hierarchical_layout;
pub use layout::spectral_layout;
pub use layout::spring_layout;
pub use layout::Position;
pub use temporal::count_temporal_triangles;
pub use temporal::evolutionary_clustering;
pub use temporal::temporal_betweenness;
pub use temporal::temporal_closeness;
pub use temporal::temporal_motif_count;
pub use temporal::temporal_pagerank;
pub use temporal::DynamicCommunity;
pub use temporal::TemporalEdge as StreamTemporalEdge;
pub use temporal::TemporalGraph as StreamTemporalGraph;
pub use temporal::TemporalMotifCounts;
pub use temporal_interval::temporal_betweenness_centrality;
pub use temporal_interval::temporal_reachability;
pub use temporal_interval::TemporalGraph;
pub use temporal_interval::TemporalPath;
pub use temporal_interval::TimeInstant;
pub use temporal_interval::TimeInterval;
pub use advanced::create_advanced_processor;
pub use advanced::execute_with_advanced;
pub use advanced::AdvancedConfig;
pub use advanced::AdvancedProcessor;
pub use advanced::AdvancedStats;
pub use advanced::AlgorithmMetrics;
pub use advanced::GPUAccelerationContext;
pub use advanced::NeuralRLAgent;
pub use advanced::NeuromorphicProcessor;
pub use graph_memory_profiler::AdvancedMemoryProfiler;
pub use graph_memory_profiler::EfficiencyAnalysis;
pub use graph_memory_profiler::MemoryProfile;
pub use graph_memory_profiler::MemoryProfilerConfig;
pub use graph_memory_profiler::MemoryStats as GraphMemoryStats;
pub use graph_memory_profiler::OptimizationOpportunity;
pub use graph_memory_profiler::OptimizationType;
pub use numerical_accuracy_validation::create_comprehensive_validation_suite;
pub use numerical_accuracy_validation::run_quick_validation;
pub use numerical_accuracy_validation::AdvancedNumericalValidator;
pub use numerical_accuracy_validation::ValidationAlgorithm;
pub use numerical_accuracy_validation::ValidationConfig;
pub use numerical_accuracy_validation::ValidationReport;
pub use numerical_accuracy_validation::ValidationResult;
pub use numerical_accuracy_validation::ValidationTolerances;
pub use compressed::AdjacencyList;
pub use compressed::CsrGraph;
pub use compressed::CsrGraphBuilder;
pub use compressed::NeighborIter;
pub use parallel_algorithms::bfs;
pub use parallel_algorithms::connected_components as csr_connected_components;
pub use parallel_algorithms::pagerank as csr_pagerank;
pub use parallel_algorithms::triangle_count;
pub use parallel_algorithms::BfsResult;
pub use parallel_algorithms::ComponentsResult;
pub use parallel_algorithms::PageRankConfig;
pub use parallel_algorithms::PageRankResult;
pub use parallel_algorithms::TriangleCountResult;
pub use parallel_algorithms::parallel_bfs;
pub use parallel_algorithms::parallel_connected_components;
pub use parallel_algorithms::parallel_pagerank;
pub use parallel_algorithms::parallel_triangle_count;
pub use streaming::DegreeDistribution;
pub use streaming::DoulionTriangleCounter;
pub use streaming::EvictionStrategy;
pub use streaming::MascotTriangleCounter;
pub use streaming::MemoryBoundedConfig;
pub use streaming::MemoryBoundedProcessor;
pub use streaming::SlidingWindowGraph;
pub use streaming::StreamEdge;
pub use streaming::StreamEvent;
pub use streaming::StreamOp;
pub use streaming::StreamingGraph;
pub use streaming::TriangleCounterStats;
pub use io::*;

Modulesยง

advanced
Advanced Mode Integration for Graph Processing
algebraic
Algebraic graph theory.
algorithms
Graph algorithms
alignment
Network alignment algorithms for finding correspondences between graphs.
attributed_graph
Attributed graphs with typed node and edge features
attributes
Node and edge attribute system
base
Base graph structures and operations
centrality
Extended centrality measures for graph analysis.
community
Community detection algorithms operating on weighted adjacency matrices.
compat
NetworkX Migration Utilities
compressed
Compressed Sparse Row (CSR) graph representation for large-scale graphs
condensation
Graph condensation (dataset distillation for graphs).
diffusion
Information diffusion models and influence maximization algorithms
distributed
Distributed graph storage with partitioned adjacency.
domination
Graph domination and covering problems.
dynamic
Dynamic graph analysis: temporal networks and streaming algorithms.
embeddings
Graph embedding algorithms and utilities
error
Error types for the graph processing module
flow
Standalone network flow algorithms (integer-capacity, index-based API).
generators
Graph generation algorithms
gnn
Graph Neural Network (GNN) layers and message-passing framework
gpu
GPU-accelerated and parallel graph algorithms.
graph_memory_profiler
Memory Usage Profiler for Advanced Mode
graph_transformer
Graph Transformer models: GraphGPS and Graphormer.
heterogeneous
Heterogeneous graphs with multiple node and edge types
hypergraph
Hypergraph algorithms and simplicial complexes.
io
Input/output operations for graphs
isomorphism
Graph isomorphism algorithms โ€” WL hash and canonical labelling
knowledge_graph
Knowledge Graph Embedding models
layout
Graph layout algorithms for visualization
link_prediction
Link prediction algorithms for graph analysis
measures
Graph measures and metrics
memory
Memory profiling and optimization utilities for graph data structures
network_statistics
Network-level statistics and structural measures
numerical_accuracy_validation
Numerical Accuracy Validation for Advanced Mode
parallel_algorithms
Parallel graph algorithms for large-scale graph analytics
partitioning
Large-scale graph partitioning algorithms.
performance
Performance optimizations for large graph operations
planarity
Graph planarity testing and related algorithms.
reliability
Network reliability analysis.
sampling
Graph Sampling Algorithms
signal_processing
Graph Signal Processing (GSP) module.
signed_directed
Signed and directed graph learning with specialised embeddings.
simd_ops
SIMD-accelerated operations for graph algorithms
social
Social network analysis algorithms
spectral
Spectral graph theory operations
spectral_graph
Spectral graph theory โ€” adjacency-matrix-based API.
ssl
Graph Self-Supervised Learning (SSL) methods.
streaming
Streaming graph processing โ€” core module and advanced algorithms.
temporal
Temporal graph analysis algorithms (stream model, f64 timestamps)
temporal_graph
Temporal and Dynamic Graphs
temporal_interval
Temporal graph structures and algorithms
traversal
Enhanced graph traversal algorithms on adjacency matrices.
visualization
Graph visualization with layout algorithms and SVG export
weighted
Specialized weighted graph operations and analysis

Traitsยง

IndexType
Trait for the unsigned integer type used for node and edge indices.