pub struct Graph { /* private fields */ }Expand description
A graph represented as an adjacency list
Implementations§
Source§impl Graph
impl Graph
Sourcepub fn add_edge(&mut self, u: usize, v: usize) -> Result<(), &'static str>
pub fn add_edge(&mut self, u: usize, v: usize) -> Result<(), &'static str>
Add an edge between vertices u and v
Sourcepub fn first_zagreb_index(&self) -> usize
pub fn first_zagreb_index(&self) -> usize
Calculate the first Zagreb index of the graph
Sourcepub fn min_degree(&self) -> usize
pub fn min_degree(&self) -> usize
Get the minimum degree of the graph
Sourcepub fn max_degree(&self) -> usize
pub fn max_degree(&self) -> usize
Get the maximum degree of the graph
Sourcepub fn is_k_connected(&self, k: usize, use_exact: bool) -> bool
pub fn is_k_connected(&self, k: usize, use_exact: bool) -> bool
Sourcepub fn is_k_connected_approx(&self, k: usize) -> bool
pub fn is_k_connected_approx(&self, k: usize) -> bool
Check if the graph is k-connected using an approximation algorithm This is faster but may give incorrect results in some cases
Sourcepub fn is_k_connected_exact(&self, k: usize) -> bool
pub fn is_k_connected_exact(&self, k: usize) -> bool
Check if the graph is k-connected using an exact algorithm based on Menger’s theorem This is slower but gives correct results for all graphs
Sourcepub fn independence_number_approx(&self) -> usize
pub fn independence_number_approx(&self) -> usize
Calculate independence number (approximate) Finding the exact independence number is NP-hard, so this is a greedy approximation
Sourcepub fn is_likely_hamiltonian(&self, use_exact_connectivity: bool) -> bool
pub fn is_likely_hamiltonian(&self, use_exact_connectivity: bool) -> bool
Check if the graph is likely Hamiltonian using Theorem 1 from the paper and known graph properties
§Arguments
use_exact_connectivity- Whether to use exact connectivity checking (slower but more accurate)
Sourcepub fn is_likely_traceable(&self, use_exact_connectivity: bool) -> bool
pub fn is_likely_traceable(&self, use_exact_connectivity: bool) -> bool
Check if the graph is likely traceable using Theorem 2 from the paper and known graph properties
§Arguments
use_exact_connectivity- Whether to use exact connectivity checking (slower but more accurate)
Sourcepub fn zagreb_upper_bound(&self) -> f64
pub fn zagreb_upper_bound(&self) -> f64
Calculate upper bound on Zagreb index using Theorem 3 from the paper
Sourcepub fn vertex_count(&self) -> usize
pub fn vertex_count(&self) -> usize
Get the number of vertices
Sourcepub fn edge_count(&self) -> usize
pub fn edge_count(&self) -> usize
Get the number of edges