lemon/lemon_reader.h
changeset 1710 f531c16dd923
parent 1627 3fd1ba6e9872
child 1722 2acb5f9bfa72
equal deleted inserted replaced
5:116adb6cea5e 6:2ac77655d3e6
    34 #include <lemon/error.h>
    34 #include <lemon/error.h>
    35 #include <lemon/graph_utils.h>
    35 #include <lemon/graph_utils.h>
    36 #include <lemon/utility.h>
    36 #include <lemon/utility.h>
    37 #include <lemon/bits/item_reader.h>
    37 #include <lemon/bits/item_reader.h>
    38 
    38 
       
    39 #include <lemon/xy.h>
       
    40 
    39 #include <lemon/concept_check.h>
    41 #include <lemon/concept_check.h>
    40 #include <lemon/concept/maps.h>
    42 #include <lemon/concept/maps.h>
    41 
    43 
    42 namespace lemon {
    44 namespace lemon {
    43 
    45 
    92       bool operator()(const T& p, const T& q) const {
    94       bool operator()(const T& p, const T& q) const {
    93 	return p < q;
    95 	return p < q;
    94       }
    96       }
    95     };
    97     };
    96 
    98 
    97     template <typename M1, typename M2>
    99     template <typename Map>
    98     class WriteComposeMap {
   100     struct Ref { typedef Map& Type; };
       
   101     template <typename Map>
       
   102     struct Arg { typedef Map& Type; };
       
   103 
       
   104     template <typename Graph, typename Map>
       
   105     class ForwardComposeMap {
    99     public:
   106     public:
   100       typedef True NeedCopy;
   107       typedef typename Graph::UndirEdge Key;
       
   108       typedef typename Map::Value Value;
       
   109 
       
   110       ForwardComposeMap(const Graph& _graph, typename Arg<Map>::Type _map) 
       
   111 	: graph(_graph), map(_map) {}
   101       
   112       
   102       typedef typename M2::Key Key;
   113       void set(const Key& key, const Value& val) {
   103       typedef typename M1::Value Value;
   114 	map.set(graph.direct(key, true), val);
   104 
   115       }
   105       WriteComposeMap(typename SmartParameter<M1>::Type _m1, const M2& _m2) 
   116 
   106 	: m1(_m1), m2(_m2) {}
   117     private:
       
   118       typename Ref<Map>::Type map;
       
   119       const Graph& graph;
       
   120     };
       
   121 
       
   122     template <typename Graph, typename Map>
       
   123     ForwardComposeMap<Graph, Map>
       
   124     forwardComposeMap(const Graph& graph, const Map& map) {
       
   125       return ForwardComposeMap<Graph, Map>(graph, map);
       
   126     }
       
   127 
       
   128     template <typename Graph, typename Map>
       
   129     ForwardComposeMap<Graph, Map>
       
   130     forwardComposeMap(const Graph& graph, Map& map) {
       
   131       return ForwardComposeMap<Graph, Map>(graph, map);
       
   132     }
       
   133 
       
   134     template <typename Graph, typename Map>
       
   135     class BackwardComposeMap {
       
   136     public:
       
   137       typedef typename Graph::UndirEdge Key;
       
   138       typedef typename Map::Value Value;
       
   139 
       
   140       BackwardComposeMap(const Graph& _graph, typename Arg<Map>::Type _map) 
       
   141 	: graph(_graph), map(_map) {}
   107       
   142       
   108       void set(const Key& key, const Value& value) {
   143       void set(const Key& key, const Value& val) {
   109 	m1.set(m2[key], value);
   144 	map.set(graph.direct(key, false), val);
   110       }
   145       }
   111 
   146 
   112     private:
   147     private:
   113       
   148       typename Ref<Map>::Type map;
   114       typename SmartReference<M1>::Type m1;
   149       const Graph& graph;
   115       typename SmartConstReference<M2>::Type m2;
   150     };
   116       
   151 
   117     };
   152 
   118 
   153     template <typename Graph, typename Map>
   119     template <typename M1, typename M2>
   154     BackwardComposeMap<Graph, Map>
   120     WriteComposeMap<M1, M2> writeComposeMap(M1& m1, const M2& m2) {
   155     backwardComposeMap(const Graph& graph, const Map& map) {
   121       return WriteComposeMap<M1, M2>(m1, m2);
   156       return BackwardComposeMap<Graph, Map>(graph, map);
   122     }
   157     }
   123 
   158 
   124     template <typename M1, typename M2>
   159     template <typename Graph, typename Map>
   125     WriteComposeMap<M1, M2> writeComposeMap(const M1& m1, const M2& m2) {
   160     BackwardComposeMap<Graph, Map>
   126       return WriteComposeMap<M1, M2>(m1, m2);
   161     backwardComposeMap(const Graph& graph, Map& map) {
   127     }
   162       return BackwardComposeMap<Graph, Map>(graph, map);
   128   
   163     }
       
   164 
       
   165     template <typename Graph, typename Map>
       
   166     struct Ref<ForwardComposeMap<Graph, Map> > { 
       
   167       typedef ForwardComposeMap<Graph, Map> Type;
       
   168     };
       
   169     template <typename Graph, typename Map>
       
   170     struct Arg<ForwardComposeMap<Graph, Map> > { 
       
   171       typedef const ForwardComposeMap<Graph, Map>& Type;
       
   172     };
       
   173 
       
   174     template <typename Graph, typename Map>
       
   175     struct Ref<BackwardComposeMap<Graph, Map> > { 
       
   176       typedef BackwardComposeMap<Graph, Map> Type; 
       
   177     };
       
   178     template <typename Graph, typename Map>
       
   179     struct Arg<BackwardComposeMap<Graph, Map> > { 
       
   180       typedef const BackwardComposeMap<Graph, Map>& Type; 
       
   181     };
       
   182 
       
   183     template <typename Map>
       
   184     struct Ref<XMap<Map> > { 
       
   185       typedef XMap<Map> Type;
       
   186     };
       
   187     template <typename Map>
       
   188     struct Arg<XMap<Map> > { 
       
   189       typedef const XMap<Map>& Type;
       
   190     };
       
   191 
       
   192     template <typename Map>
       
   193     struct Ref<YMap<Map> > { 
       
   194       typedef YMap<Map> Type;
       
   195     };
       
   196     template <typename Map>
       
   197     struct Arg<YMap<Map> > { 
       
   198       typedef const YMap<Map>& Type;
       
   199     };
       
   200 
   129   }
   201   }
   130 
   202 
   131   /// \ingroup io_group
   203   /// \ingroup io_group
   132   /// \brief Lemon Format reader class.
   204   /// \brief Lemon Format reader class.
   133   /// 
   205   /// 
   430       typedef _Reader Reader;
   502       typedef _Reader Reader;
   431       typedef typename Reader::Value Value;
   503       typedef typename Reader::Value Value;
   432       typedef _Map Map;
   504       typedef _Map Map;
   433       typedef std::map<Value, Item, _reader_bits::Less<Value> > Inverse;
   505       typedef std::map<Value, Item, _reader_bits::Less<Value> > Inverse;
   434 
   506 
   435       typename SmartReference<Map>::Type map;
   507       typename _reader_bits::Ref<Map>::Type map;
   436       Reader reader;
   508       Reader reader;
   437       Inverse inverse;
   509       Inverse inverse;
   438 
   510 
   439       MapReaderInverter(typename SmartParameter<Map>::Type _map,
   511       MapReaderInverter(typename _reader_bits::Arg<Map>::Type _map,
   440 			const Reader& _reader) 
   512 			const Reader& _reader) 
   441 	: map(_map), reader(_reader) {}
   513 	: map(_map), reader(_reader) {}
   442 
   514 
   443       virtual ~MapReaderInverter() {}
   515       virtual ~MapReaderInverter() {}
   444 
   516 
   524       typedef _Map Map;
   596       typedef _Map Map;
   525       typedef _Reader Reader;
   597       typedef _Reader Reader;
   526       typedef typename Reader::Value Value;
   598       typedef typename Reader::Value Value;
   527       typedef _Item Item;
   599       typedef _Item Item;
   528       
   600       
   529       typename SmartReference<Map>::Type map;
   601       typename _reader_bits::Ref<Map>::Type map;
   530       Reader reader;
   602       Reader reader;
   531 
   603 
   532       MapReader(typename SmartParameter<Map>::Type _map, 
   604       MapReader(typename _reader_bits::Arg<Map>::Type _map, 
   533 		const Reader& _reader) 
   605 		const Reader& _reader) 
   534 	: map(_map), reader(_reader) {}
   606 	: map(_map), reader(_reader) {}
   535 
   607 
   536       virtual ~MapReader() {}
   608       virtual ~MapReader() {}
   537 
   609 
   657     /// Constructor for NodeSetReader. It creates the NodeSetReader and
   729     /// Constructor for NodeSetReader. It creates the NodeSetReader and
   658     /// attach it into the given LemonReader. The nodeset reader will
   730     /// attach it into the given LemonReader. The nodeset reader will
   659     /// add the readed nodes to the given Graph. The reader will read
   731     /// add the readed nodes to the given Graph. The reader will read
   660     /// the section when the \c section_id and the \c _id are the same. 
   732     /// the section when the \c section_id and the \c _id are the same. 
   661     NodeSetReader(LemonReader& _reader, 
   733     NodeSetReader(LemonReader& _reader, 
   662 		  typename SmartParameter<Graph>::Type _graph, 
   734 		  Graph& _graph, 
   663 		  const std::string& _id = std::string(),
   735 		  const std::string& _id = std::string(),
   664 		  const DefaultSkipper& _skipper = DefaultSkipper()) 
   736 		  const DefaultSkipper& _skipper = DefaultSkipper()) 
   665       : Parent(_reader), graph(_graph), id(_id), skipper(_skipper) {} 
   737       : Parent(_reader), graph(_graph), id(_id), skipper(_skipper) {} 
   666 
   738 
   667 
   739 
   686     /// Add a new node map reader command for the reader.
   758     /// Add a new node map reader command for the reader.
   687     template <typename Map>
   759     template <typename Map>
   688     NodeSetReader& readNodeMap(std::string name, Map& map) {
   760     NodeSetReader& readNodeMap(std::string name, Map& map) {
   689       return _readMap<
   761       return _readMap<
   690 	typename Traits::template Reader<typename Map::Value>, Map,
   762 	typename Traits::template Reader<typename Map::Value>, Map,
   691 	typename SmartParameter<Map>::Type>(name, map);
   763 	typename _reader_bits::Arg<Map>::Type>(name, map);
   692     }
   764     }
   693 
   765 
   694     template <typename Map>
   766     template <typename Map>
   695     NodeSetReader& readNodeMap(std::string name, const Map& map) {
   767     NodeSetReader& readNodeMap(std::string name, const Map& map) {
   696       return _readMap<
   768       return _readMap<
   697 	typename Traits::template Reader<typename Map::Value>, Map,
   769 	typename Traits::template Reader<typename Map::Value>, Map,
   698 	typename SmartParameter<Map>::Type>(name, map);
   770 	typename _reader_bits::Arg<Map>::Type>(name, map);
   699     }
   771     }
   700 
   772 
   701     /// \brief Add a new node map reader command for the reader.
   773     /// \brief Add a new node map reader command for the reader.
   702     ///
   774     ///
   703     /// Add a new node map reader command for the reader.
   775     /// Add a new node map reader command for the reader.
   704     template <typename Reader, typename Map>
   776     template <typename Reader, typename Map>
   705     NodeSetReader& readNodeMap(std::string name, Map& map, 
   777     NodeSetReader& readNodeMap(std::string name, Map& map, 
   706 			       const Reader& reader = Reader()) {
   778 			       const Reader& reader = Reader()) {
   707       return _readMap<Reader, Map, typename SmartParameter<Map>::Type>
   779       return _readMap<Reader, Map, typename _reader_bits::Arg<Map>::Type>
   708 	(name, map, reader);
   780 	(name, map, reader);
   709     }
   781     }
   710 
   782 
   711     template <typename Reader, typename Map>
   783     template <typename Reader, typename Map>
   712     NodeSetReader& readNodeMap(std::string name, const Map& map, 
   784     NodeSetReader& readNodeMap(std::string name, const Map& map, 
   713 			       const Reader& reader = Reader()) {
   785 			       const Reader& reader = Reader()) {
   714       return _readMap<Reader, Map, typename SmartParameter<Map>::Type>
   786       return _readMap<Reader, Map, typename _reader_bits::Arg<Map>::Type>
   715 	(name, map, reader);
   787 	(name, map, reader);
   716     }
   788     }
   717 
   789 
   718   private:
   790   private:
   719 
   791 
   815   private:
   887   private:
   816 
   888 
   817     typedef std::map<std::string, ReaderBase<Node>*> MapReaders;
   889     typedef std::map<std::string, ReaderBase<Node>*> MapReaders;
   818     MapReaders readers;
   890     MapReaders readers;
   819    
   891    
   820     typename SmartReference<Graph>::Type graph;   
   892     Graph& graph;   
   821     std::string id;
   893     std::string id;
   822     SkipReader<Node, DefaultSkipper> skipper;
   894     SkipReader<Node, DefaultSkipper> skipper;
   823 
   895 
   824     std::auto_ptr<InverterBase<Node> > inverter;
   896     std::auto_ptr<InverterBase<Node> > inverter;
   825   };
   897   };
   865     /// node id reader to read the source and target nodes of the edges.
   937     /// node id reader to read the source and target nodes of the edges.
   866     /// The reader will read the section only if the \c _id and the 
   938     /// The reader will read the section only if the \c _id and the 
   867     /// \c edgset_id are the same. 
   939     /// \c edgset_id are the same. 
   868     template <typename NodeIdReader>
   940     template <typename NodeIdReader>
   869     EdgeSetReader(LemonReader& _reader, 
   941     EdgeSetReader(LemonReader& _reader, 
   870 		  typename SmartParameter<Graph>::Type _graph, 
   942 		  Graph& _graph, 
   871 		  const NodeIdReader& _nodeIdReader, 
   943 		  const NodeIdReader& _nodeIdReader, 
   872 		  const std::string& _id = std::string(),
   944 		  const std::string& _id = std::string(),
   873 		  const DefaultSkipper& _skipper = DefaultSkipper()) 
   945 		  const DefaultSkipper& _skipper = DefaultSkipper()) 
   874       : Parent(_reader), graph(_graph), id(_id), skipper(_skipper) {
   946       : Parent(_reader), graph(_graph), id(_id), skipper(_skipper) {
   875       checkConcept<_reader_bits::ItemIdReader<Node>, NodeIdReader>();
   947       checkConcept<_reader_bits::ItemIdReader<Node>, NodeIdReader>();
   896     /// Add a new edge map reader command for the reader.
   968     /// Add a new edge map reader command for the reader.
   897     template <typename Map>
   969     template <typename Map>
   898     EdgeSetReader& readEdgeMap(std::string name, Map& map) {
   970     EdgeSetReader& readEdgeMap(std::string name, Map& map) {
   899       return _readMap<
   971       return _readMap<
   900 	typename Traits::template Reader<typename Map::Value>, Map,
   972 	typename Traits::template Reader<typename Map::Value>, Map,
   901 	typename SmartParameter<Map>::Type>(name, map);
   973 	typename _reader_bits::Arg<Map>::Type>(name, map);
   902     }
   974     }
   903 
   975 
   904     template <typename Map>
   976     template <typename Map>
   905     EdgeSetReader& readEdgeMap(std::string name, const Map& map) {
   977     EdgeSetReader& readEdgeMap(std::string name, const Map& map) {
   906       return _readMap<
   978       return _readMap<
   907 	typename Traits::template Reader<typename Map::Value>, Map,
   979 	typename Traits::template Reader<typename Map::Value>, Map,
   908 	typename SmartParameter<Map>::Type>(name, map);
   980 	typename _reader_bits::Arg<Map>::Type>(name, map);
   909     }
   981     }
   910 
   982 
   911     /// \brief Add a new edge map reader command for the reader.
   983     /// \brief Add a new edge map reader command for the reader.
   912     ///
   984     ///
   913     /// Add a new edge map reader command for the reader.
   985     /// Add a new edge map reader command for the reader.
   914     template <typename Reader, typename Map>
   986     template <typename Reader, typename Map>
   915     EdgeSetReader& readEdgeMap(std::string name, Map& map, 
   987     EdgeSetReader& readEdgeMap(std::string name, Map& map, 
   916 			   const Reader& reader = Reader()) {
   988 			   const Reader& reader = Reader()) {
   917       return _readMap<Reader, Map,
   989       return _readMap<Reader, Map,
   918 	typename SmartParameter<Map>::Type>(name, map, reader);
   990 	typename _reader_bits::Arg<Map>::Type>(name, map, reader);
   919     }
   991     }
   920 
   992 
   921     template <typename Reader, typename Map>
   993     template <typename Reader, typename Map>
   922     EdgeSetReader& readEdgeMap(std::string name, const Map& map, 
   994     EdgeSetReader& readEdgeMap(std::string name, const Map& map, 
   923 			       const Reader& reader = Reader()) {
   995 			       const Reader& reader = Reader()) {
   924       return _readMap<Reader, Map,
   996       return _readMap<Reader, Map,
   925 	typename SmartParameter<Map>::Type>(name, map, reader);
   997 	typename _reader_bits::Arg<Map>::Type>(name, map, reader);
   926     }
   998     }
   927 
   999 
   928   private:
  1000   private:
   929 
  1001 
   930     template <typename Reader, typename Map, typename MapParameter>
  1002     template <typename Reader, typename Map, typename MapParameter>
  1030   private:
  1102   private:
  1031 
  1103 
  1032     typedef std::map<std::string, ReaderBase<Edge>*> MapReaders;
  1104     typedef std::map<std::string, ReaderBase<Edge>*> MapReaders;
  1033     MapReaders readers;
  1105     MapReaders readers;
  1034    
  1106    
  1035     typename SmartReference<Graph>::Type graph;   
  1107     Graph& graph;   
  1036     std::string id;
  1108     std::string id;
  1037     SkipReader<Edge, DefaultSkipper> skipper;
  1109     SkipReader<Edge, DefaultSkipper> skipper;
  1038 
  1110 
  1039     std::auto_ptr<InverterBase<Edge> > inverter;
  1111     std::auto_ptr<InverterBase<Edge> > inverter;
  1040     std::auto_ptr<IdReaderBase<Node> > nodeIdReader;
  1112     std::auto_ptr<IdReaderBase<Node> > nodeIdReader;
  1087     /// will use the given node id reader to read the source and target 
  1159     /// will use the given node id reader to read the source and target 
  1088     /// nodes of the edges. The reader will read the section only if the 
  1160     /// nodes of the edges. The reader will read the section only if the 
  1089     /// \c _id and the \c undiredgset_id are the same. 
  1161     /// \c _id and the \c undiredgset_id are the same. 
  1090     template <typename NodeIdReader>
  1162     template <typename NodeIdReader>
  1091     UndirEdgeSetReader(LemonReader& _reader, 
  1163     UndirEdgeSetReader(LemonReader& _reader, 
  1092 		       typename SmartParameter<Graph>::Type _graph, 
  1164 		       Graph& _graph, 
  1093 		       const NodeIdReader& _nodeIdReader, 
  1165 		       const NodeIdReader& _nodeIdReader, 
  1094 		       const std::string& _id = std::string(),
  1166 		       const std::string& _id = std::string(),
  1095 		       const DefaultSkipper& _skipper = DefaultSkipper()) 
  1167 		       const DefaultSkipper& _skipper = DefaultSkipper()) 
  1096       : Parent(_reader), graph(_graph), id(_id), skipper(_skipper) {
  1168       : Parent(_reader), graph(_graph), id(_id), skipper(_skipper) {
  1097       checkConcept<_reader_bits::ItemIdReader<Node>, NodeIdReader>();
  1169       checkConcept<_reader_bits::ItemIdReader<Node>, NodeIdReader>();
  1118     /// Add a new edge undirected map reader command for the reader.
  1190     /// Add a new edge undirected map reader command for the reader.
  1119     template <typename Map>
  1191     template <typename Map>
  1120     UndirEdgeSetReader& readUndirEdgeMap(std::string name, Map& map) {
  1192     UndirEdgeSetReader& readUndirEdgeMap(std::string name, Map& map) {
  1121       return _readMap<
  1193       return _readMap<
  1122 	typename Traits::template Reader<typename Map::Value>, Map, 
  1194 	typename Traits::template Reader<typename Map::Value>, Map, 
  1123 	typename SmartParameter<Map>::Type>(name, map);
  1195 	typename _reader_bits::Arg<Map>::Type>(name, map);
  1124     }
  1196     }
  1125 
  1197 
  1126     template <typename Map>
  1198     template <typename Map>
  1127     UndirEdgeSetReader& readUndirEdgeMap(std::string name, const Map& map) {
  1199     UndirEdgeSetReader& readUndirEdgeMap(std::string name, const Map& map) {
  1128       return _readMap<
  1200       return _readMap<
  1129 	typename Traits::template Reader<typename Map::Value>, Map, 
  1201 	typename Traits::template Reader<typename Map::Value>, Map, 
  1130 	typename SmartParameter<Map>::Type>(name, map);
  1202 	typename _reader_bits::Arg<Map>::Type>(name, map);
  1131     }
  1203     }
  1132 
  1204 
  1133     /// \brief Add a new undirected edge map reader command for the reader.
  1205     /// \brief Add a new undirected edge map reader command for the reader.
  1134     ///
  1206     ///
  1135     /// Add a new edge undirected map reader command for the reader.
  1207     /// Add a new edge undirected map reader command for the reader.
  1136     template <typename Reader, typename Map>
  1208     template <typename Reader, typename Map>
  1137     UndirEdgeSetReader& readUndirEdgeMap(std::string name, Map& map, 
  1209     UndirEdgeSetReader& readUndirEdgeMap(std::string name, Map& map, 
  1138 					 const Reader& reader = Reader()) {
  1210 					 const Reader& reader = Reader()) {
  1139       return _readMap<Reader, Map, typename SmartParameter<Map>::Type>
  1211       return _readMap<Reader, Map, typename _reader_bits::Arg<Map>::Type>
  1140 	(name, map, reader);
  1212 	(name, map, reader);
  1141     }
  1213     }
  1142 
  1214 
  1143     template <typename Reader, typename Map>
  1215     template <typename Reader, typename Map>
  1144     UndirEdgeSetReader& readUndirEdgeMap(std::string name, const Map& map, 
  1216     UndirEdgeSetReader& readUndirEdgeMap(std::string name, const Map& map, 
  1145 					 const Reader& reader = Reader()) {
  1217 					 const Reader& reader = Reader()) {
  1146       return _readMap<Reader, Map, typename SmartParameter<Map>::Type >
  1218       return _readMap<Reader, Map, typename _reader_bits::Arg<Map>::Type >
  1147 	(name, map, reader);
  1219 	(name, map, reader);
  1148     }
  1220     }
  1149 
  1221 
  1150   private:
  1222   private:
  1151 
  1223 
  1187     /// Add a new directed edge map reader command for the reader.
  1259     /// Add a new directed edge map reader command for the reader.
  1188     template <typename Map>
  1260     template <typename Map>
  1189     UndirEdgeSetReader& readEdgeMap(std::string name, Map& map) {
  1261     UndirEdgeSetReader& readEdgeMap(std::string name, Map& map) {
  1190       return _readDirMap<
  1262       return _readDirMap<
  1191 	typename Traits::template Reader<typename Map::Value>, Map,
  1263 	typename Traits::template Reader<typename Map::Value>, Map,
  1192 	typename SmartParameter<Map>::Type>(name, map);
  1264 	typename _reader_bits::Arg<Map>::Type>(name, map);
  1193     }
  1265     }
  1194 
  1266 
  1195     template <typename Map>
  1267     template <typename Map>
  1196     UndirEdgeSetReader& readEdgeMap(std::string name, const Map& map) {
  1268     UndirEdgeSetReader& readEdgeMap(std::string name, const Map& map) {
  1197       return _readDirMap<
  1269       return _readDirMap<
  1198 	typename Traits::template Reader<typename Map::Value>, Map,
  1270 	typename Traits::template Reader<typename Map::Value>, Map,
  1199 	typename SmartParameter<Map>::Type>(name, map);
  1271 	typename _reader_bits::Arg<Map>::Type>(name, map);
  1200     }
  1272     }
  1201 
  1273 
  1202     /// \brief Add a new directed edge map reader command for the reader.
  1274     /// \brief Add a new directed edge map reader command for the reader.
  1203     ///
  1275     ///
  1204     /// Add a new directed edge map reader command for the reader.
  1276     /// Add a new directed edge map reader command for the reader.
  1205     template <typename Reader, typename Map>
  1277     template <typename Reader, typename Map>
  1206     UndirEdgeSetReader& readEdgeMap(std::string name, Map& map, 
  1278     UndirEdgeSetReader& readEdgeMap(std::string name, Map& map, 
  1207 				    const Reader& reader = Reader()) {
  1279 				    const Reader& reader = Reader()) {
  1208       return _readDirMap<Reader, Map, typename SmartParameter<Map>::Type>
  1280       return _readDirMap<Reader, Map, typename _reader_bits::Arg<Map>::Type>
  1209 	(name, map, reader);
  1281 	(name, map, reader);
  1210     }
  1282     }
  1211 
  1283 
  1212     template <typename Reader, typename Map>
  1284     template <typename Reader, typename Map>
  1213     UndirEdgeSetReader& readEdgeMap(std::string name, const Map& map, 
  1285     UndirEdgeSetReader& readEdgeMap(std::string name, const Map& map, 
  1214 				    const Reader& reader = Reader()) {
  1286 				    const Reader& reader = Reader()) {
  1215       return _readDirMap<Reader, Map, typename SmartParameter<Map>::Type>
  1287       return _readDirMap<Reader, Map, typename _reader_bits::Arg<Map>::Type>
  1216 	(name, map, reader);
  1288 	(name, map, reader);
  1217     }
  1289     }
  1218 
  1290 
  1219   private:
  1291   private:
  1220 
  1292 
  1222     UndirEdgeSetReader& _readDirMap(std::string name, MapParameter map,
  1294     UndirEdgeSetReader& _readDirMap(std::string name, MapParameter map,
  1223 				    const Reader& reader = Reader()) { 
  1295 				    const Reader& reader = Reader()) { 
  1224       checkConcept<_reader_bits::ItemReader<typename Map::Value>, Reader>();
  1296       checkConcept<_reader_bits::ItemReader<typename Map::Value>, Reader>();
  1225       checkConcept<concept::WriteMap<Edge, typename Map::Value>, Map>();
  1297       checkConcept<concept::WriteMap<Edge, typename Map::Value>, Map>();
  1226       readMap("+" + name, 
  1298       readMap("+" + name, 
  1227 	      _reader_bits::writeComposeMap(map, forwardMap(graph)), reader);
  1299 	      _reader_bits::forwardComposeMap(graph, map), reader);
  1228       readMap("-" + name, 
  1300       readMap("-" + name, 
  1229 	      _reader_bits::writeComposeMap(map, backwardMap(graph)), reader);
  1301 	      _reader_bits::backwardComposeMap(graph, map), reader);
  1230       return *this;      
  1302       return *this;      
  1231     }
  1303     }
  1232 
  1304 
  1233   public:
  1305   public:
  1234 
  1306 
  1334   private:
  1406   private:
  1335 
  1407 
  1336     typedef std::map<std::string, ReaderBase<UndirEdge>*> MapReaders;
  1408     typedef std::map<std::string, ReaderBase<UndirEdge>*> MapReaders;
  1337     MapReaders readers;
  1409     MapReaders readers;
  1338    
  1410    
  1339     typename SmartReference<Graph>::Type graph;   
  1411     Graph& graph;   
  1340     std::string id;
  1412     std::string id;
  1341     SkipReader<UndirEdge, DefaultSkipper> skipper;
  1413     SkipReader<UndirEdge, DefaultSkipper> skipper;
  1342 
  1414 
  1343     std::auto_ptr<InverterBase<UndirEdge> > inverter;
  1415     std::auto_ptr<InverterBase<UndirEdge> > inverter;
  1344     std::auto_ptr<IdReaderBase<Node> > nodeIdReader;
  1416     std::auto_ptr<IdReaderBase<Node> > nodeIdReader;