pub struct Edge {
pub target: ObjectId,
pub kind: EdgeKind,
pub weight: f32,
pub valid_from: u64,
pub valid_to: u64,
pub properties: HashMap<String, SochValue>,
}Expand description
A directed, typed, weighted, temporally-versioned edge between two Knowledge Objects.
Edges are embedded within the source object — when you load an object, you immediately have its outgoing relationships. This eliminates the separate graph lookup required by KV-backed edge stores.
§Memory Layout (32 bytes per edge)
| Field | Size | Purpose |
|---|---|---|
| target | 32B | Target ObjectId (BLAKE3 hash) |
| kind | ~24B | Edge type (enum + string) |
| weight | 4B | Relationship strength [0.0, 1.0] |
| valid_from | 8B | Temporal validity start |
| valid_to | 8B | Temporal validity end |
| properties | var | Optional edge attributes |
For the hot path (CSR-based graph traversal), edges are projected to
(target_internal_id: u32, weight: f32) for cache efficiency.
Fields§
§target: ObjectIdTarget object this edge points to.
kind: EdgeKindThe type/kind of this relationship.
weight: f32Relationship strength/confidence in [0.0, 1.0].
- 1.0 = definitive relationship
- 0.5 = probable relationship
- 0.0 = hypothetical/weak relationship
valid_from: u64Temporal validity interval for this edge.
Uses the same HLC-encoded microsecond format as BitemporalCoord.
valid_to: u64End of temporal validity (exclusive). u64::MAX = still valid.
properties: HashMap<String, SochValue>Optional edge properties (e.g., “role”: “lead”, “confidence”: 0.95).
Implementations§
Source§impl Edge
impl Edge
Sourcepub fn new(target: ObjectId, kind: EdgeKind, weight: f32) -> Self
pub fn new(target: ObjectId, kind: EdgeKind, weight: f32) -> Self
Create a new edge with default weight 1.0 and open-ended validity.
Sourcepub fn with_validity(
target: ObjectId,
kind: EdgeKind,
weight: f32,
valid_from: u64,
valid_to: u64,
) -> Self
pub fn with_validity( target: ObjectId, kind: EdgeKind, weight: f32, valid_from: u64, valid_to: u64, ) -> Self
Create an edge with temporal validity.
Sourcepub fn with_property(self, key: impl Into<String>, value: SochValue) -> Self
pub fn with_property(self, key: impl Into<String>, value: SochValue) -> Self
Add a property to this edge.
Sourcepub fn is_current(&self) -> bool
pub fn is_current(&self) -> bool
Check if this edge is currently valid (valid_to == MAX).
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Edge
impl<'de> Deserialize<'de> for Edge
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl Eq for Edge
Auto Trait Implementations§
impl Freeze for Edge
impl RefUnwindSafe for Edge
impl Send for Edge
impl Sync for Edge
impl Unpin for Edge
impl UnsafeUnpin for Edge
impl UnwindSafe for Edge
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,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.