pub struct Node {
pub id: String,
pub title: String,
pub category: Option<String>,
pub source_id: Option<String>,
pub is_canonical: bool,
pub canonical_id: Option<String>,
pub node_type: NodeType,
pub metadata: HashMap<String, Value>,
}Expand description
A node in the knowledge graph.
Nodes represent content items (concepts, theorems, chapters, etc.).
The metadata field stores domain-specific attributes as key-value pairs.
Fields§
§id: StringUnique identifier (e.g., “picardy-third”, “group-theory”).
title: StringHuman-readable title.
category: Option<String>Optional category for grouping (e.g., “harmony”, “algebra”).
source_id: Option<String>Optional source identifier (e.g., “tymoczko”, “dummit-foote”).
is_canonical: boolWhether this is a canonical node (vs. source-specific variant).
canonical_id: Option<String>If not canonical, the ID of the canonical node this relates to.
node_type: NodeTypeType of this node (Domain, UserQuery, Custom).
metadata: HashMap<String, Value>Domain-specific metadata as key-value pairs.
Implementations§
Source§impl Node
impl Node
Sourcepub fn new(id: impl Into<String>, title: impl Into<String>) -> Self
pub fn new(id: impl Into<String>, title: impl Into<String>) -> Self
Creates a new canonical domain node with the given ID and title.
Sourcepub fn with_category(self, category: impl Into<String>) -> Self
pub fn with_category(self, category: impl Into<String>) -> Self
Sets the category.
Sourcepub fn with_source(self, source_id: impl Into<String>) -> Self
pub fn with_source(self, source_id: impl Into<String>) -> Self
Sets the source ID.
Sourcepub fn as_variant_of(self, canonical_id: impl Into<String>) -> Self
pub fn as_variant_of(self, canonical_id: impl Into<String>) -> Self
Marks this as a variant of a canonical node.
Sourcepub fn with_node_type(self, node_type: NodeType) -> Self
pub fn with_node_type(self, node_type: NodeType) -> Self
Sets the node type.