1.1 --- a/lemon/lgf_reader.h Wed Jul 02 13:51:20 2008 +0100
1.2 +++ b/lemon/lgf_reader.h Thu Jul 03 12:40:04 2008 +0200
1.3 @@ -479,6 +479,9 @@
1.4 bool _use_nodes;
1.5 bool _use_arcs;
1.6
1.7 + bool _skip_nodes;
1.8 + bool _skip_arcs;
1.9 +
1.10 int line_num;
1.11 std::istringstream line;
1.12
1.13 @@ -490,7 +493,8 @@
1.14 /// input stream.
1.15 DigraphReader(std::istream& is, Digraph& digraph)
1.16 : _is(&is), local_is(false), _digraph(digraph),
1.17 - _use_nodes(false), _use_arcs(false) {}
1.18 + _use_nodes(false), _use_arcs(false),
1.19 + _skip_nodes(false), _skip_arcs(false) {}
1.20
1.21 /// \brief Constructor
1.22 ///
1.23 @@ -498,7 +502,8 @@
1.24 /// file.
1.25 DigraphReader(const std::string& fn, Digraph& digraph)
1.26 : _is(new std::ifstream(fn.c_str())), local_is(true), _digraph(digraph),
1.27 - _use_nodes(false), _use_arcs(false) {}
1.28 + _use_nodes(false), _use_arcs(false),
1.29 + _skip_nodes(false), _skip_arcs(false) {}
1.30
1.31 /// \brief Constructor
1.32 ///
1.33 @@ -506,7 +511,8 @@
1.34 /// file.
1.35 DigraphReader(const char* fn, Digraph& digraph)
1.36 : _is(new std::ifstream(fn)), local_is(true), _digraph(digraph),
1.37 - _use_nodes(false), _use_arcs(false) {}
1.38 + _use_nodes(false), _use_arcs(false),
1.39 + _skip_nodes(false), _skip_arcs(false) {}
1.40
1.41 /// \brief Copy constructor
1.42 ///
1.43 @@ -514,7 +520,8 @@
1.44 /// therefore the copied reader will not be usable more.
1.45 DigraphReader(DigraphReader& other)
1.46 : _is(other._is), local_is(other.local_is), _digraph(other._digraph),
1.47 - _use_nodes(other._use_nodes), _use_arcs(other._use_arcs) {
1.48 + _use_nodes(other._use_nodes), _use_arcs(other._use_arcs),
1.49 + _skip_nodes(other._skip_nodes), _skip_arcs(other._skip_arcs) {
1.50
1.51 other._is = 0;
1.52 other.local_is = false;
1.53 @@ -837,7 +844,7 @@
1.54 /// std::string.
1.55 template <typename Map, typename Converter>
1.56 DigraphReader& useArcs(const Map& map,
1.57 - const Converter& converter = Converter()) {
1.58 + const Converter& converter = Converter()) {
1.59 checkConcept<concepts::ReadMap<Arc, typename Map::Value>, Map>();
1.60 LEMON_ASSERT(!_use_arcs, "Multiple usage of useArcs() member");
1.61 _use_arcs = true;
1.62 @@ -847,6 +854,32 @@
1.63 return *this;
1.64 }
1.65
1.66 + /// \brief Skips the reading of node section
1.67 + ///
1.68 + /// Omit the reading of the node section. This implies that each node
1.69 + /// map reading rule will be abanoned, and the nodes of the graph
1.70 + /// will not be constructed, which usually cause that the arc set
1.71 + /// could not be read due to lack of node name
1.72 + /// resolving. Therefore, the \c skipArcs() should be used too, or
1.73 + /// the useNodes() member function should be used to specify the
1.74 + /// label of the nodes.
1.75 + DigraphReader& skipNodes() {
1.76 + LEMON_ASSERT(!_skip_nodes, "Skip nodes already set");
1.77 + _skip_nodes = true;
1.78 + return *this;
1.79 + }
1.80 +
1.81 + /// \brief Skips the reading of arc section
1.82 + ///
1.83 + /// Omit the reading of the arc section. This implies that each arc
1.84 + /// map reading rule will be abanoned, and the arcs of the graph
1.85 + /// will not be constructed.
1.86 + DigraphReader& skipArcs() {
1.87 + LEMON_ASSERT(!_skip_arcs, "Skip arcs already set");
1.88 + _skip_arcs = true;
1.89 + return *this;
1.90 + }
1.91 +
1.92 /// @}
1.93
1.94 private:
1.95 @@ -1152,8 +1185,8 @@
1.96 throw DataFormatError("Cannot find file");
1.97 }
1.98
1.99 - bool nodes_done = false;
1.100 - bool arcs_done = false;
1.101 + bool nodes_done = _skip_nodes;
1.102 + bool arcs_done = _skip_arcs;
1.103 bool attributes_done = false;
1.104 std::set<std::string> extra_sections;
1.105
1.106 @@ -1295,6 +1328,9 @@
1.107 bool _use_nodes;
1.108 bool _use_edges;
1.109
1.110 + bool _skip_nodes;
1.111 + bool _skip_edges;
1.112 +
1.113 int line_num;
1.114 std::istringstream line;
1.115
1.116 @@ -1306,7 +1342,8 @@
1.117 /// input stream.
1.118 GraphReader(std::istream& is, Graph& graph)
1.119 : _is(&is), local_is(false), _graph(graph),
1.120 - _use_nodes(false), _use_edges(false) {}
1.121 + _use_nodes(false), _use_edges(false),
1.122 + _skip_nodes(false), _skip_edges(false) {}
1.123
1.124 /// \brief Constructor
1.125 ///
1.126 @@ -1314,7 +1351,8 @@
1.127 /// file.
1.128 GraphReader(const std::string& fn, Graph& graph)
1.129 : _is(new std::ifstream(fn.c_str())), local_is(true), _graph(graph),
1.130 - _use_nodes(false), _use_edges(false) {}
1.131 + _use_nodes(false), _use_edges(false),
1.132 + _skip_nodes(false), _skip_edges(false) {}
1.133
1.134 /// \brief Constructor
1.135 ///
1.136 @@ -1322,7 +1360,8 @@
1.137 /// file.
1.138 GraphReader(const char* fn, Graph& graph)
1.139 : _is(new std::ifstream(fn)), local_is(true), _graph(graph),
1.140 - _use_nodes(false), _use_edges(false) {}
1.141 + _use_nodes(false), _use_edges(false),
1.142 + _skip_nodes(false), _skip_edges(false) {}
1.143
1.144 /// \brief Copy constructor
1.145 ///
1.146 @@ -1330,7 +1369,8 @@
1.147 /// therefore the copied reader will not be usable more.
1.148 GraphReader(GraphReader& other)
1.149 : _is(other._is), local_is(other.local_is), _graph(other._graph),
1.150 - _use_nodes(other._use_nodes), _use_edges(other._use_edges) {
1.151 + _use_nodes(other._use_nodes), _use_edges(other._use_edges),
1.152 + _skip_nodes(other._skip_nodes), _skip_edges(other._skip_edges) {
1.153
1.154 other._is = 0;
1.155 other.local_is = false;
1.156 @@ -1709,6 +1749,32 @@
1.157 return *this;
1.158 }
1.159
1.160 + /// \brief Skips the reading of node section
1.161 + ///
1.162 + /// Omit the reading of the node section. This implies that each node
1.163 + /// map reading rule will be abanoned, and the nodes of the graph
1.164 + /// will not be constructed, which usually cause that the edge set
1.165 + /// could not be read due to lack of node name
1.166 + /// resolving. Therefore, the \c skipEdges() should be used too, or
1.167 + /// the useNodes() member function should be used to specify the
1.168 + /// label of the nodes.
1.169 + GraphReader& skipNodes() {
1.170 + LEMON_ASSERT(!_skip_nodes, "Skip nodes already set");
1.171 + _skip_nodes = true;
1.172 + return *this;
1.173 + }
1.174 +
1.175 + /// \brief Skips the reading of edge section
1.176 + ///
1.177 + /// Omit the reading of the edge section. This implies that each edge
1.178 + /// map reading rule will be abanoned, and the edges of the graph
1.179 + /// will not be constructed.
1.180 + GraphReader& skipEdges() {
1.181 + LEMON_ASSERT(!_skip_edges, "Skip edges already set");
1.182 + _skip_edges = true;
1.183 + return *this;
1.184 + }
1.185 +
1.186 /// @}
1.187
1.188 private:
1.189 @@ -2012,8 +2078,8 @@
1.190
1.191 LEMON_ASSERT(_is != 0, "This reader assigned to an other reader");
1.192
1.193 - bool nodes_done = false;
1.194 - bool edges_done = false;
1.195 + bool nodes_done = _skip_nodes;
1.196 + bool edges_done = _skip_edges;
1.197 bool attributes_done = false;
1.198 std::set<std::string> extra_sections;
1.199