pub struct Graph {
pub label: Option<String>,
pub directed: bool,
pub nodes: BTreeMap<String, Node>,
pub edges: Vec<Edge>,
}Expand description
A single JGF graph. Used for both a raw per-graph fragment (with label
set to the graph name) and the composed graph (with label absent).
Nodes are keyed by path in a BTreeMap for deterministic, sorted output.
Fields§
§label: Option<String>The graph name, present in a raw fragment, absent in the composed graph.
directed: bool§nodes: BTreeMap<String, Node>§edges: Vec<Edge>Implementations§
Source§impl Graph
impl Graph
Sourcepub fn labeled(label: impl Into<String>) -> Self
pub fn labeled(label: impl Into<String>) -> Self
An empty labeled directed graph (a raw per-graph fragment).
Sourcepub fn set_node(&mut self, path: impl Into<String>, node: Node)
pub fn set_node(&mut self, path: impl Into<String>, node: Node)
Insert or replace the node at path.
Sourcepub fn sort_edges(&mut self)
pub fn sort_edges(&mut self)
Sort edges by (source, target) for deterministic output.
Sourcepub fn into_document(self) -> GraphDocument
pub fn into_document(self) -> GraphDocument
Wrap this graph as a composed JGF document ({"graph": {...}}).
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
impl StructuralPartialEq for Graph
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