COIN-OR::LEMON - Graph Library

Changeset 1641:77f6ab7ad66f in lemon-0.x for demo/dijkstra_demo.cc


Ignore:
Timestamp:
08/18/05 00:07:35 (19 years ago)
Author:
Alpar Juttner
Branch:
default
Phase:
public
Convert:
svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk@2154
Message:

Demos' documentations include the source.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • demo/dijkstra_demo.cc

    r1636 r1641  
    2323/// facilities supplied by our implementation: for the detailed
    2424/// documentation of the LEMON Dijkstra class read \ref lemon::Dijkstra "this".
     25///
     26/// \include dijkstra_demo.cc
    2527
    2628#include <iostream>
     
    2830#include <lemon/list_graph.h>
    2931#include <lemon/dijkstra.h>
    30 //#include <lemon/graph_writer.h>
    3132
    3233using namespace lemon;
     
    7071    len.set(v5_t, 8);
    7172
    72     std::cout << "This program is a simple demo of the LEMON Dijkstra class."<<std::endl;
    73     std::cout << "We calculate the shortest path from node s to node t in a graph."<<std::endl;
    74     std::cout <<std::endl;
     73    std::cout << "This program is a simple demo of the LEMON Dijkstra class."
     74              << std::endl;
     75    std::cout <<
     76      "We calculate the shortest path from node s to node t in a graph."
     77              << std::endl;
     78    std::cout << std::endl;
    7579
    7680
    77     std::cout << "The id of s is " << g.id(s)<< ", the id of t is " << g.id(t)<<"."<<std::endl;
     81    std::cout << "The id of s is " << g.id(s)<< ", the id of t is "
     82              << g.id(t) << "." << std::endl;
    7883
    7984    std::cout << "Dijkstra algorithm demo..." << std::endl;
    80 
    8185
    8286    Dijkstra<Graph, LengthMap> dijkstra_test(g,len);
    8387   
    8488    dijkstra_test.run(s);
     89   
     90    std::cout << "The distance of node t from node s: "
     91              << dijkstra_test.dist(t) << std::endl;
    8592
     93    std::cout << "The shortest path from s to t goes through the following "
     94              << "nodes (the first one is t, the last one is s): "
     95              << std::endl;
     96
     97    for (Node v=t;v != s; v=dijkstra_test.predNode(v)) {
     98      std::cout << g.id(v) << "<-";
     99    }
    86100   
    87     std::cout << "The distance of node t from node s: " << dijkstra_test.dist(t)<<std::endl;
    88 
    89     std::cout << "The shortest path from s to t goes through the following nodes (the first one is t, the last one is s): "<<std::endl;
    90 
    91     for (Node v=t;v != s; v=dijkstra_test.predNode(v)){
    92         std::cout << g.id(v) << "<-";
    93     }
    94101    std::cout << g.id(s) << std::endl; 
    95102   
    96 
    97103    return 0;
    98104}
    99 
    100 
    101 
    102 
    103 
    104 
    105 
    106 
    107 
Note: See TracChangeset for help on using the changeset viewer.