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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T16:53:23+00:00 2026-05-26T16:53:23+00:00

I am trying to find out if it is possible to use Dijkstra’s algorithm

  • 0

I am trying to find out if it is possible to use Dijkstra’s algorithm to find the longest path in a directed acyclic path. I know that it is not possible to find the longest path with Dijkstra in a general graph, because of negative cost cycles. But it should work in a DAG, I think. Through Google I found a lot of conflicting sources. Some say it works in a dag and some say it does not work, but I didn’t find a proof or a counter example. Can someone point me to a proof or a counter example?

  • 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-26T16:53:24+00:00Added an answer on May 26, 2026 at 4:53 pm

    I thought about the problem and I think it is not possible in general. Being acyclic is not enough, I think.

    For example:

    We want to go from a to c in this dag.

    a - > b - > c
    |           /\
    v           |
    d - - - - - 
    

    d-c has length 4

    a-d has length 1

    all others have length 2

    If you just replace the min function with a max function, the algorithm will lead to a-b-c but the longest path is a-d-c.

    I found two special cases where you can use Dijkstra for calculating the longest path:

    1. The graph is not only directed acyclic, but also acyclic if you remove the directions. In other words: It is a tree. Because in a tree the longest path is also the shortest path.
    2. The graph has only negative weights. Then you can use max instead of min to find the longest path. BUT this works only if the weights are really negative. If you just invert positive weights it will not work.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to find out if it is possible to use someone else's
I'm trying to find out if it's possible to develop a key capturing application
Im trying to find out a good JavaScript library that can create a nice
I'm writing an application that uses Dijkstra algorithm to find minimal paths in the
I'm new to jquery and i'm trying to find out if it's possible to
Possible Duplicate: Java Class.cast() vs. cast operator I am unsuccessfully trying to find out
I'm trying to find out what my choices are when I'm going to use
I'm not familiar with Hudson or OSX, I'm just trying to find out if
I am trying to find out if it's possible to Accept Payments from PayPal
I am trying to find out how (if possible) can I create an MSI

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.