///////////////////////////////////////////////////////////////////////////// // graph.cpp - demonstrate Memento pattern with depth first search // // Jim Fawcett, CSE776 - Design Patterns, Summer 2003 // #include #include "graph.h" using namespace std; ///////////////////////////////////////////////////////////////////////////// // test stub void main() { cout << "\n Demonstrating Depth First Search using Memento Pattern " << "\n ========================================================\n"; Node n1(1), n2(2), n3(3), n4(4), n5(5); n1.attachChild(&n2); n2.attachChild(&n3); n2.attachChild(&n5); n3.attachChild(&n4); n4.attachChild(&n1); n5.attachChild(&n4); cout << "\n starting at node 1: " << "\n ---------------------"; Walker walker(&n1); walker.walk(); cout << "\n\n"; cout << "\n restarting at node 3: " << "\n -----------------------"; n1.marked() = false; n2.marked() = false; n3.marked() = false; n4.marked() = false; n5.marked() = false; Walker walker2(&n3); walker2.walk(); cout << "\n\n"; }