pub struct TemporalGraph { /* private fields */ }Expand description
A temporal (dynamic) graph stored as a sorted stream of timed edge contacts.
Nodes are identified by consecutive usize indices 0..n_nodes.
Edges are kept sorted by timestamp to enable efficient windowed queries.
§Example
use scirs2_graph::temporal_graph::{TemporalGraph, TemporalEdge};
let mut tg = TemporalGraph::new(4);
tg.add_edge(TemporalEdge::new(0, 1, 1.0));
tg.add_edge(TemporalEdge::new(1, 2, 2.0));
tg.add_edge(TemporalEdge::new(2, 3, 3.0));
let snap = tg.snapshot(0.5, 2.5);
assert_eq!(snap.node_count(), 3); // nodes 0,1,2 appear in edgesImplementations§
Source§impl TemporalGraph
impl TemporalGraph
Sourcepub fn node_count(&self) -> usize
pub fn node_count(&self) -> usize
Alias for [] — returns the number of nodes in this temporal graph.
Provided for compatibility with code expecting a method.
Sourcepub fn sorted_edges_cloned(&self) -> Vec<TemporalEdge>
pub fn sorted_edges_cloned(&self) -> Vec<TemporalEdge>
Sourcepub fn add_edge(&mut self, edge: TemporalEdge)
pub fn add_edge(&mut self, edge: TemporalEdge)
Add a temporal edge. Marks the edge list as unsorted when the new timestamp is earlier than the last stored timestamp.
Sourcepub fn edges(&mut self) -> &[TemporalEdge]
pub fn edges(&mut self) -> &[TemporalEdge]
Return a read-only slice of all temporal edges (in sorted order).
Sourcepub fn edges_in_window(&mut self, t_start: f64, t_end: f64) -> &[TemporalEdge]
pub fn edges_in_window(&mut self, t_start: f64, t_end: f64) -> &[TemporalEdge]
Return an iterator over edges in the time window [t_start, t_end).
Sourcepub fn snapshot(&mut self, t_start: f64, t_end: f64) -> Graph<usize, f64>
pub fn snapshot(&mut self, t_start: f64, t_end: f64) -> Graph<usize, f64>
Build a static (undirected, weighted) snapshot of the temporal graph for
all contacts that fall in the half-open window [t_start, t_end).
Repeated contacts between the same pair of nodes accumulate their weights (or count as 1.0 each when no weight is present).
Sourcepub fn temporal_neighbors(
&mut self,
node: usize,
t_start: f64,
t_end: f64,
) -> Vec<(usize, f64)>
pub fn temporal_neighbors( &mut self, node: usize, t_start: f64, t_end: f64, ) -> Vec<(usize, f64)>
Return all neighbours of node reachable in the time window
[t_start, t_end), together with the earliest contact timestamp.
Both directions of each edge are considered (undirected semantics).
Sourcepub fn temporal_path(
&mut self,
source: usize,
target: usize,
t_start: f64,
t_end: f64,
) -> Option<Vec<usize>>
pub fn temporal_path( &mut self, source: usize, target: usize, t_start: f64, t_end: f64, ) -> Option<Vec<usize>>
Find a time-respecting path from source to target using only edges
with timestamps in [t_start, t_end).
Uses a Dijkstra-like priority queue keyed on the earliest-arrival time at each node, guaranteeing the fastest-arrival (foremost) path.
Returns None when no such path exists.
Sourcepub fn temporal_betweenness(&mut self, t_start: f64, t_end: f64) -> Vec<f64>
pub fn temporal_betweenness(&mut self, t_start: f64, t_end: f64) -> Vec<f64>
Compute temporal betweenness centrality for all nodes.
For each ordered pair (s, t) we find the set of foremost
(earliest-arrival) paths using the method above and give each
intermediate node 1 / |paths| credit.
Returns a vector of length n_nodes.
Sourcepub fn aggregate_graph(&mut self) -> Graph<usize, f64>
pub fn aggregate_graph(&mut self) -> Graph<usize, f64>
Collapse the temporal graph to a static undirected weighted graph by summing contact weights over all time.
Trait Implementations§
Source§impl Clone for TemporalGraph
impl Clone for TemporalGraph
Source§fn clone(&self) -> TemporalGraph
fn clone(&self) -> TemporalGraph
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for TemporalGraph
impl RefUnwindSafe for TemporalGraph
impl Send for TemporalGraph
impl Sync for TemporalGraph
impl Unpin for TemporalGraph
impl UnsafeUnpin for TemporalGraph
impl UnwindSafe for TemporalGraph
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more