COIN-OR::LEMON - Graph Library

Changeset 1909:2d806130e700 in lemon-0.x for lemon/lemon_writer.h


Ignore:
Timestamp:
01/26/06 16:42:13 (14 years ago)
Author:
Mihaly Barasz
Branch:
default
Phase:
public
Convert:
svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk@2484
Message:

Undir -> U transition

File:
1 edited

Legend:

Unmodified
Added
Removed
  • lemon/lemon_writer.h

    r1901 r1909  
    9292    class ForwardComposeMap {
    9393    public:
    94       typedef typename Graph::UndirEdge Key;
     94      typedef typename Graph::UEdge Key;
    9595      typedef typename Map::Value Value;
    9696
     
    116116    class BackwardComposeMap {
    117117    public:
    118       typedef typename Graph::UndirEdge Key;
     118      typedef typename Graph::UEdge Key;
    119119      typedef typename Map::Value Value;
    120120
     
    709709  ///
    710710  /// The lemon format can store multiple undirected edgesets with several
    711   /// maps. The undirected edgeset section's header line is \c \@undiredgeset
    712   /// \c undiredgeset_name, but the \c undiredgeset_name may be empty.
     711  /// maps. The undirected edgeset section's header line is \c \@uedgeset
     712  /// \c uedgeset_name, but the \c uedgeset_name may be empty.
    713713  ///
    714714  /// The first line of the section contains the names of the maps separated
     
    735735  /// \relates LemonWriter
    736736  template <typename _Graph, typename _Traits = DefaultWriterTraits>
    737   class UndirEdgeSetWriter : public LemonWriter::SectionWriter {
     737  class UEdgeSetWriter : public LemonWriter::SectionWriter {
    738738    typedef LemonWriter::SectionWriter Parent;
    739739  public:
     
    743743    typedef typename Graph::Node Node;
    744744    typedef typename Graph::Edge Edge;
    745     typedef typename Graph::UndirEdge UndirEdge;
     745    typedef typename Graph::UEdge UEdge;
    746746
    747747    /// \brief Constructor.
    748748    ///
    749     /// Constructor for UndirEdgeSetWriter. It creates the UndirEdgeSetWriter
     749    /// Constructor for UEdgeSetWriter. It creates the UEdgeSetWriter
    750750    /// and attach it into the given LemonWriter. It will write node labels by
    751751    /// the \c _nodeLabelWriter. If the \c _forceLabelMap parameter is true
     
    753753    /// "label" named map.
    754754    template <typename NodeLabelWriter>
    755     UndirEdgeSetWriter(LemonWriter& _writer, const Graph& _graph,
     755    UEdgeSetWriter(LemonWriter& _writer, const Graph& _graph,
    756756                       const NodeLabelWriter& _nodeLabelWriter,
    757757                       const std::string& _name = std::string(),
     
    766766    /// \brief Destructor.
    767767    ///
    768     /// Destructor for UndirEdgeSetWriter.
    769     virtual ~UndirEdgeSetWriter() {
     768    /// Destructor for UEdgeSetWriter.
     769    virtual ~UEdgeSetWriter() {
    770770      typename MapWriters::iterator it;
    771771      for (it = writers.begin(); it != writers.end(); ++it) {
     
    775775
    776776  private:
    777     UndirEdgeSetWriter(const UndirEdgeSetWriter&);
    778     void operator=(const UndirEdgeSetWriter&);
     777    UEdgeSetWriter(const UEdgeSetWriter&);
     778    void operator=(const UEdgeSetWriter&);
    779779
    780780  public:
     
    784784    /// Add a new undirected map writer command for the writer.
    785785    template <typename Map>
    786     UndirEdgeSetWriter& writeUndirEdgeMap(std::string name, const Map& map) {
    787       return writeUndirEdgeMap<typename Traits::
     786    UEdgeSetWriter& writeUEdgeMap(std::string name, const Map& map) {
     787      return writeUEdgeMap<typename Traits::
    788788        template Writer<typename Map::Value>, Map>(name, map);
    789789    }
     
    793793    /// Add a new undirected map writer command for the writer.
    794794    template <typename Writer, typename Map>
    795     UndirEdgeSetWriter& writeUndirEdgeMap(std::string name, const Map& map,
     795    UEdgeSetWriter& writeUEdgeMap(std::string name, const Map& map,
    796796                                          const Writer& writer = Writer()) {
    797       checkConcept<concept::ReadMap<UndirEdge, typename Map::Value>, Map>();
     797      checkConcept<concept::ReadMap<UEdge, typename Map::Value>, Map>();
    798798      checkConcept<_writer_bits::ItemWriter<typename Map::Value>, Writer>();
    799799      writers.push_back(
    800800        make_pair(name, new _writer_bits::
    801                   MapWriter<UndirEdge, Map, Writer>(map, writer)));
     801                  MapWriter<UEdge, Map, Writer>(map, writer)));
    802802      return *this;
    803803    }
     
    807807    /// Add a new directed map writer command for the writer.
    808808    template <typename Map>
    809     UndirEdgeSetWriter& writeEdgeMap(std::string name, const Map& map) {
     809    UEdgeSetWriter& writeEdgeMap(std::string name, const Map& map) {
    810810      return writeEdgeMap<typename Traits::
    811811        template Writer<typename Map::Value>, Map>(name, map);
     
    816816    /// Add a new directed map writer command for the writer.
    817817    template <typename Writer, typename Map>
    818     UndirEdgeSetWriter& writeEdgeMap(std::string name, const Map& map,
     818    UEdgeSetWriter& writeEdgeMap(std::string name, const Map& map,
    819819                                     const Writer& writer = Writer()) {
    820820      checkConcept<concept::ReadMap<Edge, typename Map::Value>, Map>();
    821821      checkConcept<_writer_bits::ItemWriter<typename Map::Value>, Writer>();
    822       writeUndirEdge("+" + name,
     822      writeUEdge("+" + name,
    823823                     _writer_bits::forwardComposeMap(graph, map), writer);
    824       writeUndirEdge("-" + name,
     824      writeUEdge("-" + name,
    825825                     _writer_bits::backwardComposeMap(graph, map), writer);
    826826      return *this;
     
    833833    /// It gives back the header of the section.
    834834    virtual std::string header() {
    835       return "@undiredgeset " + name;
     835      return "@uedgeset " + name;
    836836    }
    837837
     
    858858      }
    859859      os << std::endl;
    860       for (typename Graph::UndirEdgeIt it(graph); it != INVALID; ++it) {
     860      for (typename Graph::UEdgeIt it(graph); it != INVALID; ++it) {
    861861        nodeLabelWriter->write(os, graph.source(it));
    862862        os << '\t';
     
    892892    /// undirected edge. Otherwise if the \c forceLabel parameter was true it
    893893    /// will write its id in the graph.
    894     void writeLabel(std::ostream& os, const UndirEdge& item) const {
     894    void writeLabel(std::ostream& os, const UEdge& item) const {
    895895      if (forceLabelMap) {
    896896        os << graph.id(item);
     
    923923
    924924    typedef std::vector<std::pair<std::string, _writer_bits::
    925                                   MapWriterBase<UndirEdge>*> > MapWriters;
     925                                  MapWriterBase<UEdge>*> > MapWriters;
    926926    MapWriters writers;
    927927
    928     _writer_bits::MapWriterBase<UndirEdge>* labelMap;
     928    _writer_bits::MapWriterBase<UEdge>* labelMap;
    929929    bool forceLabelMap;
    930930   
     
    11001100  /// \brief SectionWriter for writing named undirected edges.
    11011101  ///
    1102   /// The undirected edges section's header line is \c \@undiredges
    1103   /// \c undiredges_name, but the \c undiredges_name may be empty.
     1102  /// The undirected edges section's header line is \c \@uedges
     1103  /// \c uedges_name, but the \c uedges_name may be empty.
    11041104  ///
    11051105  /// Each line in the section contains the name of the undirected edge and
     
    11081108  /// \relates LemonWriter
    11091109  template <typename _Graph>
    1110   class UndirEdgeWriter : public LemonWriter::SectionWriter {
     1110  class UEdgeWriter : public LemonWriter::SectionWriter {
    11111111    typedef LemonWriter::SectionWriter Parent;
    11121112    typedef _Graph Graph;
    11131113    typedef typename Graph::Node Node;
    11141114    typedef typename Graph::Edge Edge;
    1115     typedef typename Graph::UndirEdge UndirEdge;
     1115    typedef typename Graph::UEdge UEdge;
    11161116  public:
    11171117   
    11181118    /// \brief Constructor.
    11191119    ///
    1120     /// Constructor for UndirEdgeWriter. It creates the UndirEdgeWriter and
     1120    /// Constructor for UEdgeWriter. It creates the UEdgeWriter and
    11211121    /// attach it into the given LemonWriter. The given \c _LabelWriter
    11221122    /// will write the undirected edges' label what can be an undirected
    11231123    /// edgeset writer.
    11241124    template <typename _LabelWriter>
    1125     UndirEdgeWriter(LemonWriter& _writer, const _LabelWriter& _labelWriter,
     1125    UEdgeWriter(LemonWriter& _writer, const _LabelWriter& _labelWriter,
    11261126               const std::string& _name = std::string())
    11271127      : Parent(_writer), name(_name) {
    11281128      checkConcept<_writer_bits::ItemLabelWriter<Edge>, _LabelWriter>();
    1129       checkConcept<_writer_bits::ItemLabelWriter<UndirEdge>, _LabelWriter>();
    1130       undirEdgeLabelWriter.reset(new _writer_bits::
    1131                               LabelWriter<UndirEdge, _LabelWriter>(_labelWriter));
     1129      checkConcept<_writer_bits::ItemLabelWriter<UEdge>, _LabelWriter>();
     1130      uEdgeLabelWriter.reset(new _writer_bits::
     1131                              LabelWriter<UEdge, _LabelWriter>(_labelWriter));
    11321132      edgeLabelWriter.reset(new _writer_bits::
    11331133                         LabelWriter<Edge, _LabelWriter>(_labelWriter));
     
    11361136    /// \brief Destructor.
    11371137    ///
    1138     /// Destructor for UndirEdgeWriter.
    1139     virtual ~UndirEdgeWriter() {}
    1140   private:
    1141     UndirEdgeWriter(const UndirEdgeWriter&);
    1142     void operator=(const UndirEdgeWriter&);
    1143 
    1144   public:
    1145 
    1146     /// \brief Add an edge writer command for the UndirEdgeWriter.
    1147     ///
    1148     /// Add an edge writer command for the UndirEdgeWriter.
     1138    /// Destructor for UEdgeWriter.
     1139    virtual ~UEdgeWriter() {}
     1140  private:
     1141    UEdgeWriter(const UEdgeWriter&);
     1142    void operator=(const UEdgeWriter&);
     1143
     1144  public:
     1145
     1146    /// \brief Add an edge writer command for the UEdgeWriter.
     1147    ///
     1148    /// Add an edge writer command for the UEdgeWriter.
    11491149    void writeEdge(const std::string& name, const Edge& item) {
    11501150      edgeWriters.push_back(make_pair(name, &item));
    11511151    }
    11521152
    1153     /// \brief Add an undirected edge writer command for the UndirEdgeWriter.
    1154     ///
    1155     /// Add an undirected edge writer command for the UndirEdgeWriter.
    1156     void writeUndirEdge(const std::string& name, const UndirEdge& item) {
    1157       undirEdgeWriters.push_back(make_pair(name, &item));
     1153    /// \brief Add an undirected edge writer command for the UEdgeWriter.
     1154    ///
     1155    /// Add an undirected edge writer command for the UEdgeWriter.
     1156    void writeUEdge(const std::string& name, const UEdge& item) {
     1157      uEdgeWriters.push_back(make_pair(name, &item));
    11581158    }
    11591159
     
    11641164    /// It gives back the header of the section.
    11651165    virtual std::string header() {
    1166       return "@undiredges " + name;
     1166      return "@uedges " + name;
    11671167    }
    11681168
     
    11741174        throw DataFormatError("Cannot find undirected edgeset or label map");
    11751175      }
    1176       if (!undirEdgeLabelWriter->isLabelWriter()) {
     1176      if (!uEdgeLabelWriter->isLabelWriter()) {
    11771177        throw DataFormatError("Cannot find undirected edgeset or label map");
    11781178      }
    1179       for (int i = 0; i < (int)undirEdgeWriters.size(); ++i) {
    1180         os << undirEdgeWriters[i].first << ' ';
    1181         undirEdgeLabelWriter->write(os, *(undirEdgeWriters[i].second));
     1179      for (int i = 0; i < (int)uEdgeWriters.size(); ++i) {
     1180        os << uEdgeWriters[i].first << ' ';
     1181        uEdgeLabelWriter->write(os, *(uEdgeWriters[i].second));
    11821182        os << std::endl;
    11831183      }
     
    11941194
    11951195    typedef std::vector<std::pair<std::string,
    1196                                   const UndirEdge*> > UndirEdgeWriters;
    1197     UndirEdgeWriters undirEdgeWriters;
    1198     std::auto_ptr<_writer_bits::LabelWriterBase<UndirEdge> > undirEdgeLabelWriter;
     1196                                  const UEdge*> > UEdgeWriters;
     1197    UEdgeWriters uEdgeWriters;
     1198    std::auto_ptr<_writer_bits::LabelWriterBase<UEdge> > uEdgeLabelWriter;
    11991199
    12001200    typedef std::vector<std::pair<std::string, const Edge*> > EdgeWriters;
Note: See TracChangeset for help on using the changeset viewer.