1.1 --- a/lemon/graph_writer.h Tue Aug 28 13:58:54 2007 +0000
1.2 +++ b/lemon/graph_writer.h Tue Aug 28 14:00:42 2007 +0000
1.3 @@ -251,9 +251,17 @@
1.4 writer->run();
1.5 }
1.6
1.7 + /// \brief Returns true if the writer can give back the labels by the items.
1.8 + ///
1.9 + /// Returns true if the writer can give back the the labels by the items.
1.10 + bool isLabelWriter() const {
1.11 + return nodeset_writer.isLabelWriter() &&
1.12 + edgeset_writer.isLabelWriter();
1.13 + }
1.14 +
1.15 /// \brief Write the label of the given node.
1.16 ///
1.17 - /// It writes the label of the given node. If there was written an "label"
1.18 + /// It writes the label of the given node. If there was written a "label"
1.19 /// named node map then it will write the map value belonging to the node.
1.20 void writeLabel(std::ostream& os, const Node& item) const {
1.21 nodeset_writer.writeLabel(os, item);
1.22 @@ -261,12 +269,32 @@
1.23
1.24 /// \brief Write the label of the given edge.
1.25 ///
1.26 - /// It writes the label of the given edge. If there was written an "label"
1.27 + /// It writes the label of the given edge. If there was written a "label"
1.28 /// named edge map then it will write the map value belonging to the edge.
1.29 void writeLabel(std::ostream& os, const Edge& item) const {
1.30 edgeset_writer.writeLabel(os, item);
1.31 }
1.32
1.33 + /// \brief Sorts the given node vector by label.
1.34 + ///
1.35 + /// Sorts the given node vector by label. If there was written an
1.36 + /// "label" named map then the vector will be sorted by the values
1.37 + /// of this map. Otherwise if the \c forceLabel parameter was true
1.38 + /// it will be sorted by its id in the graph.
1.39 + void sortByLabel(std::vector<Node>& nodes) const {
1.40 + nodeset_writer.sortByLabel(nodes);
1.41 + }
1.42 +
1.43 + /// \brief Sorts the given edge vector by label.
1.44 + ///
1.45 + /// Sorts the given edge vector by label. If there was written an
1.46 + /// "label" named map then the vector will be sorted by the values
1.47 + /// of this map. Otherwise if the \c forceLabel parameter was true
1.48 + /// it will be sorted by its id in the graph.
1.49 + void sortByLabel(std::vector<Edge>& edges) const {
1.50 + edgeset_writer.sortByLabel(edges);
1.51 + }
1.52 +
1.53 private:
1.54
1.55 LemonWriter* writer;
1.56 @@ -370,9 +398,9 @@
1.57 UGraphWriter(std::ostream& _os, const Graph& _graph)
1.58 : writer(new LemonWriter(_os)), own_writer(true),
1.59 nodeset_writer(*writer, _graph, std::string()),
1.60 - u_edgeset_writer(*writer, _graph, nodeset_writer, std::string()),
1.61 + uedgeset_writer(*writer, _graph, nodeset_writer, std::string()),
1.62 node_writer(*writer, nodeset_writer, std::string()),
1.63 - u_edge_writer(*writer, u_edgeset_writer, std::string()),
1.64 + uedge_writer(*writer, uedgeset_writer, std::string()),
1.65 attribute_writer(*writer, std::string()) {}
1.66
1.67 /// \brief Construct a new UGraphWriter.
1.68 @@ -382,21 +410,21 @@
1.69 UGraphWriter(const std::string& _filename, const Graph& _graph)
1.70 : writer(new LemonWriter(_filename)), own_writer(true),
1.71 nodeset_writer(*writer, _graph, std::string()),
1.72 - u_edgeset_writer(*writer, _graph, nodeset_writer, std::string()),
1.73 + uedgeset_writer(*writer, _graph, nodeset_writer, std::string()),
1.74 node_writer(*writer, nodeset_writer, std::string()),
1.75 - u_edge_writer(*writer, u_edgeset_writer, std::string()),
1.76 + uedge_writer(*writer, uedgeset_writer, std::string()),
1.77 attribute_writer(*writer, std::string()) {}
1.78
1.79 /// \brief Construct a new UGraphWriter.
1.80 ///
1.81 /// Construct a new UGraphWriter. It writes the given graph
1.82 - /// to given LemonReader.
1.83 + /// to given LemonWriter.
1.84 UGraphWriter(LemonWriter& _writer, const Graph& _graph)
1.85 : writer(_writer), own_writer(false),
1.86 nodeset_writer(*writer, _graph, std::string()),
1.87 - u_edgeset_writer(*writer, _graph, nodeset_writer, std::string()),
1.88 + uedgeset_writer(*writer, _graph, nodeset_writer, std::string()),
1.89 node_writer(*writer, nodeset_writer, std::string()),
1.90 - u_edge_writer(*writer, u_edgeset_writer, std::string()),
1.91 + uedge_writer(*writer, uedgeset_writer, std::string()),
1.92 attribute_writer(*writer, std::string()) {}
1.93
1.94 /// \brief Destruct the graph writer.
1.95 @@ -434,7 +462,7 @@
1.96 /// the writer.
1.97 template <typename Map>
1.98 UGraphWriter& writeEdgeMap(std::string label, const Map& map) {
1.99 - u_edgeset_writer.writeEdgeMap(label, map);
1.100 + uedgeset_writer.writeEdgeMap(label, map);
1.101 return *this;
1.102 }
1.103
1.104 @@ -445,7 +473,7 @@
1.105 template <typename ItemWriter, typename Map>
1.106 UGraphWriter& writeEdgeMap(std::string label, const Map& map,
1.107 const ItemWriter& iw = ItemWriter()) {
1.108 - u_edgeset_writer.writeEdgeMap(label, map, iw);
1.109 + uedgeset_writer.writeEdgeMap(label, map, iw);
1.110 return *this;
1.111 }
1.112
1.113 @@ -455,7 +483,7 @@
1.114 /// command</i> to the writer.
1.115 template <typename Map>
1.116 UGraphWriter& writeUEdgeMap(std::string label, const Map& map) {
1.117 - u_edgeset_writer.writeUEdgeMap(label, map);
1.118 + uedgeset_writer.writeUEdgeMap(label, map);
1.119 return *this;
1.120 }
1.121
1.122 @@ -466,7 +494,7 @@
1.123 template <typename ItemWriter, typename Map>
1.124 UGraphWriter& writeUEdgeMap(std::string label, const Map& map,
1.125 const ItemWriter& iw = ItemWriter()) {
1.126 - u_edgeset_writer.writeUEdgeMap(label, map, iw);
1.127 + uedgeset_writer.writeUEdgeMap(label, map, iw);
1.128 return *this;
1.129 }
1.130
1.131 @@ -484,7 +512,7 @@
1.132 /// This function issues a new <i> labeled edge writing
1.133 /// command</i> to the writer.
1.134 UGraphWriter& writeEdge(std::string label, const Edge& edge) {
1.135 - u_edge_writer.writeEdge(label, edge);
1.136 + uedge_writer.writeEdge(label, edge);
1.137 }
1.138
1.139 /// \brief Issue a new labeled undirected edge writing command to
1.140 @@ -493,7 +521,7 @@
1.141 /// Issue a new <i>labeled undirected edge writing command</i> to
1.142 /// the writer.
1.143 UGraphWriter& writeUEdge(std::string label, const UEdge& edge) {
1.144 - u_edge_writer.writeUEdge(label, edge);
1.145 + uedge_writer.writeUEdge(label, edge);
1.146 }
1.147
1.148 /// \brief Issue a new attribute writing command.
1.149 @@ -534,9 +562,17 @@
1.150 writer->run();
1.151 }
1.152
1.153 + /// \brief Returns true if the writer can give back the labels by the items.
1.154 + ///
1.155 + /// Returns true if the writer can give back the the labels by the items.
1.156 + bool isLabelWriter() const {
1.157 + return nodeset_writer.isLabelWriter() &&
1.158 + uedgeset_writer.isLabelWriter();
1.159 + }
1.160 +
1.161 /// \brief Write the label of the given node.
1.162 ///
1.163 - /// It writes the label of the given node. If there was written an "label"
1.164 + /// It writes the label of the given node. If there was written a "label"
1.165 /// named node map then it will write the map value belonging to the node.
1.166 void writeLabel(std::ostream& os, const Node& item) const {
1.167 nodeset_writer.writeLabel(os, item);
1.168 @@ -544,21 +580,50 @@
1.169
1.170 /// \brief Write the label of the given edge.
1.171 ///
1.172 - /// It writes the label of the given edge. If there was written an "label"
1.173 + /// It writes the label of the given edge. If there was written a "label"
1.174 /// named edge map then it will write the map value belonging to the edge.
1.175 void writeLabel(std::ostream& os, const Edge& item) const {
1.176 - u_edgeset_writer.writeLabel(os, item);
1.177 + uedgeset_writer.writeLabel(os, item);
1.178 }
1.179
1.180 /// \brief Write the label of the given undirected edge.
1.181 ///
1.182 /// It writes the label of the given undirected edge. If there was
1.183 - /// written an "label" named edge map then it will write the map
1.184 + /// written a "label" named edge map then it will write the map
1.185 /// value belonging to the edge.
1.186 void writeLabel(std::ostream& os, const UEdge& item) const {
1.187 - u_edgeset_writer.writeLabel(os, item);
1.188 + uedgeset_writer.writeLabel(os, item);
1.189 }
1.190
1.191 + /// \brief Sorts the given node vector by label.
1.192 + ///
1.193 + /// Sorts the given node vector by label. If there was written an
1.194 + /// "label" named map then the vector will be sorted by the values
1.195 + /// of this map. Otherwise if the \c forceLabel parameter was true
1.196 + /// it will be sorted by its id in the graph.
1.197 + void sortByLabel(std::vector<Node>& nodes) const {
1.198 + nodeset_writer.sortByLabel(nodes);
1.199 + }
1.200 +
1.201 + /// \brief Sorts the given edge vector by label.
1.202 + ///
1.203 + /// Sorts the given edge vector by label. If there was written an
1.204 + /// "label" named map then the vector will be sorted by the values
1.205 + /// of this map. Otherwise if the \c forceLabel parameter was true
1.206 + /// it will be sorted by its id in the graph.
1.207 + void sortByLabel(std::vector<Edge>& edges) const {
1.208 + uedgeset_writer.sortByLabel(edges);
1.209 + }
1.210 +
1.211 + /// \brief Sorts the given undirected edge vector by label.
1.212 + ///
1.213 + /// Sorts the given undirected edge vector by label. If there was
1.214 + /// written an "label" named map then the vector will be sorted by
1.215 + /// the values of this map. Otherwise if the \c forceLabel
1.216 + /// parameter was true it will be sorted by its id in the graph.
1.217 + void sortByLabel(std::vector<UEdge>& uedges) const {
1.218 + uedgeset_writer.sortByLabel(uedges);
1.219 + }
1.220
1.221 private:
1.222
1.223 @@ -566,10 +631,10 @@
1.224 bool own_writer;
1.225
1.226 NodeSetWriter<Graph, WriterTraits> nodeset_writer;
1.227 - UEdgeSetWriter<Graph, WriterTraits> u_edgeset_writer;
1.228 + UEdgeSetWriter<Graph, WriterTraits> uedgeset_writer;
1.229
1.230 NodeWriter<Graph> node_writer;
1.231 - UEdgeWriter<Graph> u_edge_writer;
1.232 + UEdgeWriter<Graph> uedge_writer;
1.233
1.234 AttributeWriter<WriterTraits> attribute_writer;
1.235 };