LayoutRequest
A layered-layout request: the graph, the preset its options start from, and the fields of
that preset to change.
Every part defaults, so
``
that preset to change.
Every part defaults, so
{} is a valid request (an empty graph, the layered preset).``
use graphlay::json::LayoutRequest;
use graphlay::{Direction, RoutingStyle};
let request: LayoutRequest = serde_json::from_str(r#"{
"graph": {"nodes": [{"size": {"width": 80, "height": 40}},
{"size": {"width": 80, "height": 40}}],
"edges": [{"source": 0, "target": 1}]},
"preset": "process_map",
"options": {"routing": {"style": "diagonal"}}
}"#)?;
let (graph, options) = request.split()?;
assert_eq!(options.routing.style, RoutingStyle::Diagonal); // from the patch
assert_eq!(options.direction, Direction::TopBottom); // from the preset
let l = graphlay::layout(&graph, &options)?;
assert!(l.nodes[0].center.y < l.nodes[1].center.y);
// A bad patch is an error that names the field.
let bad: LayoutRequest =
serde_json::from_str(r#"{"options": {"routing": {"style": "curvy"}}}"#)?;
assert!(bad.split().unwrap_err().starts_with("options.routing.style:"));
# Ok::<(), Box<dyn std::error::Error>>(())
``Used as Input
2
functions accept this type
Used as Output
0
functions return this type(+7 nested)
Type Definition
262 nested items
struct— A layered-layout request: the graph, the preset its options start from, and the fields of
nodes:Vec<Node>— Nodes, in
NodeId order.compaction:CompactionOptions— Cross-axis compaction. Its iteration counts are in
CompactionTuning.coords:CoordOptions— Cross-axis placement options.
cycles:CycleOptions— Cycle-breaking options. See
CycleStrategy.effort:Effort— How hard the engine works, as one dial over the iteration counts. Default
labels:LabelOptions— How edge labels are given room, and where in the drawing they end up.
limits:Limits— Input size limits.
order:OrderOptions— Crossing-minimisation heuristic and group lane budgets.
routing:Routing— How edges are routed: the style, bundling, and which borders and lanes the ends use.
seed:u32— Seed for the crossing minimisation's restarts and kicks. The same seed gives the same
seed_mode:SeedMode— How node positions given by the caller (
crate::Node::position) steer a layout. Defaultself_loops:SelfLoopOptions— How self-loops (
source == target edges) are drawn.spacing:Spacing— Gaps and clearances, all in px.
tuning:Tuning— Iteration counts, budgets and thresholds, tuned on the fixture corpus.
wrap:WrapOptions— Wrapping a long drawing into rows to fit a viewport shape. When a wrap pays is in
variant 1:"layered"—
LayoutOptions::layered_default, for Petri nets.variant 2:"process_map"—
LayoutOptions::process_map, for directly-follows graphs.variant 3:"hub_and_spoke"—
LayoutOptions::hub_and_spoke, for dense relationship graphs.variant 4:"hub_and_spoke_flow"—
LayoutOptions::hub_and_spoke_flow, for dense graphs with a direction of flow.Example JSON Value
{}