graph_test.cc

Go to the documentation of this file.
00001 //
00002 // Copyright 2002 Sony Corporation 
00003 //
00004 // Permission to use, copy, modify, and redistribute this software for
00005 // non-commercial use is hereby granted.
00006 //
00007 // This software is provided "as is" without warranty of any kind,
00008 // either expressed or implied, including but not limited to the
00009 // implied warranties of fitness for a particular purpose.
00010 //
00011 
00012 #include <DirectedGraph.h>
00013 #include "TestNode.h"
00014 #include "TestArc.h"
00015 
00016 const int NT    = 0;
00017 const int STAND = 1;
00018 const int SIT   = 2;
00019 const int SLEEP = 3;
00020 const int WALK  = 4;
00021 
00022 main()
00023 {
00024     DirectedGraph<TestNode, TestArc> graph;
00025     list<TestArc> path;
00026 
00027     graph.Add(TestArc(NT,    SLEEP));
00028     graph.Add(TestArc(SLEEP, STAND));
00029     graph.Add(TestArc(STAND, SLEEP));
00030     graph.Add(TestArc(SLEEP, SIT));
00031     graph.Add(TestArc(SIT  , SLEEP));
00032     graph.Add(TestArc(SIT  , STAND));
00033     graph.Add(TestArc(STAND, SIT));
00034     graph.Add(TestArc(STAND, WALK));
00035     graph.Add(TestArc(WALK , STAND));
00036 
00037     graph.Print();
00038 
00039     int n = graph.Search(TestNode(NT), TestNode(WALK), path);
00040     printf("n = %d\n", n);
00041 
00042     list<TestArc>::iterator iter = path.begin();
00043     list<TestArc>::iterator last = path.end();
00044     while (iter != last) {
00045         (*iter).Print();
00046         ++iter;
00047     }
00048 
00049     printf("\n");
00050 }

Generated on Sun Dec 2 23:04:28 2007 for openSDK by  doxygen 1.3.9.1