Skip to main content

render_svg

Function render_svg 

Source
pub fn render_svg<N, E, Ix>(
    graph: &Graph<N, E, Ix>,
    layout: &GraphLayout<N>,
    config: &SvgConfig,
) -> String
where N: Node + Clone + Debug + Display, E: EdgeWeight + Clone + Into<f64>, Ix: IndexType,
Expand description

Render a graph to SVG using the provided layout and configuration

§Arguments

  • graph - The graph to render
  • layout - Pre-computed node positions
  • config - Visual styling configuration

§Returns

A String containing valid SVG markup

§Example

use scirs2_graph::visualization::{compute_layout, LayoutAlgorithm, SvgConfig, render_svg};
use scirs2_graph::Graph;

let mut g: Graph<&str, f64> = Graph::new();
g.add_node("A");
g.add_node("B");
let _ = g.add_edge("A", "B", 1.0);

let layout = compute_layout(&g, &LayoutAlgorithm::Circular { radius: 100.0 }, 400.0, 300.0).unwrap();
let svg = render_svg(&g, &layout, &SvgConfig::default());
assert!(svg.contains("<svg"));