DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 
The C++ Graph Classes: A Tutorial - Graph(3C++) and Graph_alg(3C++)

Graph Operators

The following Graph operators are defined for both the generic and user-derived Graph types:

       Graph& operator=(const Graph& g);
       int operator==(const Graph& g) const;
       int operator!=(const Graph& g) const;

The following assignment and equality operations are then legal:

       g2 = g1; // g1 and g2 are previously declared Graphs
       if (g2 == g1) ... ;
       if (g2 != g1) ... ;

When one Graph is assigned to another, the newly-assigned Graph includes the same Vertices and Edges as the original Graph. Two Graphs are equal if and only if they include exactly the same Vertices and Edges.

We'll see, as part of the discussion of Graph Algorithms in the section, ``Traversals'', an example of when the Graph assignment operator is quite useful.


Next topic: Graph Component Insertion and Removal
Previous topic: Graph Constructors and Destructors

© 2004 The SCO Group, Inc. All rights reserved.
UnixWare 7 Release 7.1.4 - 27 April 2004