00001
00002
00003
00004
00005
00006
00007
00008
00009
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 }