COIN-OR::LEMON - Graph Library

Changeset 2467:2025a571895e in lemon-0.x for lemon/graph_writer.h


Ignore:
Timestamp:
08/28/07 16:00:42 (17 years ago)
Author:
Balazs Dezso
Branch:
default
Phase:
public
Convert:
svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk@3305
Message:

PathNodeIt?

PathWriter/Reader? structures
Distinict MapSet? readers and writers

File:
1 edited

Legend:

Unmodified
Added
Removed
  • lemon/graph_writer.h

    r2391 r2467  
    252252    }
    253253
     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
    254262    /// \brief Write the label of the given node.
    255263    ///
    256     /// It writes the label of the given node. If there was written an "label"
     264    /// It writes the label of the given node. If there was written a "label"
    257265    /// named node map then it will write the map value belonging to the node.
    258266    void writeLabel(std::ostream& os, const Node& item) const {
     
    262270    /// \brief Write the label of the given edge.
    263271    ///
    264     /// It writes the label of the given edge. If there was written an "label"
     272    /// It writes the label of the given edge. If there was written a "label"
    265273    /// named edge map then it will write the map value belonging to the edge.
    266274    void writeLabel(std::ostream& os, const Edge& item) const {
    267275      edgeset_writer.writeLabel(os, item);
    268276    }
     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    }
    269297
    270298  private:
     
    371399      : writer(new LemonWriter(_os)), own_writer(true),
    372400        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()),
    374402        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()),
    376404        attribute_writer(*writer, std::string()) {}
    377405
     
    383411      : writer(new LemonWriter(_filename)), own_writer(true),
    384412        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()),
    386414        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()),
    388416        attribute_writer(*writer, std::string()) {}
    389417
     
    391419    ///
    392420    /// Construct a new UGraphWriter. It writes the given graph
    393     /// to given LemonReader.
     421    /// to given LemonWriter.
    394422    UGraphWriter(LemonWriter& _writer, const Graph& _graph)
    395423      : writer(_writer), own_writer(false),
    396424        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()),
    398426        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()),
    400428        attribute_writer(*writer, std::string()) {}
    401429
     
    435463    template <typename Map>
    436464    UGraphWriter& writeEdgeMap(std::string label, const Map& map) {
    437       u_edgeset_writer.writeEdgeMap(label, map);
     465      uedgeset_writer.writeEdgeMap(label, map);
    438466      return *this;
    439467    }
     
    446474    UGraphWriter& writeEdgeMap(std::string label, const Map& map,
    447475                                   const ItemWriter& iw = ItemWriter()) {
    448       u_edgeset_writer.writeEdgeMap(label, map, iw);
     476      uedgeset_writer.writeEdgeMap(label, map, iw);
    449477      return *this;
    450478    }
     
    456484    template <typename Map>
    457485    UGraphWriter& writeUEdgeMap(std::string label, const Map& map) {
    458       u_edgeset_writer.writeUEdgeMap(label, map);
     486      uedgeset_writer.writeUEdgeMap(label, map);
    459487      return *this;
    460488    }
     
    467495    UGraphWriter& writeUEdgeMap(std::string label, const Map& map,
    468496                                        const ItemWriter& iw = ItemWriter()) {
    469       u_edgeset_writer.writeUEdgeMap(label, map, iw);
     497      uedgeset_writer.writeUEdgeMap(label, map, iw);
    470498      return *this;
    471499    }
     
    485513    /// command</i> to the writer.
    486514    UGraphWriter& writeEdge(std::string label, const Edge& edge) {
    487       u_edge_writer.writeEdge(label, edge);
     515      uedge_writer.writeEdge(label, edge);
    488516    }
    489517
     
    494522    /// the writer.
    495523    UGraphWriter& writeUEdge(std::string label, const UEdge& edge) {
    496       u_edge_writer.writeUEdge(label, edge);
     524      uedge_writer.writeUEdge(label, edge);
    497525    }
    498526
     
    535563    }
    536564
     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
    537573    /// \brief Write the label of the given node.
    538574    ///
    539     /// It writes the label of the given node. If there was written an "label"
     575    /// It writes the label of the given node. If there was written a "label"
    540576    /// named node map then it will write the map value belonging to the node.
    541577    void writeLabel(std::ostream& os, const Node& item) const {
     
    545581    /// \brief Write the label of the given edge.
    546582    ///
    547     /// It writes the label of the given edge. If there was written an "label"
     583    /// It writes the label of the given edge. If there was written a "label"
    548584    /// named edge map then it will write the map value belonging to the edge.
    549585    void writeLabel(std::ostream& os, const Edge& item) const {
    550       u_edgeset_writer.writeLabel(os, item);
     586      uedgeset_writer.writeLabel(os, item);
    551587    }
    552588
     
    554590    ///
    555591    /// It writes the label of the given undirected edge. If there was
    556     /// written an "label" named edge map then it will write the map
     592    /// written a "label" named edge map then it will write the map
    557593    /// value belonging to the edge.
    558594    void writeLabel(std::ostream& os, const UEdge& item) const {
    559       u_edgeset_writer.writeLabel(os, item);
     595      uedgeset_writer.writeLabel(os, item);
    560596    }
    561597
     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    }
    562627
    563628  private:
     
    567632
    568633    NodeSetWriter<Graph, WriterTraits> nodeset_writer;
    569     UEdgeSetWriter<Graph, WriterTraits> u_edgeset_writer;
     634    UEdgeSetWriter<Graph, WriterTraits> uedgeset_writer;
    570635
    571636    NodeWriter<Graph> node_writer;
    572     UEdgeWriter<Graph> u_edge_writer;
     637    UEdgeWriter<Graph> uedge_writer;
    573638   
    574639    AttributeWriter<WriterTraits> attribute_writer;
Note: See TracChangeset for help on using the changeset viewer.