equal
deleted
inserted
replaced
1 // -*- c++ -*- |
1 // -*- c++ -*- |
2 |
2 |
3 // Use a DIMACS max flow file as stdin. |
3 // Use a DIMACS max flow file as input. |
4 // sub_graph_adaptor_demo < dimacs_max_flow_file |
4 // sub_graph_adaptor_demo < dimacs_max_flow_file |
5 // This program computes a maximum number of edge-disjoint shortest paths |
5 // This program computes a maximum number of edge-disjoint shortest paths |
6 // between s and t. |
6 // between s and t. |
7 |
7 |
8 #include <iostream> |
8 #include <iostream> |
19 using namespace lemon; |
19 using namespace lemon; |
20 |
20 |
21 using std::cout; |
21 using std::cout; |
22 using std::endl; |
22 using std::endl; |
23 |
23 |
24 int main() |
24 int main(int argc, char *argv[]) |
25 { |
25 { |
|
26 if(argc<2) |
|
27 { |
|
28 std::cerr << "USAGE: sub_graph_adaptor_demo <input_file.dim>" << std::endl; |
|
29 std::cerr << "The file 'input_file.dim' has to contain a max flow instance in DIMACS format (e.g. sub_graph_adaptor_demo.dim is such a file)." << std::endl; |
|
30 return 0; |
|
31 } |
|
32 |
|
33 |
|
34 //input stream to read the graph from |
|
35 std::ifstream is(argv[1]); |
|
36 |
26 typedef SmartGraph Graph; |
37 typedef SmartGraph Graph; |
27 |
38 |
28 typedef Graph::Edge Edge; |
39 typedef Graph::Edge Edge; |
29 typedef Graph::Node Node; |
40 typedef Graph::Node Node; |
30 typedef Graph::EdgeIt EdgeIt; |
41 typedef Graph::EdgeIt EdgeIt; |
33 |
44 |
34 Graph g; |
45 Graph g; |
35 Node s, t; |
46 Node s, t; |
36 LengthMap length(g); |
47 LengthMap length(g); |
37 |
48 |
38 readDimacs(std::cin, g, length, s, t); |
49 readDimacs(is, g, length, s, t); |
39 |
50 |
40 cout << "edges with lengths (of form id, source--length->target): " << endl; |
51 cout << "edges with lengths (of form id, source--length->target): " << endl; |
41 for(EdgeIt e(g); e!=INVALID; ++e) |
52 for(EdgeIt e(g); e!=INVALID; ++e) |
42 cout << " " << g.id(e) << ", " << g.id(g.source(e)) << "--" |
53 cout << " " << g.id(e) << ", " << g.id(g.source(e)) << "--" |
43 << length[e] << "->" << g.id(g.target(e)) << endl; |
54 << length[e] << "->" << g.id(g.target(e)) << endl; |