Algorithmic Solutions > LEDA > LEDA Guide > GraphWin > Programming Interface > Layout Operations

GraphWin Layout Operations

The Layout Operations of GraphWin manipulate the positions and sizes of nodes and the sequences of bends of the edges. Such operations are, for example, used to realize the functions in the layout menu of the interactive interface. See also Graph Drawing Algorithms for an application of layout operations.

On the right you see a screenshot of a GraphWin with an orthogonal drawing of a planar graph. The screenshot is taken from the Example ORTHO_DRAW() from Section Graph Drawing Algorithms. Clicking on the picture shows the Graphwin in original size.

Example GraphWin Layout Operations

Some Operations

In most layout operations the new node positions can be specified as points or as pairs of doubles. The operations

    void gw.set_positions(const node_array<double>& xpos,
                          const node_array<double>& ypos);
    void gw.set_positions(const node_array<point>& pos);
move every node v of gw from its old position to (xpos[v],ypos[v]) or pos[v], respectively. The bends of all edges are left unchanged. The operation
    void gw.set_layout(const node_array<point>& pos, 
                       const edge_array<list<point> > bends);
moves every node v to position pos[v] and sets the bend sequence of every edge e to bends[e]. The operation
    void gw.set_layout(const node_array<point>& pos);
moves every node v to position pos[v] and removes all edge bends from the layout. The operation
    void gw.remove_bends();
removes all edge bends from the layout and leaves the node positions unchanged. The operation
    void gw.place_into_box(double x0, double y0, 
                           double x1, double y1);
moves the graph into the rectangular box (x0,y0,x1,y1) by scaling and translating the layout, and
    void gw.place_into_win();
moves the graph into the drawing window by scaling and translating.

There are many more layout operations available. For a complete list have a look at the Manual Page GraphWin

Animation of Layout Changes

GraphWin animates changes in the layout by linear interpolation. The parameter animation_steps controls this animation. If animation_steps is zero, the layout change is performed instantaneously. The operation
    int gw.set_animation_steps(int s);
allows to change the parameter.

Layout Coordinate Computation

Consider the following situation. Given a GraphWin gw and the associated graph G. We have computed a new layout for G, but the new layout does not conform the coordinate space of gw (see also pixel and user coordinates). We want to adjust the layout data before applying it. The following operations are a combination of a stretch or shrink transformation with a translation of the window, that is, they do not actually change the layout of the current graph.

GraphWin provides operations for this situation. They apply the transformations place_into_box() and place_into_win() to layout data supplied separately in node arrays and edge arrays.

    void gw.adjust_coords_to_box(node_array<double>& xpos, 
                node_array<double>& ypos,
                edge_array<list<double> >& xbends,
                edge_array<list<double> >& ybends,
                double x0, double y0, double x1, double y1);
moves and stretches the graph to fill the given rectangular box (x0, y0, x1, y1) by appropriate scaling and translating operations.
    void gw.adjust_coords_to_win(node_array<double>& xpos,
                node_array<double>& ypos,
                edge_array<list<double> >& xbends,
                edge_array<list<double> >& ybends);
moves and stretches the graph to fill the entire window by appropriate scaling and translating operations. For examples of how to use the layout coordinate computation see Edit and Run: A Simple Recipe for Interactive Demos or A Recipe for Online Demos of Network Algorithms.

See also:

GraphWin

Programming Interface

Interactive Interface

Attributes and Parameters

Edit and Run: A Simple Recipe for Interactive Demos

A Recipe for Online Demos of Network Algorithms

Zoom Operations


Graph Data Types

Graph Drawing Algorithms

Node Arrays

Edge Arrays


Windows and Panels

Pixel and User Coordinates


Geometry

Basic Data Types for 2D Geometry


Linear Lists


Manual Pages:

Manual Page GraphWin




Please send any suggestions, comments or questions to leda@algorithmic-solutions.com
© Copyright 2001-2003, Algorithmic Solutions Software GmbH