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 6887951
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T05:56:54+00:00 2026-05-27T05:56:54+00:00

All, I am reading about the relationship between all pairs shortest path and matrix

  • 0

All,

I am reading about the relationship between all pairs shortest path and matrix multiplication.

Consider the multiplication of the weighted adjacency matrix with
itself – except, in this case, we replace the multiplication operation
in matrix multiplication by addition, and the addition operation by
minimization. Notice that the product of weighted adjacency matrix
with itself returns a matrix that contains shortest paths of length 2
between any pair of nodes.

It follows from this argument that A to power of n contains all shortest paths.

Question number 1:

My question is that in a graph we will be having at most n-1 edges between two nodes in a path, on what basis is the author discussing of path of length “n”?

Following slides

http://www.infosun.fim.uni-passau.de/br/lehrstuhl/…/Westerheide2.PPT

On slide 10 it is mentioned as below.

dij(1) = cij

dij(m) = min (dij(m-1), min1≤k≤n {dik(m-1) + ckj}) --> Eq 1
       = min1≤k≤n {dik(m-1) + ckj} ------------------> Eq 2

Question 2: how author concluded Eq 2 from Eq 1.

In Cormen et al book on introduction to algorithms, it is mentioned as below:

What are the actual shortest-path weights delta(i, j)? If the graph contains no negative-weight cycles, then all shortest paths are simple and thus contain at most n – 1 edges. A path from vertex i to vertex j with more than n – 1 edges cannot have less weight than a shortest path from i to j. The actual shortest-path weights are therefore given by

delta(i,j) = d(i,j) power (n-1) = (i,j) power (n) = (i,j) power (n+1) = …

Question 3: in above equation how author came with n, n+1 edges as we have at most n-1, and also how above assignment works?

Thanks!

  • 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-05-27T05:56:54+00:00Added an answer on May 27, 2026 at 5:56 am
    1. The n vs n-1 is just an unfortunate variable name choice. He should have used a different letter instead to be more clear.

      A^1 has the shortest paths of length up to 1 (trivially)
      A^2 has the shortest paths of length up to 2
      A^k has the shortest paths of length up to k
      
    2. Eq 2 does not directly come from Eq1. Eq 2 is just the second term from the first equation. I presume this is a formatting or copy-paste error (I can’t check – your ppt link is broken)

    3. The author is just explicitly pointing out that you have nothing to gain by adding more then n-1 edges to the path:

      A^(n-1),            //the shortest paths of length up tp (n-1)
      is equal to A^n     //the shortest paths of length up tp (n)
      is equal to A^(n+1) //the shortest paths of length up tp (n+1)
      ...
      

      This is just so that you can safely stop your computations at (n-1) and be sure that you have the minimum paths among all paths of all lengths. (This is kind of obvious but the textbook has a point in being strict here…)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Recently I was reading about Codd's 12 Rules , and I understood all except
How would I go about reading all lines between two specific lines? Lets say
I keep reading about C99 and C++11 and all these totally sweet things that
When I first started reading about Python, all of the tutorials have you use
I´m a little bit confused by reading all the posts and tutorials about starting
How would I go about reading all files in a directory? In C# I
I have been reading about dependency properties in several books but all have one
After reading about MP4 and .ogv file conversions and all manner of video players,
I am learning about all things SQL, and upon reading about indexes I naturally
I'm reading about AST (abstract syntax trees) but all the samples I see use

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.