athos@1528
|
1 |
#include <iostream>
|
athos@1528
|
2 |
#include <lemon/smart_graph.h>
|
athos@1528
|
3 |
#include <lemon/invalid.h>
|
athos@1528
|
4 |
#include <lemon/graph_reader.h>
|
athos@1528
|
5 |
#include <lemon/graph_writer.h>
|
athos@1528
|
6 |
|
athos@1528
|
7 |
|
athos@1528
|
8 |
using namespace lemon;
|
athos@1528
|
9 |
|
athos@1528
|
10 |
int main() {
|
athos@1528
|
11 |
SmartGraph graph;
|
athos@1528
|
12 |
|
athos@1528
|
13 |
try {
|
athos@1528
|
14 |
std::string filename="sample.lgf";
|
athos@1528
|
15 |
GraphReader<SmartGraph> reader(filename,graph);
|
athos@1528
|
16 |
SmartGraph::EdgeMap<int> cap(graph);
|
athos@1528
|
17 |
reader.readEdgeMap("capacity",cap);
|
athos@1528
|
18 |
// reader.readNode("source",s).readNode("target",t)
|
athos@1528
|
19 |
// .readEdgeMap("capacity",cap).run();
|
athos@1528
|
20 |
reader.run();
|
athos@1528
|
21 |
|
athos@1528
|
22 |
std::cout << "Hello! We have read a graph from file " << filename<<
|
athos@1528
|
23 |
" and some maps on it: now we write this to the standard output!" <<
|
athos@1528
|
24 |
std::endl;
|
athos@1528
|
25 |
|
athos@1528
|
26 |
|
athos@1528
|
27 |
GraphWriter<SmartGraph> writer(std::cout, graph);
|
athos@1528
|
28 |
writer.writeEdgeMap("multiplicity", cap);
|
athos@1528
|
29 |
// writer.writeNode("source", s);
|
athos@1528
|
30 |
// writer.writeNode("target", t);
|
athos@1528
|
31 |
writer.run();
|
athos@1528
|
32 |
|
athos@1528
|
33 |
// LemonReader reader(std::cin);
|
athos@1528
|
34 |
|
athos@1528
|
35 |
// NodeSetReader<SmartGraph> nodeset(reader, graph);
|
athos@1528
|
36 |
// SmartGraph::NodeMap<int> cost(graph);
|
athos@1528
|
37 |
// nodeset.readMap("cost", cost);
|
athos@1528
|
38 |
// SmartGraph::NodeMap<char> mmap(graph);
|
athos@1528
|
39 |
// nodeset.readMap("mmap", mmap);
|
athos@1528
|
40 |
|
athos@1528
|
41 |
// EdgeSetReader<SmartGraph> edgeset(reader, graph, nodeset);
|
athos@1528
|
42 |
// SmartGraph::EdgeMap<std::string> description(graph);
|
athos@1528
|
43 |
// edgeset.readMap<QuotedStringReader>("description", description);
|
athos@1528
|
44 |
|
athos@1528
|
45 |
// NodeReader<SmartGraph> nodes(reader, nodeset);
|
athos@1528
|
46 |
// SmartGraph::Node source;
|
athos@1528
|
47 |
// nodes.readNode("source", source);
|
athos@1528
|
48 |
// SmartGraph::Node target;
|
athos@1528
|
49 |
// nodes.readNode("target", target);
|
athos@1528
|
50 |
|
athos@1528
|
51 |
// AttributeReader<> attribute(reader, "gui");
|
athos@1528
|
52 |
// std::string author;
|
athos@1528
|
53 |
// attribute.readAttribute<LineReader>("author", author);
|
athos@1528
|
54 |
// int count;
|
athos@1528
|
55 |
// attribute.readAttribute("count", count);
|
athos@1528
|
56 |
|
athos@1528
|
57 |
// PrintReader print(reader);
|
athos@1528
|
58 |
|
athos@1528
|
59 |
// reader.run();
|
athos@1528
|
60 |
|
athos@1528
|
61 |
|
athos@1528
|
62 |
// for (SmartGraph::NodeIt it(graph); it != INVALID; ++it) {
|
athos@1528
|
63 |
// std::cout << cost[it] << ' ' << mmap[it] << std::endl;
|
athos@1528
|
64 |
// }
|
athos@1528
|
65 |
|
athos@1528
|
66 |
// for (SmartGraph::EdgeIt it(graph); it != INVALID; ++it) {
|
athos@1528
|
67 |
// std::cout << description[it] << std::endl;
|
athos@1528
|
68 |
// }
|
athos@1528
|
69 |
|
athos@1528
|
70 |
// std::cout << "author: " << author << std::endl;
|
athos@1528
|
71 |
// std::cout << "count: " << count << std::endl;
|
athos@1528
|
72 |
|
athos@1528
|
73 |
// std::cout << "source cost: " << cost[source] << std::endl;
|
athos@1528
|
74 |
// std::cout << "target cost: " << cost[target] << std::endl;
|
athos@1528
|
75 |
|
athos@1528
|
76 |
// std::cout.flush();
|
athos@1528
|
77 |
} catch (DataFormatError& error) {
|
athos@1528
|
78 |
std::cerr << error.what() << std::endl;
|
athos@1528
|
79 |
}
|
athos@1528
|
80 |
|
athos@1528
|
81 |
|
athos@1528
|
82 |
return 0;
|
athos@1528
|
83 |
}
|