Changes in / [292:e7af73f1805e:294:cbe3ec2d59d2] in lemon-1.2
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
demo/lgf_demo.cc
r290 r294 45 45 46 46 try { 47 digraphReader( "digraph.lgf", g). // read the directed graph into g47 digraphReader(g, "digraph.lgf"). // read the directed graph into g 48 48 arcMap("capacity", cap). // read the 'capacity' arc map into cap 49 49 node("source", s). // read 'source' node to s … … 61 61 std::cout << "We can write it to the standard output:" << std::endl; 62 62 63 digraphWriter( std::cout, g).// write g to the standard output63 digraphWriter(g). // write g to the standard output 64 64 arcMap("capacity", cap). // write cap into 'capacity' 65 65 node("source", s). // write s to 'source' -
lemon/lgf_reader.h
r291 r294 393 393 394 394 template <typename Digraph> 395 DigraphReader<Digraph> digraphReader(std::istream& is, Digraph& digraph); 395 DigraphReader<Digraph> digraphReader(Digraph& digraph, 396 std::istream& is = std::cin); 396 397 397 398 template <typename Digraph> 398 DigraphReader<Digraph> digraphReader( const std::string& fn, Digraph& digraph);399 DigraphReader<Digraph> digraphReader(Digraph& digraph, const std::string& fn); 399 400 400 401 template <typename Digraph> 401 DigraphReader<Digraph> digraphReader( const char *fn, Digraph& digraph);402 DigraphReader<Digraph> digraphReader(Digraph& digraph, const char *fn); 402 403 403 404 /// \ingroup lemon_io … … 422 423 /// 423 424 ///\code 424 /// DigraphReader<Digraph>( std::cin, digraph).425 /// DigraphReader<Digraph>(digraph, std::cin). 425 426 /// nodeMap("coordinates", coord_map). 426 427 /// arcMap("capacity", cap_map). … … 503 504 /// Construct a directed graph reader, which reads from the given 504 505 /// input stream. 505 DigraphReader( std::istream& is, Digraph& digraph)506 DigraphReader(Digraph& digraph, std::istream& is = std::cin) 506 507 : _is(&is), local_is(false), _digraph(digraph), 507 508 _use_nodes(false), _use_arcs(false), … … 512 513 /// Construct a directed graph reader, which reads from the given 513 514 /// file. 514 DigraphReader( const std::string& fn, Digraph& digraph)515 DigraphReader(Digraph& digraph, const std::string& fn) 515 516 : _is(new std::ifstream(fn.c_str())), local_is(true), 516 517 _filename(fn), _digraph(digraph), … … 524 525 /// Construct a directed graph reader, which reads from the given 525 526 /// file. 526 DigraphReader( const char* fn, Digraph& digraph)527 DigraphReader(Digraph& digraph, const char* fn) 527 528 : _is(new std::ifstream(fn)), local_is(true), 528 529 _filename(fn), _digraph(digraph), … … 557 558 private: 558 559 559 friend DigraphReader<Digraph> digraphReader<>( std::istream& is,560 Digraph& digraph);561 friend DigraphReader<Digraph> digraphReader<>( const std::string& fn,562 Digraph& digraph);563 friend DigraphReader<Digraph> digraphReader<>( const char *fn,564 Digraph& digraph);560 friend DigraphReader<Digraph> digraphReader<>(Digraph& digraph, 561 std::istream& is); 562 friend DigraphReader<Digraph> digraphReader<>(Digraph& digraph, 563 const std::string& fn); 564 friend DigraphReader<Digraph> digraphReader<>(Digraph& digraph, 565 const char *fn); 565 566 566 567 DigraphReader(DigraphReader& other) … … 1188 1189 /// \relates DigraphReader 1189 1190 template <typename Digraph> 1190 DigraphReader<Digraph> digraphReader(std::istream& is, Digraph& digraph) { 1191 DigraphReader<Digraph> tmp(is, digraph); 1191 DigraphReader<Digraph> digraphReader(Digraph& digraph, 1192 std::istream& is = std::cin) { 1193 DigraphReader<Digraph> tmp(digraph, is); 1192 1194 return tmp; 1193 1195 } … … 1198 1200 /// \relates DigraphReader 1199 1201 template <typename Digraph> 1200 DigraphReader<Digraph> digraphReader( const std::string& fn,1201 Digraph& digraph) {1202 DigraphReader<Digraph> tmp( fn, digraph);1202 DigraphReader<Digraph> digraphReader(Digraph& digraph, 1203 const std::string& fn) { 1204 DigraphReader<Digraph> tmp(digraph, fn); 1203 1205 return tmp; 1204 1206 } … … 1209 1211 /// \relates DigraphReader 1210 1212 template <typename Digraph> 1211 DigraphReader<Digraph> digraphReader( const char* fn, Digraph& digraph) {1212 DigraphReader<Digraph> tmp( fn, digraph);1213 DigraphReader<Digraph> digraphReader(Digraph& digraph, const char* fn) { 1214 DigraphReader<Digraph> tmp(digraph, fn); 1213 1215 return tmp; 1214 1216 } … … 1218 1220 1219 1221 template <typename Graph> 1220 GraphReader<Graph> graphReader(std::istream& is, Graph& graph); 1222 GraphReader<Graph> graphReader(Graph& graph, 1223 std::istream& is = std::cin); 1221 1224 1222 1225 template <typename Graph> 1223 GraphReader<Graph> graphReader( const std::string& fn, Graph& graph);1226 GraphReader<Graph> graphReader(Graph& graph, const std::string& fn); 1224 1227 1225 1228 template <typename Graph> 1226 GraphReader<Graph> graphReader( const char *fn, Graph& graph);1229 GraphReader<Graph> graphReader(Graph& graph, const char *fn); 1227 1230 1228 1231 /// \ingroup lemon_io … … 1292 1295 /// Construct an undirected graph reader, which reads from the given 1293 1296 /// input stream. 1294 GraphReader( std::istream& is, Graph& graph)1297 GraphReader(Graph& graph, std::istream& is = std::cin) 1295 1298 : _is(&is), local_is(false), _graph(graph), 1296 1299 _use_nodes(false), _use_edges(false), … … 1301 1304 /// Construct an undirected graph reader, which reads from the given 1302 1305 /// file. 1303 GraphReader( const std::string& fn, Graph& graph)1306 GraphReader(Graph& graph, const std::string& fn) 1304 1307 : _is(new std::ifstream(fn.c_str())), local_is(true), 1305 1308 _filename(fn), _graph(graph), … … 1313 1316 /// Construct an undirected graph reader, which reads from the given 1314 1317 /// file. 1315 GraphReader( const char* fn, Graph& graph)1318 GraphReader(Graph& graph, const char* fn) 1316 1319 : _is(new std::ifstream(fn)), local_is(true), 1317 1320 _filename(fn), _graph(graph), … … 1345 1348 1346 1349 private: 1347 friend GraphReader<Graph> graphReader<>( std::istream& is, Graph& graph);1348 friend GraphReader<Graph> graphReader<>( const std::string& fn,1349 Graph& graph);1350 friend GraphReader<Graph> graphReader<>( const char *fn, Graph& graph);1350 friend GraphReader<Graph> graphReader<>(Graph& graph, std::istream& is); 1351 friend GraphReader<Graph> graphReader<>(Graph& graph, 1352 const std::string& fn); 1353 friend GraphReader<Graph> graphReader<>(Graph& graph, const char *fn); 1351 1354 1352 1355 GraphReader(GraphReader& other) … … 2022 2025 /// \relates GraphReader 2023 2026 template <typename Graph> 2024 GraphReader<Graph> graphReader( std::istream& is, Graph& graph) {2025 GraphReader<Graph> tmp( is, graph);2027 GraphReader<Graph> graphReader(Graph& graph, std::istream& is = std::cin) { 2028 GraphReader<Graph> tmp(graph, is); 2026 2029 return tmp; 2027 2030 } … … 2032 2035 /// \relates GraphReader 2033 2036 template <typename Graph> 2034 GraphReader<Graph> graphReader(const std::string& fn, 2035 Graph& graph) { 2036 GraphReader<Graph> tmp(fn, graph); 2037 GraphReader<Graph> graphReader(Graph& graph, const std::string& fn) { 2038 GraphReader<Graph> tmp(graph, fn); 2037 2039 return tmp; 2038 2040 } … … 2043 2045 /// \relates GraphReader 2044 2046 template <typename Graph> 2045 GraphReader<Graph> graphReader( const char* fn, Graph& graph) {2046 GraphReader<Graph> tmp( fn, graph);2047 GraphReader<Graph> graphReader(Graph& graph, const char* fn) { 2048 GraphReader<Graph> tmp(graph, fn); 2047 2049 return tmp; 2048 2050 } -
lemon/lgf_writer.h
r291 r294 353 353 354 354 template <typename Digraph> 355 DigraphWriter<Digraph> digraphWriter( std::ostream& os,356 const Digraph& digraph);355 DigraphWriter<Digraph> digraphWriter(const Digraph& digraph, 356 std::ostream& os = std::cout); 357 357 358 358 template <typename Digraph> 359 DigraphWriter<Digraph> digraphWriter(const std::string& fn,360 const Digraph& digraph);359 DigraphWriter<Digraph> digraphWriter(const Digraph& digraph, 360 const std::string& fn); 361 361 362 362 template <typename Digraph> 363 DigraphWriter<Digraph> digraphWriter(const char *fn,364 const Digraph& digraph);363 DigraphWriter<Digraph> digraphWriter(const Digraph& digraph, 364 const char *fn); 365 365 366 366 /// \ingroup lemon_io … … 383 383 /// 384 384 ///\code 385 /// DigraphWriter<Digraph>( std::cout, digraph).385 /// DigraphWriter<Digraph>(digraph, std::cout). 386 386 /// nodeMap("coordinates", coord_map). 387 387 /// nodeMap("size", size). … … 453 453 /// Construct a directed graph writer, which writes to the given 454 454 /// output stream. 455 DigraphWriter( std::ostream& is, const Digraph& digraph)456 : _os(& is), local_os(false), _digraph(digraph),455 DigraphWriter(const Digraph& digraph, std::ostream& os = std::cout) 456 : _os(&os), local_os(false), _digraph(digraph), 457 457 _skip_nodes(false), _skip_arcs(false) {} 458 458 … … 461 461 /// Construct a directed graph writer, which writes to the given 462 462 /// output file. 463 DigraphWriter(const std::string& fn, const Digraph& digraph)463 DigraphWriter(const Digraph& digraph, const std::string& fn) 464 464 : _os(new std::ofstream(fn.c_str())), local_os(true), _digraph(digraph), 465 465 _skip_nodes(false), _skip_arcs(false) { … … 471 471 /// Construct a directed graph writer, which writes to the given 472 472 /// output file. 473 DigraphWriter(const char* fn, const Digraph& digraph)473 DigraphWriter(const Digraph& digraph, const char* fn) 474 474 : _os(new std::ofstream(fn)), local_os(true), _digraph(digraph), 475 475 _skip_nodes(false), _skip_arcs(false) { … … 501 501 private: 502 502 503 friend DigraphWriter<Digraph> digraphWriter<>( std::ostream& os,504 const Digraph& digraph);505 friend DigraphWriter<Digraph> digraphWriter<>(const std::string& fn,506 const Digraph& digraph);507 friend DigraphWriter<Digraph> digraphWriter<>(const char *fn,508 const Digraph& digraph);503 friend DigraphWriter<Digraph> digraphWriter<>(const Digraph& digraph, 504 std::ostream& os); 505 friend DigraphWriter<Digraph> digraphWriter<>(const Digraph& digraph, 506 const std::string& fn); 507 friend DigraphWriter<Digraph> digraphWriter<>(const Digraph& digraph, 508 const char *fn); 509 509 510 510 DigraphWriter(DigraphWriter& other) … … 913 913 /// \relates DigraphWriter 914 914 template <typename Digraph> 915 DigraphWriter<Digraph> digraphWriter( std::ostream& os,916 const Digraph& digraph) {917 DigraphWriter<Digraph> tmp( os, digraph);915 DigraphWriter<Digraph> digraphWriter(const Digraph& digraph, 916 std::ostream& os = std::cout) { 917 DigraphWriter<Digraph> tmp(digraph, os); 918 918 return tmp; 919 919 } … … 924 924 /// \relates DigraphWriter 925 925 template <typename Digraph> 926 DigraphWriter<Digraph> digraphWriter(const std::string& fn,927 const Digraph& digraph) {928 DigraphWriter<Digraph> tmp( fn, digraph);926 DigraphWriter<Digraph> digraphWriter(const Digraph& digraph, 927 const std::string& fn) { 928 DigraphWriter<Digraph> tmp(digraph, fn); 929 929 return tmp; 930 930 } … … 935 935 /// \relates DigraphWriter 936 936 template <typename Digraph> 937 DigraphWriter<Digraph> digraphWriter(const char* fn,938 const Digraph& digraph) {939 DigraphWriter<Digraph> tmp( fn, digraph);937 DigraphWriter<Digraph> digraphWriter(const Digraph& digraph, 938 const char* fn) { 939 DigraphWriter<Digraph> tmp(digraph, fn); 940 940 return tmp; 941 941 } … … 945 945 946 946 template <typename Graph> 947 GraphWriter<Graph> graphWriter(std::ostream& os, const Graph& graph); 947 GraphWriter<Graph> graphWriter(const Graph& graph, 948 std::ostream& os = std::cout); 948 949 949 950 template <typename Graph> 950 GraphWriter<Graph> graphWriter(const std::string& fn, const Graph& graph);951 GraphWriter<Graph> graphWriter(const Graph& graph, const std::string& fn); 951 952 952 953 template <typename Graph> 953 GraphWriter<Graph> graphWriter(const char *fn, const Graph& graph);954 GraphWriter<Graph> graphWriter(const Graph& graph, const char *fn); 954 955 955 956 /// \ingroup lemon_io … … 1013 1014 /// Construct a directed graph writer, which writes to the given 1014 1015 /// output stream. 1015 GraphWriter( std::ostream& is, const Graph& graph)1016 : _os(& is), local_os(false), _graph(graph),1016 GraphWriter(const Graph& graph, std::ostream& os = std::cout) 1017 : _os(&os), local_os(false), _graph(graph), 1017 1018 _skip_nodes(false), _skip_edges(false) {} 1018 1019 … … 1021 1022 /// Construct a directed graph writer, which writes to the given 1022 1023 /// output file. 1023 GraphWriter(const std::string& fn, const Graph& graph)1024 GraphWriter(const Graph& graph, const std::string& fn) 1024 1025 : _os(new std::ofstream(fn.c_str())), local_os(true), _graph(graph), 1025 1026 _skip_nodes(false), _skip_edges(false) { … … 1031 1032 /// Construct a directed graph writer, which writes to the given 1032 1033 /// output file. 1033 GraphWriter(const char* fn, const Graph& graph)1034 GraphWriter(const Graph& graph, const char* fn) 1034 1035 : _os(new std::ofstream(fn)), local_os(true), _graph(graph), 1035 1036 _skip_nodes(false), _skip_edges(false) { … … 1061 1062 private: 1062 1063 1063 friend GraphWriter<Graph> graphWriter<>( std::ostream& os,1064 const Graph& graph);1065 friend GraphWriter<Graph> graphWriter<>(const std::string& fn,1066 const Graph& graph);1067 friend GraphWriter<Graph> graphWriter<>(const char *fn,1068 const Graph& graph);1064 friend GraphWriter<Graph> graphWriter<>(const Graph& graph, 1065 std::ostream& os); 1066 friend GraphWriter<Graph> graphWriter<>(const Graph& graph, 1067 const std::string& fn); 1068 friend GraphWriter<Graph> graphWriter<>(const Graph& graph, 1069 const char *fn); 1069 1070 1070 1071 GraphWriter(GraphWriter& other) … … 1519 1520 /// \relates GraphWriter 1520 1521 template <typename Graph> 1521 GraphWriter<Graph> graphWriter(std::ostream& os, const Graph& graph) { 1522 GraphWriter<Graph> tmp(os, graph); 1522 GraphWriter<Graph> graphWriter(const Graph& graph, 1523 std::ostream& os = std::cout) { 1524 GraphWriter<Graph> tmp(graph, os); 1523 1525 return tmp; 1524 1526 } … … 1529 1531 /// \relates GraphWriter 1530 1532 template <typename Graph> 1531 GraphWriter<Graph> graphWriter(const std::string& fn, const Graph& graph) {1532 GraphWriter<Graph> tmp( fn, graph);1533 GraphWriter<Graph> graphWriter(const Graph& graph, const std::string& fn) { 1534 GraphWriter<Graph> tmp(graph, fn); 1533 1535 return tmp; 1534 1536 } … … 1539 1541 /// \relates GraphWriter 1540 1542 template <typename Graph> 1541 GraphWriter<Graph> graphWriter(const char* fn, const Graph& graph) {1542 GraphWriter<Graph> tmp( fn, graph);1543 GraphWriter<Graph> graphWriter(const Graph& graph, const char* fn) { 1544 GraphWriter<Graph> tmp(graph, fn); 1543 1545 return tmp; 1544 1546 } -
test/bfs_test.cc
r286 r293 145 145 146 146 std::istringstream input(test_lgf); 147 digraphReader( input, G).147 digraphReader(G, input). 148 148 node("source", s). 149 149 node("target", t). -
test/dfs_test.cc
r286 r293 147 147 148 148 std::istringstream input(test_lgf); 149 digraphReader( input, G).149 digraphReader(G, input). 150 150 node("source", s). 151 151 node("target", t). -
test/dijkstra_test.cc
r286 r293 143 143 144 144 std::istringstream input(test_lgf); 145 digraphReader( input, G).145 digraphReader(G, input). 146 146 arcMap("length", length). 147 147 node("source", s). -
test/heap_test.cc
r257 r293 168 168 169 169 std::istringstream input(test_lgf); 170 digraphReader( input, digraph).170 digraphReader(digraph, input). 171 171 arcMap("capacity", length). 172 172 node("source", source).
Note: See TracChangeset
for help on using the changeset viewer.