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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T07:12:16+00:00 2026-06-02T07:12:16+00:00

Given an directed unweighted acylic graph, I am trying to adapt Floyd-Warshall algorithm to

  • 0

Given an directed unweighted acylic graph, I am trying to adapt Floyd-Warshall algorithm to count the number of paths between 2 vertices. My code currently looks like this:

for all k in 1 to n
for all i in 1 to n
for all j in 1 to n
Aij = Aij + ( Aik * Akij).

Therefore, instead of checking and replacing for min distance, I am doing the following:

Count of paths between (i,j) without k + ( Count of paths from i to k * Count of paths from k * j )

My final array, should have the number of paths between any 2 vertices.

I am not able to prove that this does not give me the count of simple paths between 2 vertices, but there are no suggestions to use this approach elsewhere.

Can someone provide a counter example where this fails?

PS: This is not my homework, but just a programming exercise I picked up.

  • 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-02T07:12:17+00:00Added an answer on June 2, 2026 at 7:12 am

    In an undirected unweighted acylic graph there’s at most 1 path between any two vertices. If there were more distinct paths, they would create a cycle. (not relevant after question was edited)

    For directed graphs, I don’t see a problem with your algorithm. The usage of modified Floyd-Warshall algorithm is actually mentioned in this paper. The reason it’s not used widely is probably its complexity – O(n3) compared to O(m+n) of this simple approach

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

Sidebar

Related Questions

I've a directed unweighted graph. Number of nodes and all links between nodes are
Given a directed graph with weighted edges, what algorithm can be used to give
Given a directed graph, I need to find the minimum set of vertices from
Given a directed, connected graph with only positive edge weights, are there faster algorithms
Given a directed graph, the goal is to combine the node with the nodes
Given a parameter k , I'm trying to delete k edges from a directed
Given the following problem : Given the directed graph G=(V,E) with the weight function
How to get the shortest path between 2 given nodes of a cyclic directed
Let's say we have a fully connected directed graph G . The vertices are
I'm trying to perform some calculations on a non-directed, cyclic, weighted graph, and I'm

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.