COIN-OR::LEMON - Graph Library

Changeset 1909:2d806130e700 in lemon-0.x for lemon/graph_reader.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/graph_reader.h

    r1901 r1909  
    379379  /// \brief The undirected graph reader class.
    380380  ///
    381   /// The \c UndirGraphReader class provides the graph input.
     381  /// The \c UGraphReader class provides the graph input.
    382382  /// Before you read this documentation it might be useful to read the general
    383383  /// description of  \ref graph-io-page "Graph Input-Output".
     
    391391  ///
    392392  /// If you read a graph you need not read all the maps and items just those
    393   /// that you need. The interface of the \c UndirGraphReader is very similar
    394   /// to the UndirGraphWriter but the reading method does not depend on the
     393  /// that you need. The interface of the \c UGraphReader is very similar
     394  /// to the UGraphWriter but the reading method does not depend on the
    395395  /// order of the given commands.
    396396  ///
     
    400400  ///
    401401  /// \code
    402   /// UndirGraphReader<UndirListGraph> reader(std::cin, graph);
     402  /// UGraphReader<ListUGraph> reader(std::cin, graph);
    403403  /// \endcode
    404404  ///
     
    417417  /// \endcode
    418418  ///
    419   /// With the \c readUndirEdgeMap() member function you can give an
    420   /// undir edge map reading command similar to the NodeMaps.
    421   ///
    422   /// \code
    423   /// reader.readUndirEdgeMap("capacity", capacityMap);
     419  /// With the \c readUEdgeMap() member function you can give an
     420  /// uedge map reading command similar to the NodeMaps.
     421  ///
     422  /// \code
     423  /// reader.readUEdgeMap("capacity", capacityMap);
    424424  /// \endcode
    425425  ///
     
    433433  /// \endcode
    434434  ///
    435   /// With \c readNode() and \c readUndirEdge() functions you can read
    436   /// labeled Nodes and UndirEdges.
     435  /// With \c readNode() and \c readUEdge() functions you can read
     436  /// labeled Nodes and UEdges.
    437437  ///
    438438  /// \code
     
    440440  /// reader.readNode("target", targetNode);
    441441  ///
    442   /// reader.readUndirEdge("observed", undirEdge);
     442  /// reader.readUEdge("observed", uEdge);
    443443  /// \endcode
    444444  ///
     
    456456  /// \see GraphReader
    457457  /// \see DefaultReaderTraits
    458   /// \see \ref UndirGraphWriter
     458  /// \see \ref UGraphWriter
    459459  /// \see \ref graph-io-page
    460460  ///
    461461  /// \author Balazs Dezso
    462462  template <typename _Graph, typename _ReaderTraits = DefaultReaderTraits>
    463   class UndirGraphReader {
     463  class UGraphReader {
    464464  public:
    465465   
     
    467467    typedef typename Graph::Node Node;
    468468    typedef typename Graph::Edge Edge;
    469     typedef typename Graph::UndirEdge UndirEdge;
     469    typedef typename Graph::UEdge UEdge;
    470470
    471471    typedef _ReaderTraits ReaderTraits;
    472472    typedef typename ReaderTraits::Skipper DefaultSkipper;
    473473
    474     /// \brief Construct a new UndirGraphReader.
    475     ///
    476     /// Construct a new UndirGraphReader. It reads into the given graph
     474    /// \brief Construct a new UGraphReader.
     475    ///
     476    /// Construct a new UGraphReader. It reads into the given graph
    477477    /// and it use the given reader as the default skipper.
    478     UndirGraphReader(std::istream& _is, Graph& _graph,
     478    UGraphReader(std::istream& _is, Graph& _graph,
    479479                     const DefaultSkipper& _skipper = DefaultSkipper())
    480480      : reader(new LemonReader(_is)), own_reader(true), skipper(_skipper),
    481481        nodeset_reader(*reader, _graph, std::string(), skipper),
    482         undir_edgeset_reader(*reader, _graph, nodeset_reader,
     482        u_edgeset_reader(*reader, _graph, nodeset_reader,
    483483                             std::string(), skipper),
    484484        node_reader(*reader, nodeset_reader, std::string()),
    485         undir_edge_reader(*reader, undir_edgeset_reader, std::string()),
     485        u_edge_reader(*reader, u_edgeset_reader, std::string()),
    486486        attribute_reader(*reader, std::string()) {}
    487487
    488     /// \brief Construct a new UndirGraphReader.
    489     ///
    490     /// Construct a new UndirGraphReader. It reads into the given graph
     488    /// \brief Construct a new UGraphReader.
     489    ///
     490    /// Construct a new UGraphReader. It reads into the given graph
    491491    /// and it use the given reader as the default skipper.
    492     UndirGraphReader(const std::string& _filename, Graph& _graph,
     492    UGraphReader(const std::string& _filename, Graph& _graph,
    493493                     const DefaultSkipper& _skipper = DefaultSkipper())
    494494      : reader(new LemonReader(_filename)), own_reader(true),
    495495        skipper(_skipper),
    496496        nodeset_reader(*reader, _graph, std::string(), skipper),
    497         undir_edgeset_reader(*reader, _graph, nodeset_reader,
     497        u_edgeset_reader(*reader, _graph, nodeset_reader,
    498498                             std::string(), skipper),
    499499        node_reader(*reader, nodeset_reader, std::string()),
    500         undir_edge_reader(*reader, undir_edgeset_reader, std::string()),
     500        u_edge_reader(*reader, u_edgeset_reader, std::string()),
    501501        attribute_reader(*reader, std::string()) {}
    502502
    503     /// \brief Construct a new UndirGraphReader.
    504     ///
    505     /// Construct a new UndirGraphReader. It reads into the given graph
     503    /// \brief Construct a new UGraphReader.
     504    ///
     505    /// Construct a new UGraphReader. It reads into the given graph
    506506    /// and it use the given reader as the default skipper.
    507     UndirGraphReader(LemonReader& _reader, Graph& _graph,
     507    UGraphReader(LemonReader& _reader, Graph& _graph,
    508508                     const DefaultSkipper& _skipper = DefaultSkipper())
    509509      : reader(_reader), own_reader(false), skipper(_skipper),
    510510        nodeset_reader(*reader, _graph, std::string(), skipper),
    511         undir_edgeset_reader(*reader, _graph, nodeset_reader,
     511        u_edgeset_reader(*reader, _graph, nodeset_reader,
    512512                             std::string(), skipper),
    513513        node_reader(*reader, nodeset_reader, std::string()),
    514         undir_edge_reader(*reader, undir_edgeset_reader, std::string()),
     514        u_edge_reader(*reader, u_edgeset_reader, std::string()),
    515515        attribute_reader(*reader, std::string()) {}
    516516
     
    518518    ///
    519519    /// Destruct the graph reader.
    520     ~UndirGraphReader() {
     520    ~UGraphReader() {
    521521      if (own_reader)
    522522        delete reader;
     
    527527    /// Give a new node map reading command to the reader.
    528528    template <typename Map>
    529     UndirGraphReader& readNodeMap(std::string name, Map& map) {
     529    UGraphReader& readNodeMap(std::string name, Map& map) {
    530530      nodeset_reader.readNodeMap(name, map);
    531531      return *this;
     
    533533
    534534    template <typename Map>
    535     UndirGraphReader& readNodeMap(std::string name, const Map& map) {
     535    UGraphReader& readNodeMap(std::string name, const Map& map) {
    536536      nodeset_reader.readNodeMap(name, map);
    537537      return *this;
     
    542542    /// Give a new node map reading command to the reader.
    543543    template <typename Reader, typename Map>
    544     UndirGraphReader& readNodeMap(std::string name, Map& map,
     544    UGraphReader& readNodeMap(std::string name, Map& map,
    545545                                  const Reader& reader = Reader()) {
    546546      nodeset_reader.readNodeMap(name, map, reader);
     
    549549
    550550    template <typename Reader, typename Map>
    551     UndirGraphReader& readNodeMap(std::string name, const Map& map,
     551    UGraphReader& readNodeMap(std::string name, const Map& map,
    552552                                  const Reader& reader = Reader()) {
    553553      nodeset_reader.readNodeMap(name, map, reader);
     
    559559    /// Give a new node map skipping command to the reader.
    560560    template <typename Reader>
    561     UndirGraphReader& skipNodeMap(std::string name,
     561    UGraphReader& skipNodeMap(std::string name,
    562562                             const Reader& reader = Reader()) {
    563563      nodeset_reader.skipNodeMap(name, reader);
     
    569569    /// Give a new undirected edge map reading command to the reader.
    570570    template <typename Map>
    571     UndirGraphReader& readUndirEdgeMap(std::string name, Map& map) {
    572       undir_edgeset_reader.readUndirEdgeMap(name, map);
    573       return *this;
    574     }
    575 
    576     template <typename Map>
    577     UndirGraphReader& readUndirEdgeMap(std::string name, const Map& map) {
    578       undir_edgeset_reader.readUndirEdgeMap(name, map);
     571    UGraphReader& readUEdgeMap(std::string name, Map& map) {
     572      u_edgeset_reader.readUEdgeMap(name, map);
     573      return *this;
     574    }
     575
     576    template <typename Map>
     577    UGraphReader& readUEdgeMap(std::string name, const Map& map) {
     578      u_edgeset_reader.readUEdgeMap(name, map);
    579579      return *this;
    580580    }
     
    585585    /// Give a new undirected edge map reading command to the reader.
    586586    template <typename Reader, typename Map>
    587     UndirGraphReader& readUndirEdgeMap(std::string name, Map& map,
     587    UGraphReader& readUEdgeMap(std::string name, Map& map,
    588588                                       const Reader& reader = Reader()) {
    589       undir_edgeset_reader.readUndirEdgeMap(name, map, reader);
    590       return *this;
    591     }
    592 
    593     template <typename Reader, typename Map>
    594     UndirGraphReader& readUndirEdgeMap(std::string name, const Map& map,
     589      u_edgeset_reader.readUEdgeMap(name, map, reader);
     590      return *this;
     591    }
     592
     593    template <typename Reader, typename Map>
     594    UGraphReader& readUEdgeMap(std::string name, const Map& map,
    595595                                       const Reader& reader = Reader()) {
    596       undir_edgeset_reader.readUndirEdgeMap(name, map, reader);
     596      u_edgeset_reader.readUEdgeMap(name, map, reader);
    597597      return *this;
    598598    }
     
    602602    /// Give a new undirected edge map skipping command to the reader.
    603603    template <typename Reader>
    604     UndirGraphReader& skipUndirEdgeMap(std::string name,
     604    UGraphReader& skipUEdgeMap(std::string name,
    605605                                       const Reader& reader = Reader()) {
    606       undir_edgeset_reader.skipUndirMap(name, reader);
     606      u_edgeset_reader.skipUMap(name, reader);
    607607      return *this;
    608608    }
     
    613613    /// Give a new edge map reading command to the reader.
    614614    template <typename Map>
    615     UndirGraphReader& readEdgeMap(std::string name, Map& map) {
    616       undir_edgeset_reader.readEdgeMap(name, map);
    617       return *this;
    618     }
    619 
    620     template <typename Map>
    621     UndirGraphReader& readEdgeMap(std::string name, const Map& map) {
    622       undir_edgeset_reader.readEdgeMap(name, map);
     615    UGraphReader& readEdgeMap(std::string name, Map& map) {
     616      u_edgeset_reader.readEdgeMap(name, map);
     617      return *this;
     618    }
     619
     620    template <typename Map>
     621    UGraphReader& readEdgeMap(std::string name, const Map& map) {
     622      u_edgeset_reader.readEdgeMap(name, map);
    623623      return *this;
    624624    }
     
    629629    /// Give a new edge map reading command to the reader.
    630630    template <typename Reader, typename Map>
    631     UndirGraphReader& readEdgeMap(std::string name, Map& map,
     631    UGraphReader& readEdgeMap(std::string name, Map& map,
    632632                                       const Reader& reader = Reader()) {
    633       undir_edgeset_reader.readEdgeMap(name, map, reader);
    634       return *this;
    635     }
    636 
    637     template <typename Reader, typename Map>
    638     UndirGraphReader& readEdgeMap(std::string name, const Map& map,
     633      u_edgeset_reader.readEdgeMap(name, map, reader);
     634      return *this;
     635    }
     636
     637    template <typename Reader, typename Map>
     638    UGraphReader& readEdgeMap(std::string name, const Map& map,
    639639                                       const Reader& reader = Reader()) {
    640       undir_edgeset_reader.readEdgeMap(name, map, reader);
     640      u_edgeset_reader.readEdgeMap(name, map, reader);
    641641      return *this;
    642642    }
     
    646646    /// Give a new edge map skipping command to the reader.
    647647    template <typename Reader>
    648     UndirGraphReader& skipEdgeMap(std::string name,
     648    UGraphReader& skipEdgeMap(std::string name,
    649649                                       const Reader& reader = Reader()) {
    650       undir_edgeset_reader.skipEdgeMap(name, reader);
     650      u_edgeset_reader.skipEdgeMap(name, reader);
    651651      return *this;
    652652    }
     
    655655    ///
    656656    /// Give a new labeled node reading command to the reader.
    657     UndirGraphReader& readNode(std::string name, Node& node) {
     657    UGraphReader& readNode(std::string name, Node& node) {
    658658      node_reader.readNode(name, node);
    659659      return *this;
     
    663663    ///
    664664    /// Give a new labeled edge reading command to the reader.
    665     UndirGraphReader& readEdge(std::string name, Edge& edge) {
    666       undir_edge_reader.readEdge(name, edge);
     665    UGraphReader& readEdge(std::string name, Edge& edge) {
     666      u_edge_reader.readEdge(name, edge);
    667667    }
    668668
     
    671671    ///
    672672    /// Give a new labeled undirected edge reading command to the reader.
    673     UndirGraphReader& readUndirEdge(std::string name, UndirEdge& edge) {
    674       undir_edge_reader.readUndirEdge(name, edge);
     673    UGraphReader& readUEdge(std::string name, UEdge& edge) {
     674      u_edge_reader.readUEdge(name, edge);
    675675    }
    676676
     
    679679    ///  Give a new attribute reading command.
    680680    template <typename Value>
    681     UndirGraphReader& readAttribute(std::string name, Value& value) {
     681    UGraphReader& readAttribute(std::string name, Value& value) {
    682682      attribute_reader.readAttribute(name, value);
    683683      return *this;
     
    688688    ///  Give a new attribute reading command.
    689689    template <typename Reader, typename Value>
    690     UndirGraphReader& readAttribute(std::string name, Value& value,
     690    UGraphReader& readAttribute(std::string name, Value& value,
    691691                               const Reader& reader) {
    692692      attribute_reader.readAttribute<Reader>(name, value, reader);
     
    717717    bool isLabelReader() const {
    718718      return nodeset_reader.isLabelReader() &&
    719         undir_edgeset_reader.isLabelReader();
     719        u_edgeset_reader.isLabelReader();
    720720    }
    721721
     
    733733    /// it. It is possible only if there was read an "label" named edge map.
    734734    void readLabel(std::istream& is, Edge& edge) const {
    735       return undir_edgeset_reader.readLabel(is, edge);
     735      return u_edgeset_reader.readLabel(is, edge);
    736736    }
    737737
     
    741741    /// belongs to it. It is possible only if there was read an "label" named
    742742    /// edge map.
    743     void readLabel(std::istream& is, UndirEdge& uedge) const {
    744       return undir_edgeset_reader.readLabel(is, uedge);
     743    void readLabel(std::istream& is, UEdge& uedge) const {
     744      return u_edgeset_reader.readLabel(is, uedge);
    745745    }
    746746   
     
    754754
    755755    NodeSetReader<Graph, ReaderTraits> nodeset_reader;
    756     UndirEdgeSetReader<Graph, ReaderTraits> undir_edgeset_reader;
     756    UEdgeSetReader<Graph, ReaderTraits> u_edgeset_reader;
    757757
    758758    NodeReader<Graph> node_reader;
    759     UndirEdgeReader<Graph> undir_edge_reader;
     759    UEdgeReader<Graph> u_edge_reader;
    760760   
    761761    AttributeReader<ReaderTraits> attribute_reader;
     
    765765  ///
    766766  /// It is a helper function to read an undirected graph from the given input
    767   /// stream. It gives back an UndirGraphReader object and this object
     767  /// stream. It gives back an UGraphReader object and this object
    768768  /// can read more maps, labeled nodes, edges, undirected edges and
    769769  /// attributes.
     
    774774  /// \param g The graph.
    775775  template<typename Graph>
    776   UndirGraphReader<Graph> undirGraphReader(std::istream& is, Graph &g) {
     776  UGraphReader<Graph> uGraphReader(std::istream& is, Graph &g) {
    777777    return GraphReader<Graph>(is, g);
    778778  }
     
    781781  ///
    782782  /// It is a helper function to read an undirected graph from the given input
    783   /// file. It gives back an UndirGraphReader object and this object
     783  /// file. It gives back an UGraphReader object and this object
    784784  /// can read more maps, labeled nodes, edges, undirected edges and
    785785  /// attributes.
     
    790790  /// \param g The graph.
    791791  template<typename Graph>
    792   UndirGraphReader<Graph> undirGraphReader(const std::string& fn, Graph &g) {
     792  UGraphReader<Graph> uGraphReader(const std::string& fn, Graph &g) {
    793793    return GraphReader<Graph>(fn, g);
    794794  }
Note: See TracChangeset for help on using the changeset viewer.