Skip to main content

PetTopologyGraph

Struct PetTopologyGraph 

Source
pub struct PetTopologyGraph { /* private fields */ }
Expand description

Petgraph-backed implementation of the topology graph.

Implementations§

Source§

impl PetTopologyGraph

Source

pub fn new() -> Self

Source

pub fn find_nodes_by_exact_label(&self, label: &str) -> &[NodeId]

O(1) exact label lookup (case-insensitive).

Trait Implementations§

Source§

impl Default for PetTopologyGraph

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl TopologyGraph for PetTopologyGraph

Source§

fn add_node(&mut self, data: NodeData) -> NodeId

Add a node and return its ID.
Source§

fn get_node(&self, id: &NodeId) -> Option<&NodeData>

Get node data by ID.
Source§

fn get_node_mut(&mut self, id: &NodeId) -> Option<&mut NodeData>

Get mutable node data by ID.
Source§

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(&self, from: &NodeId, to: &NodeId) -> Option<&EdgeData>

Get edge data.
Source§

fn get_edge_mut(&mut self, from: &NodeId, to: &NodeId) -> Option<&mut EdgeData>

Get mutable edge data.
Source§

fn neighbors(&self, node: &NodeId) -> Vec<(NodeId, &EdgeData)>

Get all neighbors of a node.
Source§

fn remove_edge(&mut self, from: &NodeId, to: &NodeId) -> Option<EdgeData>

Remove an edge. Returns the removed edge data if it existed.
Source§

fn all_nodes(&self) -> Vec<NodeId>

Get all node IDs.
Source§

fn all_edges(&self) -> Vec<(NodeId, NodeId, &EdgeData)>

Get all edges.
Source§

fn node_count(&self) -> usize

Number of nodes.
Source§

fn edge_count(&self) -> usize

Number of edges.
Source§

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>

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>

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>

Find nodes matching a label (substring match).
Source§

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)>

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)>

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

Count connected components in the graph.
Source§

fn find_nodes_by_exact_label(&self, label: &str) -> Vec<NodeId>

Find nodes with an exact label match (case-insensitive). Default implementation falls back to find_nodes_by_label with filtering.
Source§

fn louvain_communities(&self) -> LouvainResult

Detect communities using the Louvain algorithm. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.