Algorithms in a Nutshell

(Tina Meador) #1

(^158) | Chapter 6: Graph Algorithms
Figure 6-15. Dijkstra’s Algorithm for dense graphs fact sheet
Example 6-5. Optimized Dijkstra’s Algorithm for dense graphs
/**



  • Given int[][] of edge weights in raw form, compute shortest distance to

  • all vertices in graph (dist) and record predecessor links for all

  • vertices (pred) to be able to recreate these paths. An edge weight of

  • INF means no edge. Suitable for Dense Graphs Only.
    */
    void singleSourceShortestDense(int n, int * const weight, int s, / in */
    Algorithms in a Nutshell
    Algorithms in a Nutshell By Gary Pollice, George T. Heineman, Stanley Selkow ISBN:
    9780596516246 Publisher: O'Reilly Media, Inc.
    Prepared for Ming Yi, Safari ID: [email protected]
    Licensed by Ming Yi
    Print Publication Date: 2008/10/21 User number: 594243
    © 2009 Safari Books Online, LLC. This PDF is made available for personal use only during the relevant subscription term, subject to the Safari Terms of Service. Any other use

Free download pdf