Skip to main content

layout_lgl

Function layout_lgl 

Source
pub fn layout_lgl(
    graph: &Graph,
    params: &LglParams,
) -> IgraphResult<Vec<[f64; 2]>>
Expand description

Compute the Large Graph Layout (LGL).

Places vertices using BFS layering from a root vertex followed by Fruchterman-Reingold style force-directed refinement with grid-based repulsion acceleration.

§Arguments

  • graph — input graph (treated as undirected).
  • params — algorithm parameters (all have sensible defaults).

Returns [x, y] positions for each vertex.

§Errors

Returns InvalidArgument if root is out of range or if the graph is empty.

§Examples

use rust_igraph::{Graph, layout_lgl, LglParams};

let mut g = Graph::with_vertices(6);
g.add_edge(0, 1).unwrap();
g.add_edge(1, 2).unwrap();
g.add_edge(2, 3).unwrap();
g.add_edge(3, 4).unwrap();
g.add_edge(4, 5).unwrap();

let params = LglParams::default();
let pos = layout_lgl(&g, &params).unwrap();
assert_eq!(pos.len(), 6);
assert!(pos.iter().all(|p| p[0].is_finite() && p[1].is_finite()));