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