1.1 --- a/lemon/graph_reader.h Wed Oct 26 10:59:51 2005 +0000
1.2 +++ b/lemon/graph_reader.h Wed Oct 26 11:09:29 2005 +0000
1.3 @@ -339,97 +339,37 @@
1.4 };
1.5
1.6
1.7 - ///\anchor readGraph()
1.8 + /// \brief Read a graph from the input.
1.9 ///
1.10 - /// \brief Read a graph from an input stream.
1.11 + /// It is a helper function to read a graph from the given input
1.12 + /// stream. It gives back an GraphReader object and this object
1.13 + /// can read more maps, labeled nodes, edges and attributes.
1.14 ///
1.15 - /// Read a graph from an input stream.
1.16 + /// \warning Do not forget to call the \c run() function.
1.17 + ///
1.18 /// \param is The input stream.
1.19 /// \param g The graph.
1.20 template<typename Graph>
1.21 - void readGraph(std::istream& is, Graph &g) {
1.22 - GraphReader<Graph> reader(is, g);
1.23 - reader.run();
1.24 + GraphReader<Graph> graphReader(std::istream& is, Graph &g) {
1.25 + return GraphReader<Graph>(is, g);
1.26 }
1.27
1.28 - /// \brief Read a capacitated graph instance from an input stream.
1.29 - ///
1.30 - /// Read a capacitated graph (graph+capacity on the
1.31 - /// edges) from an input stream.
1.32 - /// \param is The input stream.
1.33 + /// \brief Read a graph from the input.
1.34 + ///
1.35 + /// It is a helper function to read a graph from the given input
1.36 + /// file. It gives back an GraphReader object and this object
1.37 + /// can read more maps, labeled nodes, edges and attributes.
1.38 + ///
1.39 + /// \warning Do not forget to call the \c run() function.
1.40 + ///
1.41 + /// \param fn The input filename.
1.42 /// \param g The graph.
1.43 - /// \param capacity The capacity map.
1.44 - template<typename Graph, typename CapacityMap>
1.45 - void readGraph(std::istream& is, Graph &g, CapacityMap& capacity) {
1.46 - GraphReader<Graph> reader(is, g);
1.47 - reader.readEdgeMap("capacity", capacity);
1.48 - reader.run();
1.49 + template<typename Graph>
1.50 + GraphReader<Graph> graphReader(const std::string& fn, Graph &g) {
1.51 + return GraphReader<Graph>(fn, g);
1.52 }
1.53
1.54 - /// \brief Read a shortest path instance from an input stream.
1.55 - ///
1.56 - /// Read a shortest path instance (graph+capacity on the
1.57 - /// edges+designated source) from an input stream.
1.58 - /// \param is The input stream.
1.59 - /// \param g The graph.
1.60 - /// \param capacity The capacity map.
1.61 - /// \param s The source node.
1.62 - template<typename Graph, typename CapacityMap>
1.63 - void readGraph(std::istream& is, Graph &g, CapacityMap& capacity,
1.64 - typename Graph::Node &s) {
1.65 - GraphReader<Graph> reader(is, g);
1.66 - reader.readEdgeMap("capacity", capacity);
1.67 - reader.readNode("source", s);
1.68 - reader.run();
1.69 - }
1.70 -
1.71 -
1.72 -
1.73 - /// \brief Read a max flow instance from an input stream.
1.74 - ///
1.75 - /// Read a max flow instance (graph+capacity on the
1.76 - /// edges+designated source and target) from an input stream.
1.77 - ///
1.78 - /// \param is The input stream.
1.79 - /// \param g The graph.
1.80 - /// \param capacity The capacity map.
1.81 - /// \param s The source node.
1.82 - /// \param t The target node.
1.83 - template<typename Graph, typename CapacityMap>
1.84 - void readGraph(std::istream& is, Graph &g, CapacityMap& capacity,
1.85 - typename Graph::Node &s, typename Graph::Node &t) {
1.86 - GraphReader<Graph> reader(is, g);
1.87 - reader.readEdgeMap("capacity", capacity);
1.88 - reader.readNode("source", s);
1.89 - reader.readNode("target", t);
1.90 - reader.run();
1.91 - }
1.92 -
1.93 - /// \brief Read a min cost flow instance from an input stream.
1.94 - ///
1.95 - /// Read a min cost flow instance (graph+capacity on the edges+cost
1.96 - /// function on the edges+designated source and target) from an input stream.
1.97 - ///
1.98 - /// \param is The input stream.
1.99 - /// \param g The graph.
1.100 - /// \param capacity The capacity map.
1.101 - /// \param s The source node.
1.102 - /// \param t The target node.
1.103 - /// \param cost The cost map.
1.104 - template<typename Graph, typename CapacityMap, typename CostMap>
1.105 - void readGraph(std::istream& is, Graph &g, CapacityMap& capacity,
1.106 - typename Graph::Node &s, typename Graph::Node &t,
1.107 - CostMap& cost) {
1.108 - GraphReader<Graph> reader(is, g);
1.109 - reader.readEdgeMap("capacity", capacity);
1.110 - reader.readEdgeMap("cost", cost);
1.111 - reader.readNode("source", s);
1.112 - reader.readNode("target", t);
1.113 - reader.run();
1.114 - }
1.115 -
1.116 -
1.117 - /// \brief The undir graph reader class.
1.118 + /// \brief The undirected graph reader class.
1.119 ///
1.120 /// The \c UndirGraphReader class provides the graph input.
1.121 /// Before you read this documentation it might be useful to read the general
1.122 @@ -806,33 +746,38 @@
1.123 AttributeReader<ReaderTraits> attribute_reader;
1.124 };
1.125
1.126 - /// \brief Read an undirected graph from an input stream.
1.127 + /// \brief Read an undirected graph from the input.
1.128 ///
1.129 - /// Read an undirected graph from an input stream.
1.130 + /// It is a helper function to read an undirected graph from the given input
1.131 + /// stream. It gives back an UndirGraphReader object and this object
1.132 + /// can read more maps, labeled nodes, edges, undirected edges and
1.133 + /// attributes.
1.134 + ///
1.135 + /// \warning Do not forget to call the \c run() function.
1.136 + ///
1.137 /// \param is The input stream.
1.138 /// \param g The graph.
1.139 template<typename Graph>
1.140 - void readUndirGraph(std::istream& is, Graph &g) {
1.141 - UndirGraphReader<Graph> reader(is, g);
1.142 - reader.run();
1.143 + UndirGraphReader<Graph> undirGraphReader(std::istream& is, Graph &g) {
1.144 + return GraphReader<Graph>(is, g);
1.145 }
1.146
1.147 - /// \brief Read an undirected multigraph (undirected graph + capacity
1.148 - /// map on the edges) from an input stream.
1.149 + /// \brief Read an undirected graph from the input.
1.150 ///
1.151 - /// Read an undirected multigraph (undirected graph + capacity
1.152 - /// map on the edges) from an input stream.
1.153 - /// \param is The input stream.
1.154 + /// It is a helper function to read an undirected graph from the given input
1.155 + /// file. It gives back an UndirGraphReader object and this object
1.156 + /// can read more maps, labeled nodes, edges, undirected edges and
1.157 + /// attributes.
1.158 + ///
1.159 + /// \warning Do not forget to call the \c run() function.
1.160 + ///
1.161 + /// \param fn The input filename.
1.162 /// \param g The graph.
1.163 - /// \param capacity The capacity map.
1.164 - template<typename Graph, typename CapacityMap>
1.165 - void readUndirGraph(std::istream& is, Graph &g, CapacityMap& capacity) {
1.166 - UndirGraphReader<Graph> reader(is, g);
1.167 - reader.readUndirEdgeMap("capacity", capacity);
1.168 - reader.run();
1.169 + template<typename Graph>
1.170 + UndirGraphReader<Graph> undirGraphReader(const std::string& fn, Graph &g) {
1.171 + return GraphReader<Graph>(fn, g);
1.172 }
1.173
1.174 -
1.175 /// @}
1.176 }
1.177