pub struct PetTopologyGraph { /* private fields */ }Expand description
Petgraph-backed implementation of the topology graph.
Implementations§
Trait Implementations§
Source§impl Default for PetTopologyGraph
impl Default for PetTopologyGraph
Source§impl TopologyGraph for PetTopologyGraph
impl TopologyGraph for PetTopologyGraph
Source§fn set_edge(&mut self, from: NodeId, to: NodeId, data: EdgeData)
fn set_edge(&mut self, from: NodeId, to: NodeId, data: EdgeData)
Add or update an edge. If the edge exists, the data is replaced.
Source§fn get_edge_mut(&mut self, from: &NodeId, to: &NodeId) -> Option<&mut EdgeData>
fn get_edge_mut(&mut self, from: &NodeId, to: &NodeId) -> Option<&mut EdgeData>
Get mutable edge data.
Source§fn remove_edge(&mut self, from: &NodeId, to: &NodeId) -> Option<EdgeData>
fn remove_edge(&mut self, from: &NodeId, to: &NodeId) -> Option<EdgeData>
Remove an edge. Returns the removed edge data if it existed.
Source§fn node_count(&self) -> usize
fn node_count(&self) -> usize
Number of nodes.
Source§fn edge_count(&self) -> usize
fn edge_count(&self) -> usize
Number of edges.
Source§fn decay_edges(
&mut self,
rate: f64,
prune_threshold: f64,
) -> Vec<PrunedConnection>
fn decay_edges( &mut self, rate: f64, prune_threshold: f64, ) -> Vec<PrunedConnection>
Decay all edge weights by a rate (0.0-1.0).
Returns edges that fell below the threshold after decay.
Source§fn decay_edges_activity(
&mut self,
base_rate: f64,
prune_threshold: f64,
current_tick: u64,
staleness_factor: f64,
maturation_ticks: u64,
) -> Vec<PrunedConnection>
fn decay_edges_activity( &mut self, base_rate: f64, prune_threshold: f64, current_tick: u64, staleness_factor: f64, maturation_ticks: u64, ) -> Vec<PrunedConnection>
Activity-aware decay: edges that haven’t been co-activated recently decay faster.
Edges younger than
maturation_ticks get base rate only.Source§fn prune_to_max_degree(&mut self, max_degree: usize) -> Vec<PrunedConnection>
fn prune_to_max_degree(&mut self, max_degree: usize) -> Vec<PrunedConnection>
Competitive pruning: for each node, keep only top
max_degree edges by weight.
An edge survives if EITHER endpoint keeps it in their top-K.Source§fn find_nodes_by_label(&self, query: &str) -> Vec<NodeId>
fn find_nodes_by_label(&self, query: &str) -> Vec<NodeId>
Find nodes matching a label (substring match).
Source§fn shortest_path(
&self,
from: &NodeId,
to: &NodeId,
) -> Option<(Vec<NodeId>, f64)>
fn shortest_path( &self, from: &NodeId, to: &NodeId, ) -> Option<(Vec<NodeId>, f64)>
Find the shortest weighted path between two nodes.
Returns (path_of_node_ids, total_weight). Uses inverse weight as cost
so stronger edges are preferred.
Source§fn betweenness_centrality(&self, sample_size: usize) -> Vec<(NodeId, f64)>
fn betweenness_centrality(&self, sample_size: usize) -> Vec<(NodeId, f64)>
Compute betweenness centrality for all nodes (approximate, sampled).
Returns (node_id, centrality_score) sorted descending by centrality.
Centrality measures how often a node lies on shortest paths between
other node pairs — high centrality = hub/bridge concept.
Source§fn bridge_nodes(&self, top_k: usize) -> Vec<(NodeId, f64)>
fn bridge_nodes(&self, top_k: usize) -> Vec<(NodeId, f64)>
Find bridge nodes whose removal would most increase graph fragmentation.
Returns (node_id, fragility_score) sorted descending.
Fragility = (components_after_removal - components_before) / node_degree.
Source§fn connected_components(&self) -> usize
fn connected_components(&self) -> usize
Count connected components in the graph.
Auto Trait Implementations§
impl Freeze for PetTopologyGraph
impl RefUnwindSafe for PetTopologyGraph
impl Send for PetTopologyGraph
impl Sync for PetTopologyGraph
impl Unpin for PetTopologyGraph
impl UnwindSafe for PetTopologyGraph
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more