-1

I want to implement the dijkstra algorithm and have to set each note at the beginning to infinity.

I would like to know, if there is any function in Java which makes it easy.

4
  • 2
    First show us what you have implemented. Commented Jun 8, 2017 at 12:40
  • 1
    If you're talking about distance, simply take -1. A valid distance can't be <1 so you can easily identify -1 as "unseen". Commented Jun 8, 2017 at 12:42
  • Or use null and store all distance in Long objects Commented Jun 8, 2017 at 12:45
  • @rollback In dijkstra, we initialize the distance array with positive infinity. Commented Jun 8, 2017 at 12:46

1 Answer 1

1

Double.POSITIVE_INFINITY if you are using Double to store your data. Also note that this is not a number, which is nice depending on what you want to do. Double supports this concept.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.