lemon/graph_reader.h
changeset 1537 0d9f1a71be27
parent 1476 182da222fceb
child 1540 7d028a73d7f2
equal deleted inserted replaced
1:28797f5c6196 2:3b272d0d07e0
    31   /// \addtogroup io_group
    31   /// \addtogroup io_group
    32   /// @{
    32   /// @{
    33 
    33 
    34   /// \brief The graph reader class.
    34   /// \brief The graph reader class.
    35   ///
    35   ///
       
    36   /// The \c GraphReader class provides the graph input. 
       
    37   /// Before you read this documentation it might be useful to read the general
       
    38   /// description of  \ref graph-io-page "Graph Input-Output".
       
    39   /// If you don't need very sophisticated
       
    40   /// behaviour then you can use the versions of the public function
       
    41   /// \ref readGraph() to read a graph (or a max flow instance etc).
       
    42   ///
    36   /// The given file format may contain several maps and labeled nodes or 
    43   /// The given file format may contain several maps and labeled nodes or 
    37   /// edges.
    44   /// edges.
    38   ///
    45   ///
    39   /// If you read a graph you need not read all the maps and items just those
    46   /// If you read a graph you need not read all the maps and items just those
    40   /// that you need. The interface of the \c GraphReader is very similar to
    47   /// that you need. The interface of the \c GraphReader is very similar to
   330     EdgeReader<Graph> edge_reader;
   337     EdgeReader<Graph> edge_reader;
   331     
   338     
   332     AttributeReader<ReaderTraits> attribute_reader;
   339     AttributeReader<ReaderTraits> attribute_reader;
   333   };
   340   };
   334 
   341 
   335   /// \brief Read a graph from the input.
   342 
   336   ///
   343   ///\anchor readGraph()
   337   /// Read a graph from the input.
   344   ///
       
   345   /// \brief Read a graph from an input stream.
       
   346   ///
       
   347   /// Read a graph from an input stream.
       
   348   /// \param is The input stream.
       
   349   /// \param g The graph.
       
   350   template<typename Graph>
       
   351   void readGraph(std::istream& is, Graph &g) {
       
   352     GraphReader<Graph> reader(is, g);
       
   353     reader.run();
       
   354   }
       
   355 
       
   356   /// \brief Read a capacitated graph instance from an input stream.
       
   357   /// 
       
   358   /// Read a capacitated graph (graph+capacity on the
       
   359   /// edges) from an input stream.
       
   360   /// \param is The input stream.
       
   361   /// \param g The graph.
       
   362   /// \param capacity The capacity map.
       
   363   template<typename Graph, typename CapacityMap>
       
   364   void readGraph(std::istream& is, Graph &g, CapacityMap& capacity) {
       
   365     GraphReader<Graph> reader(is, g);
       
   366     reader.readEdgeMap("capacity", capacity);
       
   367     reader.run();
       
   368   }
       
   369 
       
   370   /// \brief Read a shortest path instance from an input stream.
       
   371   /// 
       
   372   /// Read a shortest path instance (graph+capacity on the
       
   373   /// edges+designated source) from an input stream.
       
   374   /// \param is The input stream.
       
   375   /// \param g The graph.
       
   376   /// \param capacity The capacity map.
       
   377   /// \param s The source node.
       
   378   template<typename Graph, typename CapacityMap>
       
   379   void readGraph(std::istream& is, Graph &g, CapacityMap& capacity, 
       
   380 		  typename Graph::Node &s) {
       
   381     GraphReader<Graph> reader(is, g);
       
   382     reader.readEdgeMap("capacity", capacity);
       
   383     reader.readNode("source", s);
       
   384     reader.run();
       
   385   }
       
   386 
       
   387 
       
   388 
       
   389   /// \brief Read a max flow instance from an input stream.
       
   390   ///
       
   391   /// Read a max flow instance (graph+capacity on the
       
   392   /// edges+designated source and target) from an input stream.
       
   393   ///
       
   394   /// \param is The input stream.
       
   395   /// \param g The graph.
       
   396   /// \param capacity The capacity map.
       
   397   /// \param s The source node.
       
   398   /// \param t The target node.
       
   399   template<typename Graph, typename CapacityMap>
       
   400   void readGraph(std::istream& is, Graph &g, CapacityMap& capacity, 
       
   401 		  typename Graph::Node &s, typename Graph::Node &t) {
       
   402     GraphReader<Graph> reader(is, g);
       
   403     reader.readEdgeMap("capacity", capacity);
       
   404     reader.readNode("source", s);
       
   405     reader.readNode("target", t);
       
   406     reader.run();
       
   407   }
       
   408 
       
   409   /// \brief Read a min cost flow instance from an input stream.
       
   410   ///
       
   411   /// Read a min cost flow instance (graph+capacity on the edges+cost
       
   412   /// function on the edges+designated source and target) from an input stream.
       
   413   ///
   338   /// \param is The input stream.
   414   /// \param is The input stream.
   339   /// \param g The graph.
   415   /// \param g The graph.
   340   /// \param capacity The capacity map.
   416   /// \param capacity The capacity map.
   341   /// \param s The source node.
   417   /// \param s The source node.
   342   /// \param t The target node.
   418   /// \param t The target node.
   351     reader.readNode("source", s);
   427     reader.readNode("source", s);
   352     reader.readNode("target", t);
   428     reader.readNode("target", t);
   353     reader.run();
   429     reader.run();
   354   }
   430   }
   355 
   431 
   356   /// \brief Read a graph from the input.
       
   357   ///
       
   358   /// Read a graph from the input.
       
   359   /// \param is The input stream.
       
   360   /// \param g The graph.
       
   361   /// \param capacity The capacity map.
       
   362   /// \param s The source node.
       
   363   /// \param t The target node.
       
   364   template<typename Graph, typename CapacityMap>
       
   365   void readGraph(std::istream& is, Graph &g, CapacityMap& capacity, 
       
   366 		  typename Graph::Node &s, typename Graph::Node &t) {
       
   367     GraphReader<Graph> reader(is, g);
       
   368     reader.readEdgeMap("capacity", capacity);
       
   369     reader.readNode("source", s);
       
   370     reader.readNode("target", t);
       
   371     reader.run();
       
   372   }
       
   373 
       
   374   /// \brief Read a graph from the input.
       
   375   ///
       
   376   /// Read a graph from the input.
       
   377   /// \param is The input stream.
       
   378   /// \param g The graph.
       
   379   /// \param capacity The capacity map.
       
   380   /// \param s The source node.
       
   381   template<typename Graph, typename CapacityMap>
       
   382   void readGraph(std::istream& is, Graph &g, CapacityMap& capacity, 
       
   383 		  typename Graph::Node &s) {
       
   384     GraphReader<Graph> reader(is, g);
       
   385     reader.readEdgeMap("capacity", capacity);
       
   386     reader.readNode("source", s);
       
   387     reader.run();
       
   388   }
       
   389 
       
   390   /// \brief Read a graph from the input.
       
   391   ///
       
   392   /// Read a graph from the input.
       
   393   /// \param is The input stream.
       
   394   /// \param g The graph.
       
   395   /// \param capacity The capacity map.
       
   396   template<typename Graph, typename CapacityMap>
       
   397   void readGraph(std::istream& is, Graph &g, CapacityMap& capacity) {
       
   398     GraphReader<Graph> reader(is, g);
       
   399     reader.readEdgeMap("capacity", capacity);
       
   400     reader.run();
       
   401   }
       
   402 
       
   403   /// \brief Read a graph from the input.
       
   404   ///
       
   405   /// Read a graph from the input.
       
   406   /// \param is The input stream.
       
   407   /// \param g The graph.
       
   408   template<typename Graph>
       
   409   void readGraph(std::istream& is, Graph &g) {
       
   410     GraphReader<Graph> reader(is, g);
       
   411     reader.run();
       
   412   }
       
   413 
   432 
   414   /// \brief The undir graph reader class.
   433   /// \brief The undir graph reader class.
   415   ///
   434   ///
   416   /// The given file format may contain several maps and labeled nodes or 
   435   /// The given file format may contain several maps and labeled nodes or 
   417   /// edges.
   436   /// edges.
   777     UndirEdgeReader<Graph> undir_edge_reader;
   796     UndirEdgeReader<Graph> undir_edge_reader;
   778     
   797     
   779     AttributeReader<ReaderTraits> attribute_reader;
   798     AttributeReader<ReaderTraits> attribute_reader;
   780   };
   799   };
   781 
   800 
   782   /// \brief Read an undir graph from the input.
   801   /// \brief Read an undirected graph from an input stream.
   783   ///
   802   ///
   784   /// Read an undir graph from the input.
   803   /// Read an undirected graph from an input stream.
       
   804   /// \param is The input stream.
       
   805   /// \param g The graph.
       
   806   template<typename Graph>
       
   807   void readUndirGraph(std::istream& is, Graph &g) {
       
   808     UndirGraphReader<Graph> reader(is, g);
       
   809     reader.run();
       
   810   }
       
   811 
       
   812   /// \brief Read an undirected multigraph (undirected graph + capacity
       
   813   /// map on the edges) from an input stream.
       
   814   ///
       
   815   /// Read an undirected multigraph (undirected graph + capacity
       
   816   /// map on the edges) from an input stream.
   785   /// \param is The input stream.
   817   /// \param is The input stream.
   786   /// \param g The graph.
   818   /// \param g The graph.
   787   /// \param capacity The capacity map.
   819   /// \param capacity The capacity map.
   788   template<typename Graph, typename CapacityMap>
   820   template<typename Graph, typename CapacityMap>
   789   void readUndirGraph(std::istream& is, Graph &g, CapacityMap& capacity) {
   821   void readUndirGraph(std::istream& is, Graph &g, CapacityMap& capacity) {
   790     UndirGraphReader<Graph> reader(is, g);
   822     UndirGraphReader<Graph> reader(is, g);
   791     reader.readUndirEdgeMap("capacity", capacity);
   823     reader.readUndirEdgeMap("capacity", capacity);
   792     reader.run();
   824     reader.run();
   793   }
   825   }
   794 
   826 
   795   /// \brief Read an undir graph from the input.
       
   796   ///
       
   797   /// Read an undir graph from the input.
       
   798   /// \param is The input stream.
       
   799   /// \param g The graph.
       
   800   template<typename Graph>
       
   801   void readUndirGraph(std::istream& is, Graph &g) {
       
   802     UndirGraphReader<Graph> reader(is, g);
       
   803     reader.run();
       
   804   }
       
   805 
   827 
   806   /// @}
   828   /// @}
   807 }
   829 }
   808 
   830 
   809 #endif
   831 #endif