C++ Data Structures: Dijkstra's Algorithm

Поділитися
Вставка
  • Опубліковано 8 січ 2025

КОМЕНТАРІ • 19

  • @LamNguyen-jp5vh
    @LamNguyen-jp5vh 2 роки тому +1

    Thank you so much for your help! Thanks to this, I understand the dijkstra algo better

  • @bumate90
    @bumate90 4 роки тому +6

    Great video, however I would use letters to represent the vertices(A, B, C...) to avoid confusion.
    Also you can increase the readability by representing a node like this: pair node.
    This way your graph would contain nodes instead of edges.

  • @pseudounknow5559
    @pseudounknow5559 3 роки тому +2

    Just to be inline with your graphical representation since it's an undirected graph when adding an edge we have to add 2 links like that :
    void Graph::addEdge(int v1, int v2, int weight){
    adj[v1].push_back(make_pair(v2, weight));
    adj[v2].push_back(make_pair(v1, weight));
    }

  • @hosseinyah4247
    @hosseinyah4247 4 роки тому +2

    Such great video bro, leaved a like.

  • @kennytran8203
    @kennytran8203 3 роки тому +1

    Hey, love the vid! Would you mind explaining how one could take your current implementation and potentially add a way to describe each path as it passes through the iteration? Instead of displaying the distance would it be possible to output the route?

    • @pseudounknow5559
      @pseudounknow5559 3 роки тому

      You would have to use an array of size V to keep track for each node from which node we have come. You can then implement a function to print recursively the path.

  • @student2432
    @student2432 3 роки тому

    the code is perfect but visual studio is showing "can not open or find the pdb file"
    what should i do ?
    please help

  • @igorswies5913
    @igorswies5913 10 місяців тому

    Shouldn't the set be sorting the pair according to the weight, not the vertex? Are you sure this works?

    • @karamany9870
      @karamany9870 9 місяців тому

      the extract_set has weight as first and vertex as second. So it's sorted according to the weights.

  • @DanielDuran-dy7wd
    @DanielDuran-dy7wd 2 роки тому

    How can I print the path it took?

  • @usamaahmadsaleem4183
    @usamaahmadsaleem4183 3 роки тому

    how can we also print the shortest path it takes and not only the cost...

  • @ASD9344
    @ASD9344 2 роки тому

    Will this implementation work for unweighted graph by inserting all weights as "1" ?

    • @sirmonke8946
      @sirmonke8946 Рік тому

      This comment is over 1 year old and there is a 99% chance you already got the answer, but yes, it would work. However, in an unweighted graph is would be more effective to use breadth-first search instead.

  • @webgpu
    @webgpu 4 роки тому

    It doesn't show the "Path" (vertices from origin to destiny) just the total distance.

    • @NotesByNick
      @NotesByNick  4 роки тому

      Yep!

    • @zomy2k
      @zomy2k 4 роки тому

      @@NotesByNick How would you go about printing the paths?

    • @pseudounknow5559
      @pseudounknow5559 3 роки тому +2

      @@zomy2k You would have to use an array of size V to keep track for each node from which node we have come. You can then implement a function to print recursively the path.

  • @itsmejohnson0891
    @itsmejohnson0891 3 роки тому

    Hi.. can we use this C++ code on codeblocks ?

    • @NotesByNick
      @NotesByNick  3 роки тому

      I don't know what codeblocks is, but this is just C++ code (not platform specific). If codeblocks just uses a mainstream C++ compiler, I don't see why not.