COIN-OR::LEMON - Graph Library

Changeset 1286:692948b894e8 in lemon-0.x for src/work/peter/xy-reader.cc


Ignore:
Timestamp:
04/01/05 10:28:51 (20 years ago)
Author:
Hegyi Péter
Branch:
default
Phase:
public
Convert:
svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk@1719
Message:

Peter is able to read xy vector from file.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/work/peter/xy-reader.cc

    r1278 r1286  
    1515typedef Graph::NodeMap<Coordinates> CoordinatesMap;
    1616typedef Graph::Node Node;
     17typedef Graph::EdgeIt EdgeIt;
     18typedef Graph::NodeIt NodeIt;
    1719
    18 class CoordReaderMap: public MapBase<Node, double>
     20class CoordReaderMap: public MapBase <Node, double>
    1921{
    20     CoordinatesMap * cm;
     22    CoordinatesMap & cm;
    2123    char xoy;
    2224
    2325public:
    24     CoordReaderMap(char xory, CoordinatesMap * coordmap): cm(coordmap)
     26    CoordReaderMap(char xory, CoordinatesMap & coordmap): cm(coordmap)
    2527    {
    2628        switch(xory)
     
    4042        {
    4143            case 'x':
    42                 (*cm)[node].x=coord;
     44                cm[node].x=coord;
    4345                break;
    4446            case 'y':
    45                 (*cm)[node].y=coord;
     47                cm[node].y=coord;
    4648                break;
    4749            default:
     
    5658    CoordinatesMap cm(g);
    5759
    58     CoordReaderMap xreader('x',&cm);
    59     CoordReaderMap yreader('y',&cm);
     60    CoordReaderMap xreader('x',cm);
     61    CoordReaderMap yreader('y',cm);
    6062
    61     std::ifstream is("dijkstra_test.lemon");
     63    std::ifstream is("graphocska.lemon");
    6264   
    6365    GraphReader<Graph> reader(is, g);
     
    6567    reader.addNodeMap("coordinates_y", yreader);
    6668    reader.run();
    67    
     69    std::cout << "Megvagyok" << std::endl;
     70
     71    for (NodeIt i(g); i!=INVALID; ++i)
     72        std::cout << " " << g.id(i) << " " << cm[i];
     73    std::cout << std::endl;
     74
    6875    return 0;
    6976}
Note: See TracChangeset for help on using the changeset viewer.