Algorithmic Solutions > LEDA > LEDA Guide > GraphWin > Programming Interface > Attribute and Parameter Operations

GraphWin Attribute and Parameter Operations

Attributes of nodes and edges, and global parameters are manipulated by get()- and set()-operations (see also Window Parameters). Details about available attributes and parameters can be found on Attributes and Parameters or the Manual Page GraphWin.

On the right there is a screenshot of a simple example program that shows how to use GraphWin attribute and parameter operations. For more elaborate examples see Edit and Run, Online Demos of Graph Algorithms, and Online Demos of Network Algorithms.

Example GraphWin Attribute and Parameter Operations

Individual Attributes of Nodes and Edges

Attributes of existing nodes and edges can be retrieved and changed by the following operations. We use object for either node or edge, and attrib (of type attrib_type) for an arbitrary attribute.
    attrib_type gw.get_attrib(object x);
returns the value of attribute attrib for object x.
    attrib_type gw.set_attrib(object x, attrib_type a);
sets the value of attribute attrib to a for object x, and returns the old value of attrib.
    void gw.set_attrib(list<object> L, attrib_type a);
sets attribute attrib to value a for all objects in list L, and
    void gw.reset_attributes();
resets all attributes of all objects to their default values.

The current attributes of all nodes and edges may be saved and restored later to the saved values by the following functions. These functions are very useful if the appearance of the graph has to be changed temporarily, e.g., to highlight a substructure of the graph. For an example of how to use these operations have a look at Edit and Run: A Simple Recipe for Interactive Demos with GraphWin.

    void gw.save_node_attributes();
    void gw.save_edge_attributes();
    void gw.restore_node_attributes();
    void gw_restore_edge_attributes();
	

Default Attributes

Every attribute has a default value which is used to initialize the attributes of new objects. The default values can be changed by the following operations.
    attrib_type get_object_attrib();
    attrib_type set_object_attrib(attrib_type a, bool apply=true);

Remark: Changing the default value of an attribute also affects all existing objects unless the optional boolean flag apply in the corresponding set_object_attrib()-operation is set to false.

The current default values of all attributes can be saved to a file and later reloaded by the following operations

    void gw.save_defaults(string fname);
    void gw.read_defaults(string fname);
	

Global Parameters

Global parameters can be retrieved and changed by a collection of get()- and set()-operations. We use param_type for the type of a parameter param.

There is a get()- and set()-operation for each global parameter.

    param_type gw.get_param();
    param_type gw.set_param(param_type p);
The latter operation returns the previous value of param.

See also:

GraphWin

Programming Interface

Attributes and Parameters

Edit and Run: A Simple Recipe for Interactive Demos with GraphWin

A Recipe for Online Demos of Graph Algorithms

A Recipe for Online Demos of Network Algorithms


Windows and Panels

Window Parameters


Linear Lists

Strings


Graph Data Types

Graphs


Manual Pages:

Manual Page GraphWin




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