pub struct TemporalGraph {
pub nodes: usize,
pub edges: Vec<TemporalEdge>,
/* private fields */
}Expand description
Temporal graph in the stream-of-interactions model.
Stores a sorted sequence of TemporalEdge contacts; nodes are identified
by consecutive usize indices 0..nodes.
§Example
use scirs2_graph::temporal::TemporalGraph;
use scirs2_graph::temporal::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));
// Static snapshot of interactions in [0.5, 2.5)
let snap = tg.snapshot(0.5, 2.5);
assert!(snap.edge_count() >= 1);Fields§
§nodes: usizeTotal number of nodes (fixed at construction; node indices are 0..nodes)
edges: Vec<TemporalEdge>Edge stream, sorted by timestamp
Implementations§
Source§impl TemporalGraph
impl TemporalGraph
Sourcepub fn add_edge(&mut self, edge: TemporalEdge)
pub fn add_edge(&mut self, edge: TemporalEdge)
Add a temporal edge. The internal list is lazily re-sorted when queried.
Sourcepub fn time_ordered_edges(&mut self) -> &[TemporalEdge]
pub fn time_ordered_edges(&mut self) -> &[TemporalEdge]
Return all edges in sorted order.
Sourcepub fn edges_slice(&self) -> &[TemporalEdge]
pub fn edges_slice(&self) -> &[TemporalEdge]
Borrow edges without sorting (useful if you know they are already sorted).
Sourcepub fn edges_in_window(&mut self, start: f64, end: f64) -> &[TemporalEdge]
pub fn edges_in_window(&mut self, start: f64, end: f64) -> &[TemporalEdge]
Return edges in the half-open window [start, end).
Sourcepub fn snapshot(&mut self, start: f64, end: f64) -> Graph<usize, f64>
pub fn snapshot(&mut self, start: f64, end: f64) -> Graph<usize, f64>
Build a static undirected snapshot for the window [start, end).
Repeated contacts between the same pair of nodes accumulate weights.
The returned Graph<usize, f64> contains only nodes that appear in
at least one edge within the window.
Sourcepub fn aggregate_graph(&mut self) -> Graph<usize, f64>
pub fn aggregate_graph(&mut self) -> Graph<usize, f64>
Collapse all temporal contacts into a static undirected weighted graph by summing contact weights over all time.
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 neighbors of node contacted in [t_start, t_end).
Returns (neighbor_id, earliest_contact_time) pairs (undirected semantics).
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