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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T20:11:32+00:00 2026-06-01T20:11:32+00:00

how to calculate the shortest path between two nodes in a graph where the

  • 0

how to calculate the shortest path between two nodes in a graph where the source and target are the same?

Graph:

A->B(5)
A->D(5)
A->E(7)
B->C(4)
C->D(8)
C->E(2)
D->C(8)
D->E(6)
E->B(3)

for example what is the shortest path between B and B? I tried to use dijkstra but didn’t work, it always return B->B in the first step.

correct ans: B->C->E->B

  • 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-01T20:11:33+00:00Added an answer on June 1, 2026 at 8:11 pm

    Split the vertex into two: B1 and B2, where all edges that started in B in the original graph will start in B1; all edges that terminated in B will terminate in B2.

    After that, you can run Dijkstra to find shortest path from B1 to B2 in the modified graph.

    Note: if you want to preserve all paths in the graph, add an additional edge B2->B1. That will not change the result for your cycle search, and all the paths in the original and modified graph will be equivalent

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

Sidebar

Related Questions

I am writing a program to calculate the shortest path between two nodes. In
I use the JUNG API to calculate shortest paths between several nodes in medium
I have undirected graph with 57 nodes and 204 linkages. I calculate the shortest
I am trying to calculate the shortest distance between any two numbers in an
I want to calculate distance between two points. I googled it but all I
I have an application that finds the shortest path between 2 squares, and when
Requirements: Calculate the number of months between two dates: receiveDate and dueDate. Both optimistic
I am trying to calculate the distance between two points (Pins) on the iPhone
I want to calculate total say Sundays,Mondays...Saturdays between two days. I want a do
I have a directed acyclic graph and need to find the shortest paths with

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.