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

Graph Operations

Update Operations of GraphWin

GraphWin provides the following update operations of its associated graph
    node gw.new_node(const point& p);
    void gw.del_node(node v);
    edge gw.new_edge(node v, node w);
    void gw.del_edge(edge e);
    void gw.clear_graph();

Using the Update Operations for Graphs

The update operations for graphs can be used for the graph associated with a GraphWin as follows
    graph& G=gw.get_graph();
    //some update operations on G, e.g., G.new_node();
    gw.update_graph();
Important Notice: gw.update_graph() informs gw about the fact that its graph G was modified and allows it to update its internal data structures. Without the statement G and the internal data structures of gw will go out of sync and serious errors may occur.

Example

The following example declares GraphWin gw, defines two nodes u and v and an edge between them. Then it displays gw. It defines a reference G for the graph of gw and creates a new node of G. Only after a call of gw.update_graph() this node appears in gw.
#include <LEDA/graphics/graphwin.h>
#include <LEDA/graph/graph_alg.h>

using namespace leda;

int main()
{  
  GraphWin gw("LEDA Graph Editor");
  node u=gw.new_node(point(100,100));
  node v=gw.new_node(point(100,200));
  gw.new_edge(u,v);

  gw.display();
  gw.get_window().read_mouse();

  graph& G=gw.get_graph();
  G.new_node();
  gw.get_window().read_mouse();

  gw.update_graph();
  gw.get_window().read_mouse();
		
  return 0;
}

See also:

GraphWin

Programming Interface


Graph Data Types

Graphs


Geometry

Basic Data Types for 2D Geometry


Manual Pages:

Manual Page GraphWin




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