pub struct Subgraph {
pub id: String,
pub label: String,
pub direction: Option<Direction>,
pub node_ids: Vec<String>,
pub subgraph_ids: Vec<String>,
}Expand description
A named cluster of nodes (and optionally nested subgraphs).
Subgraphs are rendered as a rounded rectangle that encloses all their direct and indirect member nodes. Edges may freely cross subgraph boundaries.
Fields§
§id: StringUnique identifier (the id token after subgraph).
label: StringHuman-readable label displayed at the top of the border. Falls back
to id when not explicitly specified.
direction: Option<Direction>Optional per-subgraph flow direction override.
Currently preserved on the model for future use; the renderer always uses the parent graph direction.
node_ids: Vec<String>IDs of direct child nodes (not recursively nested ones).
subgraph_ids: Vec<String>IDs of direct child subgraphs.
Implementations§
Source§impl Subgraph
impl Subgraph
Sourcepub fn new(id: impl Into<String>, label: impl Into<String>) -> Self
pub fn new(id: impl Into<String>, label: impl Into<String>) -> Self
Construct a new subgraph with the given id and label.
Both node_ids and subgraph_ids start empty; the parser fills them
as it processes the subgraph body. direction defaults to None
(inherits from the parent graph).
§Arguments
id— unique identifier (the token aftersubgraph)label— display label at the top of the border
§Examples
use mermaid_text::types::Subgraph;
let sg = Subgraph::new("S1", "My Cluster");
assert_eq!(sg.id, "S1");
assert_eq!(sg.label, "My Cluster");
assert!(sg.node_ids.is_empty());
assert!(sg.direction.is_none());