Skip to content

Possible to use this crate w/o IO? #52

@peekxc

Description

@peekxc

Hey thanks for this crate, it looks like it contains a variety of decently faithful implementations of many of the sub-algorithms necessary for a sugiyama / layered-graph layout.

Is it possible to use the underlying algorithms in this crate directly without inputting dot files and outputting SVG's? I have no need for either; it looks like it's possible to avoid the former by constructs the VisualGraph directly, as in the GraphBuilder examples:

    // Create a new graph:
    let mut vg = VisualGraph::new(Orientation::LeftToRight);

    // Define the node styles:
    let sp0 = ShapeKind::new_box("one");
    let sp1 = ShapeKind::new_box("two");
    let look0 = StyleAttr::simple();
    let look1 = StyleAttr::simple();
    let sz = Point::new(100., 100.);
    // Create the nodes:
    let node0 = Element::create(sp0, look0, Orientation::LeftToRight, sz);
    let node1 = Element::create(sp1, look1, Orientation::LeftToRight, sz);

But is it possible to extract various positioning information without using the SVGWriter backend?

    // Render the nodes to some rendering backend.
    let mut svg = SVGWriter::new();
    vg.do_it(false, false, false, &mut svg);

    // Save the output.
    let _ = save_to_file("/tmp/graph.svg", &svg.finalize());

I suppose I could avoid the save_to_file and inspect svg directly; I was more hoping for something more basic, like:

let mut XY = XYBackend::new();
vg.write_xy(..., &mut XY); 

let xc: Vec<f32> = XY.x; // x-coordinates of the nodes 
let yc: Vec<f32> = XY.y; // y-coordinates of the nodes 
... // other positioning info

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions