Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8419459
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T02:37:05+00:00 2026-06-10T02:37:05+00:00

I am trying to implement Distance Vector Routing algorithm, using http://www.cs.bu.edu/fac/byers/courses/791/F99/scribe_notes/cs791-notes-990923.html (in C++). Here

  • 0

I am trying to implement Distance Vector Routing algorithm, using http://www.cs.bu.edu/fac/byers/courses/791/F99/scribe_notes/cs791-notes-990923.html
(in C++).

Here is what I have done so

far:

i) Read no. of nodes.

ii) Implement the points 1 to 4 in the article as:

     for(i = 0; i < nodes; i++) //nodes is the no. of nodes
     {
         for(j = 0; j < nodes; j++)
         {
             if(distanceVector[i][j] != 0) //distanceVector holds the cost value between every pair of links, 0 if no link exists
             {
                  for(k = 0; k < nodes; k++)
                  {
                       if((distanceVector[i][j] + distanceVector[j][k]) < distanceVector[i][k])
                       {
                             distanceVector[i][k] = distanceVector[i][j] + distanceVector[j][k];
                             via[i][j] = i; // intermediate node, in case no link exists
                             via[j][i] = j;
                       }
                  }
              }
         }
     }

I get the same array / matrix as it is. I have also tried juggling i, j, and k, but of no use.

Am I right in my implementation…???

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T02:37:07+00:00Added an answer on June 10, 2026 at 2:37 am

    Two things bother me about your code. First, you are using “0” to represent “no link”. This can get you in trouble. The code basically read as follows: “if there is an intermediary point j, that makes that path from i to k shorter, change the path from i to k to pass via k”. Therefore, using “0” to represent “no link” might make your code choose wrong “via”s. Try instead to use infinity (if you are using floating point) or a really big value (e.g., MAX_INT).

    Second, these lines look wrong:

    via[i][j] = i; // intermediate node, in case no link exists
    via[j][i] = j;
    

    Since you found a path from i to k via j that is shorter, it should be:

    via[i][k] = j; // intermediate node, in case no link exists
    via[k][i] = j;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to implement the Minimum Distance Algorithm for image classification using GDAL and
I'm trying to implement the distance matrix in parallel using openmp in which I
We are trying to implement levensteing distance algorithm in assembly and calling the assembly
I'm trying to implement this: from https://docs.google.com/viewer?url=http://www.tinaja.com/glib/bezdist.pdf&pli=1 The following BASIC program uses the method
I'm trying to implement solr to use the spatial searches to find the distance
I am trying to implement a simpler version of this algorithm but which works
I'm trying to implement the levenshtein distance (or edit distance) in Haskell, but its
I am trying to implement the command pattern to control a robot. I'm using
I'm trying to implement a 6 Degrees-style algorithm, in that I'm trying to find
i'm new to c++ and have been trying to implement the bellman ford algorithm,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.