Skip to main content

PetTemporalGraph

Struct PetTemporalGraph 

Source
pub struct PetTemporalGraph<N, L, V, T> { /* private fields */ }
Expand description

A temporal graph backed by petgraph::StableGraph.

Nodes are identified by N, edges carry TemporalEdge<L, V, T>. A HashMap<N, NodeIndex> provides reverse lookup from user IDs to petgraph’s internal NodeIndex.

Implementations§

Source§

impl<N, L, V, T> PetTemporalGraph<N, L, V, T>
where N: Eq + Hash + Clone + Debug, T: Clone,

Source

pub fn new(initial_time: T) -> Self

Create a new empty graph with the given initial time.

Source

pub fn set_time(&mut self, t: T)

Set the current time.

Source

pub fn add_node(&mut self, id: N) -> NodeIndex

Add a node (or return existing index if already present).

Source

pub fn add_edge(&mut self, from: N, label: L, value: V, interval: Interval<T>)

Add a temporal edge between two nodes.

Source

pub fn add_edge_to_node( &mut self, from: N, label: L, to: N, interval: Interval<T>, )
where V: From<NodeRef<N>>,

Add a temporal edge with a node-valued target (also ensures target node exists).

Source

pub fn add_edge_bounded( &mut self, from: N, label: L, value: V, start: T, end: T, )
where T: Ord,

Add a temporal edge with a bounded interval [start, end).

Source

pub fn node_count(&self) -> usize

Number of nodes.

Source

pub fn edge_count(&self) -> usize

Number of edges.

Trait Implementations§

Source§

impl<N, L, T> DataSource for PetTemporalGraph<N, L, PetValue<N>, T>
where N: Eq + Hash + Clone + Debug + PartialOrd, L: Eq + Hash + Clone + Debug, T: Ord + Clone + Debug + Hash,

Source§

type N = N

Node identifier type.
Source§

type L = L

Edge label type.
Source§

type V = PetValue<N>

Value type (edge targets — can be nodes, strings, numbers, booleans).
Source§

type T = T

Time type.
Source§

fn edges_from( &self, node: &N, label: &L, at: &T, ) -> Vec<Edge<N, PetValue<N>, T>>

Follow edges from node with label, active at time at. Read more
Source§

fn scan( &self, label: &L, constraint: &ValueConstraint<PetValue<N>>, at: &T, ) -> Vec<Edge<N, PetValue<N>, T>>

Find all source nodes that have an edge with label matching constraint, active at time at. Read more
Source§

fn edges_from_any_time( &self, node: &N, label: &L, ) -> Vec<Edge<N, PetValue<N>, T>>

Find all edges from node with label that were ever valid (regardless of time). Used for temporal constraint checking.
Source§

fn scan_any_time( &self, label: &L, constraint: &ValueConstraint<PetValue<N>>, ) -> Vec<Edge<N, PetValue<N>, T>>

Scan for edges with label matching constraint at any time.
Source§

fn now(&self) -> T

The current time in the graph’s time model.
Source§

fn value_as_node(&self, value: &PetValue<N>) -> Option<N>

Check if a value represents a node reference (for traversal) vs. a literal (for comparison). This lets the pattern matcher know whether to follow a value as a node or compare it as data.

Auto Trait Implementations§

§

impl<N, L, V, T> Freeze for PetTemporalGraph<N, L, V, T>
where T: Freeze,

§

impl<N, L, V, T> RefUnwindSafe for PetTemporalGraph<N, L, V, T>

§

impl<N, L, V, T> Send for PetTemporalGraph<N, L, V, T>
where T: Send, N: Send, L: Send, V: Send,

§

impl<N, L, V, T> Sync for PetTemporalGraph<N, L, V, T>
where T: Sync, N: Sync, L: Sync, V: Sync,

§

impl<N, L, V, T> Unpin for PetTemporalGraph<N, L, V, T>
where T: Unpin, N: Unpin, L: Unpin, V: Unpin,

§

impl<N, L, V, T> UnsafeUnpin for PetTemporalGraph<N, L, V, T>
where T: UnsafeUnpin,

§

impl<N, L, V, T> UnwindSafe for PetTemporalGraph<N, L, V, T>

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.