Changeset 1394:f0c48d7fa73d in lemon-0.x for src/lemon
- Timestamp:
- 04/27/05 12:44:58 (20 years ago)
- Branch:
- default
- Phase:
- public
- Convert:
- svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk@1851
- Location:
- src/lemon
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
src/lemon/graph_reader.h
r1359 r1394 201 201 /// \endcode 202 202 /// 203 /// The \c addNodeMap() function reads a map from the \c \@nodeset section.203 /// The \c readNodeMap() function reads a map from the \c \@nodeset section. 204 204 /// If there is a map that you do not want to read from the file and there is 205 205 /// whitespace in the string represenation of the values then you should … … 208 208 /// 209 209 /// \code 210 /// reader. addNodeMap("x-coord", xCoordMap);211 /// reader. addNodeMap("y-coord", yCoordMap);212 /// 213 /// reader. addNodeMap<QuotedStringReader>("label", labelMap);210 /// reader.readNodeMap("x-coord", xCoordMap); 211 /// reader.readNodeMap("y-coord", yCoordMap); 212 /// 213 /// reader.readNodeMap<QuotedStringReader>("label", labelMap); 214 214 /// reader.skipNodeMap<QuotedStringReader>("description"); 215 215 /// 216 /// reader. addNodeMap("color", colorMap);216 /// reader.readNodeMap("color", colorMap); 217 217 /// \endcode 218 218 /// 219 /// With the \c addEdgeMap() member function you can give an edge map219 /// With the \c readEdgeMap() member function you can give an edge map 220 220 /// reading command similar to the NodeMaps. 221 221 /// 222 222 /// \code 223 /// reader. addEdgeMap("weight", weightMap);224 /// reader. addEdgeMap("label", labelMap);223 /// reader.readEdgeMap("weight", weightMap); 224 /// reader.readEdgeMap("label", labelMap); 225 225 /// \endcode 226 226 /// 227 /// With \c addNode() and \c addEdge() functions you can read labeled Nodes227 /// With \c readNode() and \c readEdge() functions you can read labeled Nodes 228 228 /// and Edges. 229 229 /// 230 230 /// \code 231 /// reader. addNode("source", sourceNode);232 /// reader. addNode("target", targetNode);233 /// 234 /// reader. addEdge("observed", edge);231 /// reader.readNode("source", sourceNode); 232 /// reader.readNode("target", targetNode); 233 /// 234 /// reader.readEdge("observed", edge); 235 235 /// \endcode 236 236 /// … … 286 286 /// Add a new node map reader command for the reader. 287 287 template <typename Map> 288 GraphReader& addNodeMap(std::string name, Map& map) {289 return addNodeMap<typename ReaderTraits::template288 GraphReader& readNodeMap(std::string name, Map& map) { 289 return readNodeMap<typename ReaderTraits::template 290 290 Reader<typename Map::Value>, Map>(name, map); 291 291 } … … 295 295 /// Add a new node map reader command for the reader. 296 296 template <typename Reader, typename Map> 297 GraphReader& addNodeMap(std::string name, Map& map,297 GraphReader& readNodeMap(std::string name, Map& map, 298 298 const Reader& reader = Reader()) { 299 299 if (node_map_readers.find(name) != node_map_readers.end()) { … … 327 327 /// Add a new edge map reader command for the reader. 328 328 template <typename Map> 329 GraphReader& addEdgeMap(std::string name, Map& map) {330 return addEdgeMap<typename ReaderTraits::template329 GraphReader& readEdgeMap(std::string name, Map& map) { 330 return readEdgeMap<typename ReaderTraits::template 331 331 Reader<typename Map::Value>, Map>(name, map); 332 332 } … … 337 337 /// Add a new edge map reader command for the reader. 338 338 template <typename Reader, typename Map> 339 GraphReader& addEdgeMap(std::string name, Map& map,339 GraphReader& readEdgeMap(std::string name, Map& map, 340 340 const Reader& reader = Reader()) { 341 341 if (edge_map_readers.find(name) != edge_map_readers.end()) { … … 368 368 /// 369 369 /// Add a new labeled node reader for the reader. 370 GraphReader& addNode(std::string name, Node& node) {370 GraphReader& readNode(std::string name, Node& node) { 371 371 if (node_readers.find(name) != node_readers.end()) { 372 372 ErrorMessage msg; … … 381 381 /// 382 382 /// Add a new labeled edge reader for the reader. 383 GraphReader& addEdge(std::string name, Edge& edge) {383 GraphReader& readEdge(std::string name, Edge& edge) { 384 384 if (edge_readers.find(name) != edge_readers.end()) { 385 385 ErrorMessage msg; … … 755 755 CostMap& cost) { 756 756 GraphReader<Graph> reader(is, g); 757 reader. addEdgeMap("capacity", capacity);758 reader. addEdgeMap("cost", cost);759 reader. addNode("source", s);760 reader. addNode("target", t);757 reader.readEdgeMap("capacity", capacity); 758 reader.readEdgeMap("cost", cost); 759 reader.readNode("source", s); 760 reader.readNode("target", t); 761 761 reader.run(); 762 762 } … … 774 774 typename Graph::Node &s, typename Graph::Node &t) { 775 775 GraphReader<Graph> reader(is, g); 776 reader. addEdgeMap("capacity", capacity);777 reader. addNode("source", s);778 reader. addNode("target", t);776 reader.readEdgeMap("capacity", capacity); 777 reader.readNode("source", s); 778 reader.readNode("target", t); 779 779 reader.run(); 780 780 } … … 791 791 typename Graph::Node &s) { 792 792 GraphReader<Graph> reader(is, g); 793 reader. addEdgeMap("capacity", capacity);794 reader. addNode("source", s);793 reader.readEdgeMap("capacity", capacity); 794 reader.readNode("source", s); 795 795 reader.run(); 796 796 } … … 805 805 void readGraph(std::istream& is, Graph &g, CapacityMap& capacity) { 806 806 GraphReader<Graph> reader(is, g); 807 reader. addEdgeMap("capacity", capacity);807 reader.readEdgeMap("capacity", capacity); 808 808 reader.run(); 809 809 } -
src/lemon/graph_writer.h
r1359 r1394 169 169 /// \endcode 170 170 /// 171 /// The \c addNodeMap() function declares a \c NodeMap writing command in the 172 /// \c GraphWriter. You should give as parameter the name of the map and the 173 /// map object. The NodeMap writing command with name "id" should write a 174 /// unique map because it is regarded as ID map. 171 /// The \c writeNodeMap() function declares a \c NodeMap writing 172 /// command in the \c GraphWriter. You should give as parameter 173 /// the name of the map and the map object. The NodeMap writing 174 /// command with name "id" should write a unique map because it 175 /// is regarded as ID map. 175 176 /// 176 177 /// \code 177 178 /// IdMap<ListGraph, Node> nodeIdMap; 178 /// writer. addNodeMap("id", nodeIdMap);179 /// 180 /// writer. addNodeMap("x-coord", xCoordMap);181 /// writer. addNodeMap("y-coord", yCoordMap);182 /// writer. addNodeMap("color", colorMap);179 /// writer.writeNodeMap("id", nodeIdMap); 180 /// 181 /// writer.writeNodeMap("x-coord", xCoordMap); 182 /// writer.writeNodeMap("y-coord", yCoordMap); 183 /// writer.writeNodeMap("color", colorMap); 183 184 /// \endcode 184 185 /// 185 /// With the \c addEdgeMap() member function you can give an edge map186 /// With the \c writeEdgeMap() member function you can give an edge map 186 187 /// writing command similar to the NodeMaps. 187 188 /// … … 189 190 /// DescriptorMap<ListGraph, Edge, ListGraph::EdgeMap<int> > 190 191 /// edgeDescMap(graph); 191 /// writer. addEdgeMap("descriptor", edgeDescMap);192 /// 193 /// writer. addEdgeMap("weight", weightMap);194 /// writer. addEdgeMap("label", labelMap);192 /// writer.writeEdgeMap("descriptor", edgeDescMap); 193 /// 194 /// writer.writeEdgeMap("weight", weightMap); 195 /// writer.writeEdgeMap("label", labelMap); 195 196 /// \endcode 196 197 /// 197 /// With \c addNode() and \c addEdge() functions you can point out Nodes and198 /// Edges in the graph. By example, you can write out the source and target199 /// of the graph.198 /// With \c writeNode() and \c writeEdge() functions you can 199 /// point out Nodes and Edges in the graph. By example, you can 200 /// write out the source and target of the graph. 200 201 /// 201 202 /// \code 202 /// writer. addNode("source", sourceNode);203 /// writer. addNode("target", targetNode);204 /// 205 /// writer. addEdge("observed", edge);203 /// writer.writeNode("source", sourceNode); 204 /// writer.writeNode("target", targetNode); 205 /// 206 /// writer.writeEdge("observed", edge); 206 207 /// \endcode 207 208 /// … … 217 218 /// \see IdMap 218 219 /// \see DescriptorMap 219 /// \see \ref Graph Reader220 /// \see \ref GraphWriter 220 221 /// \see \ref graph-io-page 221 222 /// \author Balazs Dezso … … 263 264 /// Add a new node map writer command for the writer. 264 265 template <typename Map> 265 GraphWriter& addNodeMap(std::string name, const Map& map) {266 return addNodeMap<typename WriterTraits::template Writer<266 GraphWriter& writeNodeMap(std::string name, const Map& map) { 267 return writeNodeMap<typename WriterTraits::template Writer< 267 268 typename Map::Value>, Map>(name, map); 268 269 } … … 272 273 /// Add a new node map writer command for the writer. 273 274 template <typename Writer, typename Map> 274 GraphWriter& addNodeMap(std::string name, const Map& map,275 GraphWriter& writeNodeMap(std::string name, const Map& map, 275 276 const Writer& writer = Writer()) { 276 277 node_map_writers.push_back( … … 285 286 /// Add a new edge map writer command for the writer. 286 287 template <typename Map> 287 GraphWriter& addEdgeMap(std::string name, const Map& map) {288 return addEdgeMap<typename WriterTraits::template Writer<288 GraphWriter& writeEdgeMap(std::string name, const Map& map) { 289 return writeEdgeMap<typename WriterTraits::template Writer< 289 290 typename Map::Value>, Map>(name, map); 290 291 } … … 295 296 /// Add a new edge map writer command for the writer. 296 297 template <typename Writer, typename Map> 297 GraphWriter& addEdgeMap(std::string name,298 GraphWriter& writeEdgeMap(std::string name, 298 299 const Map& map, const Writer& writer = Writer()) { 299 300 edge_map_writers.push_back(make_pair(name, … … 305 306 /// 306 307 /// Add a new labeled node writer for the writer. 307 GraphWriter& addNode(std::string name, const Node& node) {308 GraphWriter& writeNode(std::string name, const Node& node) { 308 309 node_writers.push_back(make_pair(name, node)); 309 310 return *this; … … 313 314 /// 314 315 /// Add a new labeled edge writer for the writer. 315 GraphWriter& addEdge(std::string name, const Edge& edge) {316 GraphWriter& writeEdge(std::string name, const Edge& edge) { 316 317 edge_writers.push_back(make_pair(name, edge)); 317 318 return *this; … … 468 469 const CapacityMap& capacity, const typename Graph::Node &s, 469 470 const typename Graph::Node &t, const CostMap& cost) { 470 GraphWriter<Graph> reader(os, g);471 GraphWriter<Graph> writer(os, g); 471 472 IdMap<Graph, typename Graph::Node> nodeIdMap(g); 472 reader.addNodeMap("id", nodeIdMap);473 writer.writeNodeMap("id", nodeIdMap); 473 474 IdMap<Graph, typename Graph::Edge> edgeIdMap(g); 474 reader.addEdgeMap("id", edgeIdMap);475 reader.addEdgeMap("capacity", capacity);476 reader.addEdgeMap("cost", cost);477 reader.addNode("source", s);478 reader.addNode("target", t);479 reader.run();475 writer.writeEdgeMap("id", edgeIdMap); 476 writer.writeEdgeMap("capacity", capacity); 477 writer.writeEdgeMap("cost", cost); 478 writer.writeNode("source", s); 479 writer.writeNode("target", t); 480 writer.run(); 480 481 } 481 482 … … 492 493 const CapacityMap& capacity, const typename Graph::Node &s, 493 494 const typename Graph::Node &t) { 494 GraphWriter<Graph> reader(os, g);495 GraphWriter<Graph> writer(os, g); 495 496 IdMap<Graph, typename Graph::Node> nodeIdMap(g); 496 reader.addNodeMap("id", nodeIdMap);497 writer.writeNodeMap("id", nodeIdMap); 497 498 IdMap<Graph, typename Graph::Edge> edgeIdMap(g); 498 reader.addEdgeMap("id", edgeIdMap);499 reader.addEdgeMap("capacity", capacity);500 reader.addNode("source", s);501 reader.addNode("target", t);502 reader.run();499 writer.writeEdgeMap("id", edgeIdMap); 500 writer.writeEdgeMap("capacity", capacity); 501 writer.writeNode("source", s); 502 writer.writeNode("target", t); 503 writer.run(); 503 504 } 504 505 … … 513 514 void writeGraph(std::ostream& os, const Graph &g, 514 515 const CapacityMap& capacity, const typename Graph::Node &s) { 515 GraphWriter<Graph> reader(os, g);516 GraphWriter<Graph> writer(os, g); 516 517 IdMap<Graph, typename Graph::Node> nodeIdMap(g); 517 reader.addNodeMap("id", nodeIdMap);518 writer.writeNodeMap("id", nodeIdMap); 518 519 IdMap<Graph, typename Graph::Edge> edgeIdMap(g); 519 reader.addEdgeMap("id", edgeIdMap);520 reader.addEdgeMap("capacity", capacity);521 reader.addNode("source", s);522 reader.run();520 writer.writeEdgeMap("id", edgeIdMap); 521 writer.writeEdgeMap("capacity", capacity); 522 writer.writeNode("source", s); 523 writer.run(); 523 524 } 524 525 … … 532 533 void writeGraph(std::ostream& os, const Graph &g, 533 534 const CapacityMap& capacity) { 534 GraphWriter<Graph> reader(os, g);535 GraphWriter<Graph> writer(os, g); 535 536 IdMap<Graph, typename Graph::Node> nodeIdMap(g); 536 reader.addNodeMap("id", nodeIdMap);537 writer.writeNodeMap("id", nodeIdMap); 537 538 IdMap<Graph, typename Graph::Edge> edgeIdMap(g); 538 reader.addEdgeMap("id", edgeIdMap);539 reader.addEdgeMap("capacity", capacity);540 reader.run();539 writer.writeEdgeMap("id", edgeIdMap); 540 writer.writeEdgeMap("capacity", capacity); 541 writer.run(); 541 542 } 542 543 … … 548 549 template<typename Graph> 549 550 void writeGraph(std::ostream& os, const Graph &g) { 550 GraphWriter<Graph> reader(os, g);551 GraphWriter<Graph> writer(os, g); 551 552 IdMap<Graph, typename Graph::Node> nodeIdMap(g); 552 reader.addNodeMap("id", nodeIdMap);553 writer.writeNodeMap("id", nodeIdMap); 553 554 IdMap<Graph, typename Graph::Edge> edgeIdMap(g); 554 reader.addEdgeMap("id", edgeIdMap);555 reader.run();555 writer.writeEdgeMap("id", edgeIdMap); 556 writer.run(); 556 557 } 557 558
Note: See TracChangeset
for help on using the changeset viewer.