Expand description
§dagre-rs
A faithful Rust port of dagre-js — a directed-graph layout engine that assigns x/y coordinates to nodes and bend-point sequences to edges, while keeping edge crossings to a minimum.
§Quick start
use dagre_dgl_rs::{Graph, GraphLabel, NodeLabel, EdgeLabel, layout};
let mut g = Graph::default();
g.set_graph(GraphLabel {
rankdir: Some("LR".to_string()),
nodesep: Some(50.0),
ranksep: Some(50.0),
..Default::default()
});
g.set_node("a", NodeLabel { width: 100.0, height: 40.0, ..Default::default() });
g.set_node("b", NodeLabel { width: 100.0, height: 40.0, ..Default::default() });
g.set_edge("a", "b", EdgeLabel::default(), None);
layout(&mut g);
let a = g.node("a");
println!("node a: ({:?}, {:?})", a.x, a.y);§Modules
Most users only need the items re-exported at the crate root. The sub-modules
(acyclic, rank, order, position, …) contain the individual pipeline stages
and are public for advanced use or testing.
Re-exports§
pub use graph::Edge;pub use graph::EdgeLabel;pub use graph::Graph;pub use graph::GraphLabel;pub use graph::NodeLabel;pub use graph::Point;pub use graph::SelfEdge;pub use layout::layout;
Modules§
- acyclic
- acyclic.rs — acyclic run/undo + dfsFAS + greedyFAS Faithful port of dagre-js/lib/acyclic.ts and greedy-fas.ts
- add_
border_ segments - add_border_segments.rs — addBorderSegments Faithful port of dagre-js/lib/add-border-segments.ts
- coordinate_
system - coordinate_system.rs — adjust/undo Faithful port of dagre-js/lib/coordinate-system.ts
- data
- Graph data structures used internally by the layout pipeline (e.g. doubly-linked list).
- graph
- graph.rs — A faithful port of @dagrejs/graphlib Graph to Rust.
- layout
- Entry point for the full dagre layout pipeline (
layout::layout). - nesting_
graph - nesting_graph.rs — nestingGraph run/cleanup Faithful port of dagre-js/lib/nesting-graph.ts
- normalize
- normalize.rs — normalize run/undo Faithful port of dagre-js/lib/normalize.ts
- order
- order/mod.rs — order() Faithful port of dagre-js/lib/order/index.ts
- parent_
dummy_ chains - parent_dummy_chains.rs — parentDummyChains Faithful port of dagre-js/lib/parent-dummy-chains.ts
- position
- position/mod.rs — position() Faithful port of dagre-js/lib/position/index.ts
- rank
- rank/mod.rs — rank() dispatcher Faithful port of dagre-js/lib/rank/index.ts
- util
- Shared utility functions used across the layout pipeline.