Skip to main content

Graph

Struct Graph 

Source
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: GraphId

Stable identity for editor-state lookup and cross-graph references.

§graph_version: u32

Schema 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

Source

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 Clone for Graph

Source§

fn clone(&self) -> Graph

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Graph

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Graph

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for Graph

Source§

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

Source§

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>

Builds a RemovePort op for an existing port, including incident edges.
Source§

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>

Builds a transaction that removes a port (and its incident edges).
Source§

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>

Builds a transaction that removes a node (and its ports/edges).
Source§

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>

Builds a transaction that removes a group (and detaches any child nodes).
Source§

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>

Builds a transaction that removes a sticky note and attached bindings.
Source§

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>

Builds a transaction that removes a binding.
Source§

impl Serialize for Graph

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. 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> 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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.