00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053 #include "config.h"
00054 #ifdef HAVE_STL
00055
00056 #include <stdio.h>
00057
00058 #include "routealgo/rnode.h"
00059
00060
00061
00062 static void PrintPred(nodeid_t, nodeid_t, RoutingVec_t&);
00063 static void NixPred(nodeid_t, nodeid_t, RoutingVec_t&, RNodeVec_t&, NixVec&);
00064
00065
00066
00067 void PrintRoute( nodeid_t s, nodeid_t d, RoutingVec_t& pred)
00068 {
00069 printf("Route to node %ld is : ", d);
00070 PrintPred(s, d, pred);
00071 printf("\n");
00072 }
00073
00074
00075 void NixRoute( nodeid_t s, nodeid_t d, RoutingVec_t& pred,
00076 RNodeVec_t& nodes, NixVec& nv)
00077 {
00078 NixPred(s, d, pred, nodes, nv);
00079 }
00080
00081
00082
00083 void PrintParents(RoutingVec_t& pred)
00084 {
00085 printf("Parent vector is");
00086 for (RoutingVec_it i = pred.begin(); i != pred.end(); i++)
00087 {
00088 printf(" %ld", *i);
00089 }
00090 printf("\n");
00091 }
00092
00093
00094 void PrintNix(nodeid_t s, RNodeVec_t nodes, NixVec& nv)
00095 {
00096 printf("Printing Nv from %ld\n", s);
00097 while(1)
00098 {
00099 printf("%ld\n", s);
00100 fflush(stdout);
00101 if (!nodes[s])
00102 {
00103 printf("PrintNix Error, no node for %ld\n", s);
00104 break;
00105 }
00106 printf("Node %ld nixl %ld\n", s, nodes[s]->GetNixl());
00107 Nix_t n = nv.Extract(nodes[s]->GetNixl());
00108 if (n == NIX_NONE) break;
00109 nodeid_t s1 = nodes[s]->GetNeighbor(n);
00110 if (s1 == NODE_NONE)
00111 {
00112 printf("Huh? Node %ld can't get neighbor %ld\n", s, n);
00113 break;
00114 }
00115 s = s1;
00116 }
00117 printf("\n");
00118 nv.Reset();
00119 }
00120
00121
00122
00123
00124 static void PrintPred(nodeid_t s, nodeid_t p, RoutingVec_t& pred)
00125 {
00126 if (s == p)
00127 {
00128 printf(" %ld", s);
00129 }
00130 else
00131 {
00132 if (pred[p] == NODE_NONE)
00133 {
00134 printf(" No path..");
00135 }
00136 else
00137 {
00138 PrintPred(s, pred[p], pred);
00139 printf(" %ld", p);
00140 }
00141 }
00142 }
00143
00144 static void NixPred(nodeid_t s, nodeid_t p, RoutingVec_t& pred,
00145 RNodeVec_t& nodes, NixVec& nv)
00146 {
00147 if (s == p)
00148 {
00149 return;
00150 }
00151 else
00152 {
00153 if (pred[p] == NODE_NONE)
00154 {
00155 if(0)printf(" No path..");
00156 return;
00157 }
00158 else
00159 {
00160 NixPred(s, pred[p], pred, nodes, nv);
00161 NixPair_t n = nodes[pred[p]]->GetNix(p);
00162 if (n.first == NIX_NONE)
00163 {
00164 printf("RouteAlgo::GetNix returned NIX_NONE!\n");
00165 exit(1);
00166 }
00167 if(0)printf("NVAdding ind %ld lth %ld\n", n.first, n.second);
00168 nv.Add(n);
00169 }
00170 }
00171 }
00172
00173 #endif