Creating and Opening a GraphWinCreating a GraphWinA GraphWin has an associated graph and an associated window. Either one of them may or may not be specified in the constructor of the GraphWin.GraphWin gw;constructs a GraphWin gw with a private graph and a private
window. Graph and window of gw can be accessed by the operation
gw.get_graph() , respectively, gw.get_window() .
GraphWin gw(graph& G); associates Remark: GraphWin gw(window & W); GraphWin gw(graph& G, window& W);use window W for displaying
the associated graph of gw .
Opening a GraphWinA GraphWin is opened and displayed by callinggw.display();The interactive interface of GraphWin is started by gw.edit();Remark: In the interactive interface the menus of gw
are enabled and the graph associated with gw may be changed
interactively. Pressing done terminates the session and returns
true , exit in the file menu also terminates the
session, but returns false .
ExampleThe following example declares and displays aGraphWin gw ,
starts an edit loop that lets the user construct or modify the graph
G associated with gw . When done is pressed,
G is tested for planarity, exit terminates the
loop and the program.
#include <LEDA/graphics/graphwin.h> #include <LEDA/graph/graph_alg.h> using namespace leda; int main() { GraphWin gw("LEDA Graph Editor"); graph& G=gw.get_graph(); gw.display(window::center,window::center); while (gw.edit()) { if (PLANAR(G)) std::cout << "This graph is planar." << std::endl; else std::cout << "This graph is non-planar." << std::endl; } return 0; } |
See also:Manual Pages: |