Changeset 2467:2025a571895e in lemon-0.x for lemon/graph_writer.h
- Timestamp:
- 08/28/07 16:00:42 (17 years ago)
- Branch:
- default
- Phase:
- public
- Convert:
- svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk@3305
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
lemon/graph_writer.h
r2391 r2467 252 252 } 253 253 254 /// \brief Returns true if the writer can give back the labels by the items. 255 /// 256 /// Returns true if the writer can give back the the labels by the items. 257 bool isLabelWriter() const { 258 return nodeset_writer.isLabelWriter() && 259 edgeset_writer.isLabelWriter(); 260 } 261 254 262 /// \brief Write the label of the given node. 255 263 /// 256 /// It writes the label of the given node. If there was written a n"label"264 /// It writes the label of the given node. If there was written a "label" 257 265 /// named node map then it will write the map value belonging to the node. 258 266 void writeLabel(std::ostream& os, const Node& item) const { … … 262 270 /// \brief Write the label of the given edge. 263 271 /// 264 /// It writes the label of the given edge. If there was written a n"label"272 /// It writes the label of the given edge. If there was written a "label" 265 273 /// named edge map then it will write the map value belonging to the edge. 266 274 void writeLabel(std::ostream& os, const Edge& item) const { 267 275 edgeset_writer.writeLabel(os, item); 268 276 } 277 278 /// \brief Sorts the given node vector by label. 279 /// 280 /// Sorts the given node vector by label. If there was written an 281 /// "label" named map then the vector will be sorted by the values 282 /// of this map. Otherwise if the \c forceLabel parameter was true 283 /// it will be sorted by its id in the graph. 284 void sortByLabel(std::vector<Node>& nodes) const { 285 nodeset_writer.sortByLabel(nodes); 286 } 287 288 /// \brief Sorts the given edge vector by label. 289 /// 290 /// Sorts the given edge vector by label. If there was written an 291 /// "label" named map then the vector will be sorted by the values 292 /// of this map. Otherwise if the \c forceLabel parameter was true 293 /// it will be sorted by its id in the graph. 294 void sortByLabel(std::vector<Edge>& edges) const { 295 edgeset_writer.sortByLabel(edges); 296 } 269 297 270 298 private: … … 371 399 : writer(new LemonWriter(_os)), own_writer(true), 372 400 nodeset_writer(*writer, _graph, std::string()), 373 u _edgeset_writer(*writer, _graph, nodeset_writer, std::string()),401 uedgeset_writer(*writer, _graph, nodeset_writer, std::string()), 374 402 node_writer(*writer, nodeset_writer, std::string()), 375 u _edge_writer(*writer, u_edgeset_writer, std::string()),403 uedge_writer(*writer, uedgeset_writer, std::string()), 376 404 attribute_writer(*writer, std::string()) {} 377 405 … … 383 411 : writer(new LemonWriter(_filename)), own_writer(true), 384 412 nodeset_writer(*writer, _graph, std::string()), 385 u _edgeset_writer(*writer, _graph, nodeset_writer, std::string()),413 uedgeset_writer(*writer, _graph, nodeset_writer, std::string()), 386 414 node_writer(*writer, nodeset_writer, std::string()), 387 u _edge_writer(*writer, u_edgeset_writer, std::string()),415 uedge_writer(*writer, uedgeset_writer, std::string()), 388 416 attribute_writer(*writer, std::string()) {} 389 417 … … 391 419 /// 392 420 /// Construct a new UGraphWriter. It writes the given graph 393 /// to given Lemon Reader.421 /// to given LemonWriter. 394 422 UGraphWriter(LemonWriter& _writer, const Graph& _graph) 395 423 : writer(_writer), own_writer(false), 396 424 nodeset_writer(*writer, _graph, std::string()), 397 u _edgeset_writer(*writer, _graph, nodeset_writer, std::string()),425 uedgeset_writer(*writer, _graph, nodeset_writer, std::string()), 398 426 node_writer(*writer, nodeset_writer, std::string()), 399 u _edge_writer(*writer, u_edgeset_writer, std::string()),427 uedge_writer(*writer, uedgeset_writer, std::string()), 400 428 attribute_writer(*writer, std::string()) {} 401 429 … … 435 463 template <typename Map> 436 464 UGraphWriter& writeEdgeMap(std::string label, const Map& map) { 437 u _edgeset_writer.writeEdgeMap(label, map);465 uedgeset_writer.writeEdgeMap(label, map); 438 466 return *this; 439 467 } … … 446 474 UGraphWriter& writeEdgeMap(std::string label, const Map& map, 447 475 const ItemWriter& iw = ItemWriter()) { 448 u _edgeset_writer.writeEdgeMap(label, map, iw);476 uedgeset_writer.writeEdgeMap(label, map, iw); 449 477 return *this; 450 478 } … … 456 484 template <typename Map> 457 485 UGraphWriter& writeUEdgeMap(std::string label, const Map& map) { 458 u _edgeset_writer.writeUEdgeMap(label, map);486 uedgeset_writer.writeUEdgeMap(label, map); 459 487 return *this; 460 488 } … … 467 495 UGraphWriter& writeUEdgeMap(std::string label, const Map& map, 468 496 const ItemWriter& iw = ItemWriter()) { 469 u _edgeset_writer.writeUEdgeMap(label, map, iw);497 uedgeset_writer.writeUEdgeMap(label, map, iw); 470 498 return *this; 471 499 } … … 485 513 /// command</i> to the writer. 486 514 UGraphWriter& writeEdge(std::string label, const Edge& edge) { 487 u _edge_writer.writeEdge(label, edge);515 uedge_writer.writeEdge(label, edge); 488 516 } 489 517 … … 494 522 /// the writer. 495 523 UGraphWriter& writeUEdge(std::string label, const UEdge& edge) { 496 u _edge_writer.writeUEdge(label, edge);524 uedge_writer.writeUEdge(label, edge); 497 525 } 498 526 … … 535 563 } 536 564 565 /// \brief Returns true if the writer can give back the labels by the items. 566 /// 567 /// Returns true if the writer can give back the the labels by the items. 568 bool isLabelWriter() const { 569 return nodeset_writer.isLabelWriter() && 570 uedgeset_writer.isLabelWriter(); 571 } 572 537 573 /// \brief Write the label of the given node. 538 574 /// 539 /// It writes the label of the given node. If there was written a n"label"575 /// It writes the label of the given node. If there was written a "label" 540 576 /// named node map then it will write the map value belonging to the node. 541 577 void writeLabel(std::ostream& os, const Node& item) const { … … 545 581 /// \brief Write the label of the given edge. 546 582 /// 547 /// It writes the label of the given edge. If there was written a n"label"583 /// It writes the label of the given edge. If there was written a "label" 548 584 /// named edge map then it will write the map value belonging to the edge. 549 585 void writeLabel(std::ostream& os, const Edge& item) const { 550 u _edgeset_writer.writeLabel(os, item);586 uedgeset_writer.writeLabel(os, item); 551 587 } 552 588 … … 554 590 /// 555 591 /// It writes the label of the given undirected edge. If there was 556 /// written a n"label" named edge map then it will write the map592 /// written a "label" named edge map then it will write the map 557 593 /// value belonging to the edge. 558 594 void writeLabel(std::ostream& os, const UEdge& item) const { 559 u _edgeset_writer.writeLabel(os, item);595 uedgeset_writer.writeLabel(os, item); 560 596 } 561 597 598 /// \brief Sorts the given node vector by label. 599 /// 600 /// Sorts the given node vector by label. If there was written an 601 /// "label" named map then the vector will be sorted by the values 602 /// of this map. Otherwise if the \c forceLabel parameter was true 603 /// it will be sorted by its id in the graph. 604 void sortByLabel(std::vector<Node>& nodes) const { 605 nodeset_writer.sortByLabel(nodes); 606 } 607 608 /// \brief Sorts the given edge vector by label. 609 /// 610 /// Sorts the given edge vector by label. If there was written an 611 /// "label" named map then the vector will be sorted by the values 612 /// of this map. Otherwise if the \c forceLabel parameter was true 613 /// it will be sorted by its id in the graph. 614 void sortByLabel(std::vector<Edge>& edges) const { 615 uedgeset_writer.sortByLabel(edges); 616 } 617 618 /// \brief Sorts the given undirected edge vector by label. 619 /// 620 /// Sorts the given undirected edge vector by label. If there was 621 /// written an "label" named map then the vector will be sorted by 622 /// the values of this map. Otherwise if the \c forceLabel 623 /// parameter was true it will be sorted by its id in the graph. 624 void sortByLabel(std::vector<UEdge>& uedges) const { 625 uedgeset_writer.sortByLabel(uedges); 626 } 562 627 563 628 private: … … 567 632 568 633 NodeSetWriter<Graph, WriterTraits> nodeset_writer; 569 UEdgeSetWriter<Graph, WriterTraits> u _edgeset_writer;634 UEdgeSetWriter<Graph, WriterTraits> uedgeset_writer; 570 635 571 636 NodeWriter<Graph> node_writer; 572 UEdgeWriter<Graph> u _edge_writer;637 UEdgeWriter<Graph> uedge_writer; 573 638 574 639 AttributeWriter<WriterTraits> attribute_writer;
Note: See TracChangeset
for help on using the changeset viewer.