demo/reader_writer_demo.cc
changeset 2494 839c74eeba84
parent 2391 14a343be7a5a
child 2553 bfced05fa852
equal deleted inserted replaced
9:bdc96031c5e5 10:475aabf574a9
    37 int main() {
    37 int main() {
    38   SmartGraph graph;
    38   SmartGraph graph;
    39 
    39 
    40   try {
    40   try {
    41     std::string filename="sample.lgf";
    41     std::string filename="sample.lgf";
       
    42     std::string name;
    42     GraphReader<SmartGraph> reader(filename,graph);
    43     GraphReader<SmartGraph> reader(filename,graph);
    43     SmartGraph::EdgeMap<int> cap(graph);
    44     SmartGraph::EdgeMap<int> cap(graph);
    44     reader.readEdgeMap("capacity",cap);
    45     reader.readEdgeMap("capacity",cap);
       
    46     reader.readAttribute("name",name);
    45     reader.run();
    47     reader.run();
    46 
    48 
    47     std::cout << "Hello! We have read a graph from file " << filename<< 
    49     std::cout << "Hello! We have read a graph from file " << filename<< 
    48       " and some maps on it:\n now we write it to the standard output!" << 
    50       " and some maps on it:\n now we write it to the standard output!" << 
    49       std::endl;
    51       std::endl;
    50 
    52 
    51 
    53 
    52     GraphWriter<SmartGraph> writer(std::cout, graph);
    54     GraphWriter<SmartGraph> writer(std::cout, graph);
    53     writer.writeEdgeMap("multiplicity", cap);
    55     writer.writeEdgeMap("multiplicity", cap);
       
    56     writer.writeAttribute("name",name);
    54     writer.run();
    57     writer.run();
    55      
    58      
    56   } catch (DataFormatError& error) {
    59   } catch (DataFormatError& error) {
    57     std::cerr << error.what() << std::endl;
    60     std::cerr << error.what() << std::endl;
    58   }
    61   }