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.