pub struct Graph {
pub nodes: HashMap<String, GraphNode>,
pub edges: HashSet<GraphEdge>,
}Expand description
Experience/thought graph G — 𝔸3
Nodes carry embeddings in Z (latent space). Edges are typed morphisms. Only Match mutates G.
Fields§
§nodes: HashMap<String, GraphNode>§edges: HashSet<GraphEdge>Implementations§
Source§impl Graph
impl Graph
Sourcepub fn node_count(&self) -> usize
pub fn node_count(&self) -> usize
Number of nodes.
Sourcepub fn edge_count(&self) -> usize
pub fn edge_count(&self) -> usize
Number of edges.
Sourcepub fn ok(&self, latent_dim: usize) -> bool
pub fn ok(&self, latent_dim: usize) -> bool
GraphOK — Inv3: typed nodes/edges, embeddings in Z.
Checks:
- Every edge endpoint is an existing node
- All embeddings have matching dimension
- All embeddings are finite (in Z)
Sourcepub fn add_node(
&mut self,
id: String,
embedding: Vec<f64>,
node_type: Option<String>,
)
pub fn add_node( &mut self, id: String, embedding: Vec<f64>, node_type: Option<String>, )
Add a node with a latent embedding.
Sourcepub fn delete_node(&mut self, id: &str)
pub fn delete_node(&mut self, id: &str)
Delete a node and all incident edges.
Sourcepub fn add_edge(&mut self, from: String, to: String, edge_type: String) -> bool
pub fn add_edge(&mut self, from: String, to: String, edge_type: String) -> bool
Add a typed edge.
Sourcepub fn relabel_node(&mut self, id: &str, new_embedding: Vec<f64>) -> bool
pub fn relabel_node(&mut self, id: &str, new_embedding: Vec<f64>) -> bool
Relabel a node’s embedding.
Sourcepub fn rebuild(&mut self, target: &Graph)
pub fn rebuild(&mut self, target: &Graph)
Replace the entire graph with a target (rebuild to G*).
Sourcepub fn is_acyclic(&self) -> bool
pub fn is_acyclic(&self) -> bool
Whether the directed dependency spine is acyclic (Inv7 candidate gate).
Kahn’s algorithm: a DAG has a topological order covering every node.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Graph
impl<'de> Deserialize<'de> for Graph
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>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for Graph
impl RefUnwindSafe for Graph
impl Send for Graph
impl Sync for Graph
impl Unpin for Graph
impl UnsafeUnpin for Graph
impl UnwindSafe for Graph
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