pub struct Graph {
pub graph_id: GraphId,
pub graph_version: u32,
pub imports: BTreeMap<GraphId, GraphImport>,
pub symbols: BTreeMap<SymbolId, Symbol>,
pub nodes: BTreeMap<NodeId, Node>,
pub ports: BTreeMap<PortId, Port>,
pub edges: BTreeMap<EdgeId, Edge>,
pub groups: BTreeMap<GroupId, Group>,
pub sticky_notes: BTreeMap<StickyNoteId, StickyNote>,
pub bindings: BTreeMap<BindingId, Binding>,
}Expand description
Node graph document.
Fields§
§graph_id: GraphIdStable identity for editor-state lookup and cross-graph references.
graph_version: u32Schema version for migrations.
imports: BTreeMap<GraphId, GraphImport>Transitive graph dependencies (semantic subgraphs / libraries).
symbols: BTreeMap<SymbolId, Symbol>Graph-scoped symbols (blackboard/variables).
nodes: BTreeMap<NodeId, Node>Node instances.
ports: BTreeMap<PortId, Port>Port instances (owned by nodes, but stored in a flat map for stable lookup).
edges: BTreeMap<EdgeId, Edge>Edges between ports.
groups: BTreeMap<GroupId, Group>Optional groups.
sticky_notes: BTreeMap<StickyNoteId, StickyNote>Optional sticky notes.
bindings: BTreeMap<BindingId, Binding>Optional knowledge-canvas bindings.
Implementations§
Source§impl Graph
impl Graph
Sourcepub fn new(graph_id: GraphId) -> Self
pub fn new(graph_id: GraphId) -> Self
Creates a new, empty graph with the given id.
Examples found in repository?
examples/build_graph.rs (line 34)
32fn main() {
33 let node_id = NodeId::from_u128(2);
34 let mut graph = Graph::new(GraphId::from_u128(1));
35
36 let mut tx = GraphTransaction::new().with_label("add source node");
37 tx.push(GraphOp::AddNode {
38 id: node_id,
39 node: make_node("demo.source", 10.0, 20.0),
40 });
41 tx.apply_to(&mut graph).expect("transaction applies");
42
43 assert_eq!(graph.nodes.len(), 1);
44 assert_eq!(graph.nodes[&node_id].kind, NodeKindKey::new("demo.source"));
45}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
Source§impl GraphOpBuilderExt for Graph
impl GraphOpBuilderExt for Graph
Source§fn build_remove_edge_op(&self, id: EdgeId) -> Option<GraphOp>
fn build_remove_edge_op(&self, id: EdgeId) -> Option<GraphOp>
Builds a
RemoveEdge op for an existing edge.Source§fn build_remove_port_op(&self, id: PortId) -> Option<GraphOp>
fn build_remove_port_op(&self, id: PortId) -> Option<GraphOp>
Builds a
RemovePort op for an existing port, including incident edges.Source§fn build_disconnect_port_ops(&self, id: PortId) -> Option<Vec<GraphOp>>
fn build_disconnect_port_ops(&self, id: PortId) -> Option<Vec<GraphOp>>
Builds ops that disconnect all edges incident to the port. Read more
Source§fn build_remove_port_tx(
&self,
id: PortId,
label: impl Into<String>,
) -> Option<GraphTransaction>
fn build_remove_port_tx( &self, id: PortId, label: impl Into<String>, ) -> Option<GraphTransaction>
Builds a transaction that removes a port (and its incident edges).
Source§fn build_remove_node_op(&self, id: NodeId) -> Option<GraphOp>
fn build_remove_node_op(&self, id: NodeId) -> Option<GraphOp>
Builds a
RemoveNode op for an existing node, including owned ports and incident edges.Source§fn build_remove_node_tx(
&self,
id: NodeId,
label: impl Into<String>,
) -> Option<GraphTransaction>
fn build_remove_node_tx( &self, id: NodeId, label: impl Into<String>, ) -> Option<GraphTransaction>
Builds a transaction that removes a node (and its ports/edges).
Source§fn build_remove_group_op(&self, id: GroupId) -> Option<GraphOp>
fn build_remove_group_op(&self, id: GroupId) -> Option<GraphOp>
Builds a
RemoveGroup op for an existing group, including nodes detached from it.Source§fn build_remove_group_tx(
&self,
id: GroupId,
label: impl Into<String>,
) -> Option<GraphTransaction>
fn build_remove_group_tx( &self, id: GroupId, label: impl Into<String>, ) -> Option<GraphTransaction>
Builds a transaction that removes a group (and detaches any child nodes).
Source§fn build_remove_sticky_note_op(&self, id: StickyNoteId) -> Option<GraphOp>
fn build_remove_sticky_note_op(&self, id: StickyNoteId) -> Option<GraphOp>
Builds a
RemoveStickyNote op for an existing sticky note, including attached bindings.Source§fn build_remove_sticky_note_tx(
&self,
id: StickyNoteId,
label: impl Into<String>,
) -> Option<GraphTransaction>
fn build_remove_sticky_note_tx( &self, id: StickyNoteId, label: impl Into<String>, ) -> Option<GraphTransaction>
Builds a transaction that removes a sticky note and attached bindings.
Source§fn build_remove_binding_op(&self, id: BindingId) -> Option<GraphOp>
fn build_remove_binding_op(&self, id: BindingId) -> Option<GraphOp>
Builds a
RemoveBinding op for an existing binding.Source§fn build_remove_binding_tx(
&self,
id: BindingId,
label: impl Into<String>,
) -> Option<GraphTransaction>
fn build_remove_binding_tx( &self, id: BindingId, label: impl Into<String>, ) -> Option<GraphTransaction>
Builds a transaction that removes a binding.
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