COIN-OR::LEMON - Graph Library

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

    r1901 r1909  
    316316  /// \brief The undirected graph writer class.
    317317  ///
    318   /// The \c UndirGraphWriter class provides the undir graph output. To write
     318  /// The \c UGraphWriter class provides the ugraph output. To write
    319319  /// a graph you should first give writing commands to the writer. You can
    320   /// declare write command as \c NodeMap, \c EdgeMap or \c UndirEdgeMap
    321   /// writing and labeled Node, Edge or UndirEdge writing.
    322   ///
    323   /// \code
    324   /// UndirGraphWriter<UndirListGraph> writer(std::cout, graph);
     320  /// declare write command as \c NodeMap, \c EdgeMap or \c UEdgeMap
     321  /// writing and labeled Node, Edge or UEdge writing.
     322  ///
     323  /// \code
     324  /// UGraphWriter<ListUGraph> writer(std::cout, graph);
    325325  /// \endcode
    326326  ///
    327327  /// The \c writeNodeMap() function declares a \c NodeMap writing
    328   /// command in the \c UndirGraphWriter. You should give as parameter
     328  /// command in the \c UGraphWriter. You should give as parameter
    329329  /// the name of the map and the map object. The NodeMap writing
    330330  /// command with name "label" should write a unique map because it
     
    332332  ///
    333333  /// \code
    334   /// IdMap<UndirListGraph, Node> nodeLabelMap;
     334  /// IdMap<ListUGraph, Node> nodeLabelMap;
    335335  /// writer.writeNodeMap("label", nodeLabelMap);
    336336  ///
     
    339339  /// \endcode
    340340  ///
    341   /// With the \c writeUndirEdgeMap() member function you can give an
     341  /// With the \c writeUEdgeMap() member function you can give an
    342342  /// undirected edge map writing command similar to the NodeMaps.
    343343  ///
     
    345345  /// DescriptorMap<ListGraph, Edge, ListGraph::EdgeMap<int> >
    346346  ///   edgeDescMap(graph);
    347   /// writer.writeUndirEdgeMap("descriptor", edgeDescMap);
    348   ///
    349   /// writer.writeUndirEdgeMap("weight", weightMap);
    350   /// writer.writeUndirEdgeMap("label", labelMap);
     347  /// writer.writeUEdgeMap("descriptor", edgeDescMap);
     348  ///
     349  /// writer.writeUEdgeMap("weight", weightMap);
     350  /// writer.writeUEdgeMap("label", labelMap);
    351351  /// \endcode
    352352  ///
     
    359359  ///
    360360  ///
    361   /// With \c writeNode() and \c writeUndirEdge() functions you can
     361  /// With \c writeNode() and \c writeUEdge() functions you can
    362362  /// designate nodes and undirected edges in the graph. For example, you can
    363363  /// write out the source and target of the graph.
     
    367367  /// writer.writeNode("target", targetNode);
    368368  ///
    369   /// writer.writeUndirEdge("observed", undirEdge);
     369  /// writer.writeUEdge("observed", uEdge);
    370370  /// \endcode
    371371  ///
     
    385385  /// \author Balazs Dezso
    386386  template <typename _Graph, typename _WriterTraits = DefaultWriterTraits>
    387   class UndirGraphWriter {
     387  class UGraphWriter {
    388388  public:
    389389   
     
    391391    typedef typename Graph::Node Node;
    392392    typedef typename Graph::Edge Edge;
    393     typedef typename Graph::UndirEdge UndirEdge;
     393    typedef typename Graph::UEdge UEdge;
    394394
    395395    typedef _WriterTraits WriterTraits;
    396396
    397     /// \brief Construct a new UndirGraphWriter.
    398     ///
    399     /// Construct a new UndirGraphWriter. It writes the given graph
     397    /// \brief Construct a new UGraphWriter.
     398    ///
     399    /// Construct a new UGraphWriter. It writes the given graph
    400400    /// to the given stream.
    401     UndirGraphWriter(std::ostream& _os, const Graph& _graph)
     401    UGraphWriter(std::ostream& _os, const Graph& _graph)
    402402      : writer(new LemonWriter(_os)), own_writer(true),
    403403        nodeset_writer(*writer, _graph, std::string()),
    404         undir_edgeset_writer(*writer, _graph, nodeset_writer, std::string()),
     404        u_edgeset_writer(*writer, _graph, nodeset_writer, std::string()),
    405405        node_writer(*writer, nodeset_writer, std::string()),
    406         undir_edge_writer(*writer, undir_edgeset_writer, std::string()),
     406        u_edge_writer(*writer, u_edgeset_writer, std::string()),
    407407        attribute_writer(*writer, std::string()) {}
    408408
    409     /// \brief Construct a new UndirGraphWriter.
    410     ///
    411     /// Construct a new UndirGraphWriter. It writes the given graph
     409    /// \brief Construct a new UGraphWriter.
     410    ///
     411    /// Construct a new UGraphWriter. It writes the given graph
    412412    /// to the given file.
    413     UndirGraphWriter(const std::string& _filename, const Graph& _graph)
     413    UGraphWriter(const std::string& _filename, const Graph& _graph)
    414414      : writer(new LemonWriter(_filename)), own_writer(true),
    415415        nodeset_writer(*writer, _graph, std::string()),
    416         undir_edgeset_writer(*writer, _graph, nodeset_writer, std::string()),
     416        u_edgeset_writer(*writer, _graph, nodeset_writer, std::string()),
    417417        node_writer(*writer, nodeset_writer, std::string()),
    418         undir_edge_writer(*writer, undir_edgeset_writer, std::string()),
     418        u_edge_writer(*writer, u_edgeset_writer, std::string()),
    419419        attribute_writer(*writer, std::string()) {}
    420420
    421     /// \brief Construct a new UndirGraphWriter.
    422     ///
    423     /// Construct a new UndirGraphWriter. It writes the given graph
     421    /// \brief Construct a new UGraphWriter.
     422    ///
     423    /// Construct a new UGraphWriter. It writes the given graph
    424424    /// to given LemonReader.
    425     UndirGraphWriter(LemonWriter& _writer, const Graph& _graph)
     425    UGraphWriter(LemonWriter& _writer, const Graph& _graph)
    426426      : writer(_writer), own_writer(false),
    427427        nodeset_writer(*writer, _graph, std::string()),
    428         undir_edgeset_writer(*writer, _graph, nodeset_writer, std::string()),
     428        u_edgeset_writer(*writer, _graph, nodeset_writer, std::string()),
    429429        node_writer(*writer, nodeset_writer, std::string()),
    430         undir_edge_writer(*writer, undir_edgeset_writer, std::string()),
     430        u_edge_writer(*writer, u_edgeset_writer, std::string()),
    431431        attribute_writer(*writer, std::string()) {}
    432432
     
    434434    ///
    435435    /// Destruct the graph writer.
    436     ~UndirGraphWriter() {
     436    ~UGraphWriter() {
    437437      if (own_writer)
    438438        delete writer;
     
    443443   /// This function issues a new <i> node map writing command</i> to the writer.
    444444    template <typename Map>
    445     UndirGraphWriter& writeNodeMap(std::string name, const Map& map) {
     445    UGraphWriter& writeNodeMap(std::string name, const Map& map) {
    446446      nodeset_writer.writeNodeMap(name, map);
    447447      return *this;
     
    452452   /// This function issues a new <i> node map writing command</i> to the writer.
    453453    template <typename Writer, typename Map>
    454     UndirGraphWriter& writeNodeMap(std::string name, const Map& map,
     454    UGraphWriter& writeNodeMap(std::string name, const Map& map,
    455455                              const Writer& writer = Writer()) {
    456456      nodeset_writer.writeNodeMap(name, map, writer);
     
    462462   /// This function issues a new <i> edge map writing command</i> to the writer.
    463463    template <typename Map>
    464     UndirGraphWriter& writeEdgeMap(std::string name, const Map& map) {
    465       undir_edgeset_writer.writeEdgeMap(name, map);
     464    UGraphWriter& writeEdgeMap(std::string name, const Map& map) {
     465      u_edgeset_writer.writeEdgeMap(name, map);
    466466      return *this;
    467467    }
     
    471471   /// This function issues a new <i> edge map writing command</i> to the writer.
    472472    template <typename Writer, typename Map>
    473     UndirGraphWriter& writeEdgeMap(std::string name, const Map& map,
     473    UGraphWriter& writeEdgeMap(std::string name, const Map& map,
    474474                                   const Writer& writer = Writer()) {
    475       undir_edgeset_writer.writeEdgeMap(name, map, writer);
     475      u_edgeset_writer.writeEdgeMap(name, map, writer);
    476476      return *this;
    477477    }
     
    482482    /// command</i> to the writer.
    483483    template <typename Map>
    484     UndirGraphWriter& writeUndirEdgeMap(std::string name, const Map& map) {
    485       undir_edgeset_writer.writeUndirEdgeMap(name, map);
     484    UGraphWriter& writeUEdgeMap(std::string name, const Map& map) {
     485      u_edgeset_writer.writeUEdgeMap(name, map);
    486486      return *this;
    487487    }
     
    492492    /// command</i> to the writer.
    493493   template <typename Writer, typename Map>
    494     UndirGraphWriter& writeUndirEdgeMap(std::string name, const Map& map,
     494    UGraphWriter& writeUEdgeMap(std::string name, const Map& map,
    495495                                        const Writer& writer = Writer()) {
    496       undir_edgeset_writer.writeUndirEdgeMap(name, map, writer);
     496      u_edgeset_writer.writeUEdgeMap(name, map, writer);
    497497      return *this;
    498498    }
     
    502502    /// This function issues a new <i> labeled node writing
    503503    /// command</i> to the writer.
    504     UndirGraphWriter& writeNode(std::string name, const Node& node) {
     504    UGraphWriter& writeNode(std::string name, const Node& node) {
    505505      node_writer.writeNode(name, node);
    506506      return *this;
     
    511511    /// This function issues a new <i> labeled edge writing
    512512    /// command</i> to the writer.
    513     UndirGraphWriter& writeEdge(std::string name, const Edge& edge) {
    514       undir_edge_writer.writeEdge(name, edge);
     513    UGraphWriter& writeEdge(std::string name, const Edge& edge) {
     514      u_edge_writer.writeEdge(name, edge);
    515515    }
    516516
     
    520520    /// Issue a new <i>labeled undirected edge writing command</i> to
    521521    /// the writer.
    522     UndirGraphWriter& writeUndirEdge(std::string name, const UndirEdge& edge) {
    523       undir_edge_writer.writeUndirEdge(name, edge);
     522    UGraphWriter& writeUEdge(std::string name, const UEdge& edge) {
     523      u_edge_writer.writeUEdge(name, edge);
    524524    }
    525525
     
    529529    /// command</i> to the writer.
    530530    template <typename Value>
    531     UndirGraphWriter& writeAttribute(std::string name, const Value& value) {
     531    UGraphWriter& writeAttribute(std::string name, const Value& value) {
    532532      attribute_writer.writeAttribute(name, value);
    533533      return *this;
     
    539539    /// command</i> to the writer.
    540540    template <typename Writer, typename Value>
    541     UndirGraphWriter& writeAttribute(std::string name, const Value& value,
     541    UGraphWriter& writeAttribute(std::string name, const Value& value,
    542542                               const Writer& writer) {
    543543      attribute_writer.writeAttribute<Writer>(name, value, writer);
     
    575575    /// named edge map then it will write the map value belonging to the edge.
    576576    void writeLabel(std::ostream& os, const Edge& item) const {
    577       undir_edgeset_writer.writeLabel(os, item);
     577      u_edgeset_writer.writeLabel(os, item);
    578578    }
    579579
     
    583583    /// an "label" named edge map then it will write the map value belonging to
    584584    /// the edge.
    585     void writeLabel(std::ostream& os, const UndirEdge& item) const {
    586       undir_edgeset_writer.writeLabel(os, item);
     585    void writeLabel(std::ostream& os, const UEdge& item) const {
     586      u_edgeset_writer.writeLabel(os, item);
    587587    }
    588588
     
    594594
    595595    NodeSetWriter<Graph, WriterTraits> nodeset_writer;
    596     UndirEdgeSetWriter<Graph, WriterTraits> undir_edgeset_writer;
     596    UEdgeSetWriter<Graph, WriterTraits> u_edgeset_writer;
    597597
    598598    NodeWriter<Graph> node_writer;
    599     UndirEdgeWriter<Graph> undir_edge_writer;
     599    UEdgeWriter<Graph> u_edge_writer;
    600600   
    601601    AttributeWriter<WriterTraits> attribute_writer;
     
    605605  ///
    606606  /// It is a helper function to write an undirected graph to the given output
    607   /// stream. It gives back an UndirGraphWriter object and this object
     607  /// stream. It gives back an UGraphWriter object and this object
    608608  /// can write more maps, labeled nodes and edges and attributes.
    609609  /// \warning Do not forget to call the \c run() function.
     
    612612  /// \param g The graph.
    613613  template <typename Graph>
    614   UndirGraphWriter<Graph> undirGraphWriter(std::ostream& os, const Graph &g) {
    615     return UndirGraphWriter<Graph>(os, g);
     614  UGraphWriter<Graph> uGraphWriter(std::ostream& os, const Graph &g) {
     615    return UGraphWriter<Graph>(os, g);
    616616  }
    617617
     
    619619  ///
    620620  /// It is a helper function to write an undirected graph to the given output
    621   /// file. It gives back an UndirGraphWriter object and this object
     621  /// file. It gives back an UGraphWriter object and this object
    622622  /// can write more maps, labeled nodes, edges, undirected edges and
    623623  /// attributes.
     
    628628  /// \param g The graph.
    629629  template <typename Graph>
    630   UndirGraphWriter<Graph> undirGraphWriter(const std::string& fn,
     630  UGraphWriter<Graph> uGraphWriter(const std::string& fn,
    631631                                           const Graph &g) {
    632     return UndirGraphWriter<Graph>(fn, g);
     632    return UGraphWriter<Graph>(fn, g);
    633633  }
    634634
Note: See TracChangeset for help on using the changeset viewer.