pub struct EvolvingGraph {
pub history: Vec<(f64, GraphChange)>,
pub current_time: f64,
/* private fields */
}Expand description
A graph that evolves over time through a sequence of explicit changes.
Internally the current state is maintained for O(1) queries; the full history
is kept so that state_at can reconstruct any past configuration.
Fields§
§history: Vec<(f64, GraphChange)>Chronological log of (timestamp, change) pairs.
current_time: f64Timestamp of the most recent change applied.
Implementations§
Source§impl EvolvingGraph
impl EvolvingGraph
Sourcepub fn apply_change(&mut self, time: f64, change: GraphChange)
pub fn apply_change(&mut self, time: f64, change: GraphChange)
Apply a change at the given timestamp, updating internal state and history.
Sourcepub fn has_edge(&self, u: usize, v: usize) -> bool
pub fn has_edge(&self, u: usize, v: usize) -> bool
Whether an edge between u and v exists in the current state.
Sourcepub fn edge_weight(&self, u: usize, v: usize) -> Option<f64>
pub fn edge_weight(&self, u: usize, v: usize) -> Option<f64>
Weight of the edge between u and v, if it exists.
Sourcepub fn node_attribute(&self, n: usize, attr: &str) -> Option<f64>
pub fn node_attribute(&self, n: usize, attr: &str) -> Option<f64>
Get the value of attribute attr on node n, if set.
Sourcepub fn state_at(&self, target_time: f64) -> Self
pub fn state_at(&self, target_time: f64) -> Self
Reconstruct the graph state at target_time by replaying history.
Only changes with timestamp <= target_time are applied.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for EvolvingGraph
impl RefUnwindSafe for EvolvingGraph
impl Send for EvolvingGraph
impl Sync for EvolvingGraph
impl Unpin for EvolvingGraph
impl UnsafeUnpin for EvolvingGraph
impl UnwindSafe for EvolvingGraph
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
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>
Converts
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>
Converts
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