dagre_dgl_rs/lib.rs
1#![deny(missing_docs)]
2//! # dagre-rs
3//!
4//! A faithful Rust port of [dagre-js](https://github.com/dagrejs/dagre) — a directed-graph
5//! layout engine that assigns **x/y coordinates** to nodes and **bend-point sequences** to
6//! edges, while keeping edge crossings to a minimum.
7//!
8//! ## Quick start
9//!
10//! ```rust
11//! use dagre_dgl_rs::{Graph, GraphLabel, NodeLabel, EdgeLabel, layout};
12//!
13//! let mut g = Graph::default();
14//! g.set_graph(GraphLabel {
15//! rankdir: Some("LR".to_string()),
16//! nodesep: Some(50.0),
17//! ranksep: Some(50.0),
18//! ..Default::default()
19//! });
20//!
21//! g.set_node("a", NodeLabel { width: 100.0, height: 40.0, ..Default::default() });
22//! g.set_node("b", NodeLabel { width: 100.0, height: 40.0, ..Default::default() });
23//! g.set_edge("a", "b", EdgeLabel::default(), None);
24//!
25//! layout(&mut g);
26//!
27//! let a = g.node("a");
28//! println!("node a: ({:?}, {:?})", a.x, a.y);
29//! ```
30//!
31//! ## Modules
32//!
33//! Most users only need the items re-exported at the crate root. The sub-modules
34//! (`acyclic`, `rank`, `order`, `position`, …) contain the individual pipeline stages
35//! and are public for advanced use or testing.
36
37pub mod acyclic;
38pub mod add_border_segments;
39pub mod coordinate_system;
40/// Graph data structures used internally by the layout pipeline (e.g. doubly-linked list).
41pub mod data;
42pub mod graph;
43/// Entry point for the full dagre layout pipeline ([`layout::layout`]).
44pub mod layout;
45pub mod nesting_graph;
46pub mod normalize;
47pub mod order;
48pub mod parent_dummy_chains;
49pub mod position;
50pub mod rank;
51mod tests;
52/// Shared utility functions used across the layout pipeline.
53pub mod util;
54
55/// Core graph types: [`Graph`], [`NodeLabel`], [`EdgeLabel`], [`GraphLabel`], [`Edge`],
56/// [`Point`], and [`SelfEdge`].
57pub use graph::{Edge, EdgeLabel, Graph, GraphLabel, NodeLabel, Point, SelfEdge};
58
59/// Run the full dagre layout pipeline on a graph. See [`layout::layout`] for details.
60pub use layout::layout;