reader_writer_demo.cc File Reference
Detailed Description
This simple demo program gives an example of how to read and write a graph and additional maps (on the nodes or the edges) from/to a stream.
#include <iostream>
#include <lemon/smart_graph.h>
#include <lemon/graph_reader.h>
#include <lemon/graph_writer.h>
using namespace lemon;
int main() {
SmartGraph graph;
try {
std::string filename="sample.lgf";
std::string name;
GraphReader<SmartGraph> reader(filename,graph);
SmartGraph::EdgeMap<int> cap(graph);
reader.readEdgeMap("capacity",cap);
reader.readAttribute("name",name);
reader.run();
std::cout << "Hello! We have read a graph from file " << filename<<
" and some maps on it:\n now we write it to the standard output!" <<
std::endl;
GraphWriter<SmartGraph> writer(std::cout, graph);
writer.writeEdgeMap("multiplicity", cap);
writer.writeAttribute("name",name);
writer.run();
} catch (DataFormatError& error) {
std::cerr << error.what() << std::endl;
}
return 0;
}
#include <iostream>
#include <lemon/smart_graph.h>
#include <lemon/graph_reader.h>
#include <lemon/graph_writer.h>