Advertisement
Guest User

Untitled

a guest
Apr 20th, 2014
45
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.48 KB | None | 0 0
  1. LengthFromSrc = 0;
  2. LengthFromDest = 0;
  3. TotalNumberHops = 0;
  4.  
  5. X = SRC; /*Last Node Visited from Random walk starting at SRC;*/
  6. Y = DEST; /*Last Node Visited from Random walk starting at DEST;*/
  7. /* Randomly select a route length */
  8. do {
  9. Length = rand( ) % Max;
  10. while( Length < Min );
  11.  
  12.  
  13. while( TotalNumberHops < Length ) {
  14.  
  15. Next = Toss Coin to Pick Random Walk from Src or from Dest;
  16.  
  17. if( Next == RandWalkFromSrc ) {
  18. Z = Randomly select an adjacent node to X;
  19. TotalNumberHops = 1 + LengthFromSrc + LengthFromDest
  20. + shortest-path from Z to Y;
  21. if( TotalNumberHops > Length )
  22. break;
  23. X = Z; /*include the node in the route*/
  24. Store X in the route data structure
  25. LengthFromSrc++;
  26. }
  27. else { /* Next = RandWalkFromDest */
  28. Z = Randomly select an adjacent node to Y;
  29. TotalNumberHops = 1 + LengthFromSrc + LengthFromDest
  30. + shortest-path from Z to X;
  31. if( TotalNumberHops > Length )
  32. break;
  33. Y = Z;
  34. Store Y in the route data structure
  35. LengthFromDest++;
  36. }
  37. }
  38.  
  39. do {
  40. Length = rand( ) % Max;
  41. while( Length < Min );
  42.  
  43.  
  44. while( TotalNumberHops < Length )
  45.  
  46. do {
  47. Length = rand() % Max;
  48. }
  49. while( Length < Min );
  50.  
  51. Length = Min + rand() % (Max - Min);
  52.  
  53. Length = random number in the range [Min, Max)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement