lemon/lgf_writer.h
changeset 1029 374a9519986b
parent 1024 b84e68af8248
child 1030 4936be66d2f5
equal deleted inserted replaced
34:28bd1197eef9 35:78a60dc7dae2
  1627   ///
  1627   ///
  1628   /// It can be used almost the same way as \c GraphWriter, but it
  1628   /// It can be used almost the same way as \c GraphWriter, but it
  1629   /// reads the red and blue nodes from separate sections, and these
  1629   /// reads the red and blue nodes from separate sections, and these
  1630   /// sections can contain different set of maps.
  1630   /// sections can contain different set of maps.
  1631   ///
  1631   ///
  1632   /// The red and blue maps are written to the corresponding
  1632   /// The red and blue node maps are written to the corresponding
  1633   /// sections. The node maps are written to both of these sections
  1633   /// sections. The node maps are written to both of these sections
  1634   /// with the same map name.
  1634   /// with the same map name.
  1635   template <typename BGR>
  1635   template <typename BGR>
  1636   class BpGraphWriter {
  1636   class BpGraphWriter {
  1637   public:
  1637   public:
  1803         new _writer_bits::MapStorage<Node, Map, Converter>(map, converter);
  1803         new _writer_bits::MapStorage<Node, Map, Converter>(map, converter);
  1804       _blue_maps.push_back(std::make_pair(caption, blue_storage));
  1804       _blue_maps.push_back(std::make_pair(caption, blue_storage));
  1805       return *this;
  1805       return *this;
  1806     }
  1806     }
  1807 
  1807 
  1808     /// \brief Red map writing rule
  1808     /// \brief Red node map writing rule
  1809     ///
  1809     ///
  1810     /// Add a red map writing rule to the writer.
  1810     /// Add a red node map writing rule to the writer.
  1811     template <typename Map>
  1811     template <typename Map>
  1812     BpGraphWriter& redMap(const std::string& caption, const Map& map) {
  1812     BpGraphWriter& redNodeMap(const std::string& caption, const Map& map) {
  1813       checkConcept<concepts::ReadMap<Node, typename Map::Value>, Map>();
  1813       checkConcept<concepts::ReadMap<Node, typename Map::Value>, Map>();
  1814       _writer_bits::MapStorageBase<Node>* storage =
  1814       _writer_bits::MapStorageBase<Node>* storage =
  1815         new _writer_bits::MapStorage<Node, Map>(map);
  1815         new _writer_bits::MapStorage<Node, Map>(map);
  1816       _red_maps.push_back(std::make_pair(caption, storage));
  1816       _red_maps.push_back(std::make_pair(caption, storage));
  1817       return *this;
  1817       return *this;
  1818     }
  1818     }
  1819 
  1819 
  1820     /// \brief Red map writing rule
  1820     /// \brief Red node map writing rule
  1821     ///
  1821     ///
  1822     /// Add a red map writing rule with specialized converter to the
  1822     /// Add a red node map writing rule with specialized converter to the
  1823     /// writer.
  1823     /// writer.
  1824     template <typename Map, typename Converter>
  1824     template <typename Map, typename Converter>
  1825     BpGraphWriter& redMap(const std::string& caption, const Map& map,
  1825     BpGraphWriter& redNodeMap(const std::string& caption, const Map& map,
  1826                           const Converter& converter = Converter()) {
  1826                               const Converter& converter = Converter()) {
  1827       checkConcept<concepts::ReadMap<Node, typename Map::Value>, Map>();
  1827       checkConcept<concepts::ReadMap<Node, typename Map::Value>, Map>();
  1828       _writer_bits::MapStorageBase<Node>* storage =
  1828       _writer_bits::MapStorageBase<Node>* storage =
  1829         new _writer_bits::MapStorage<Node, Map, Converter>(map, converter);
  1829         new _writer_bits::MapStorage<Node, Map, Converter>(map, converter);
  1830       _red_maps.push_back(std::make_pair(caption, storage));
  1830       _red_maps.push_back(std::make_pair(caption, storage));
  1831       return *this;
  1831       return *this;
  1832     }
  1832     }
  1833 
  1833 
  1834     /// \brief Blue map writing rule
  1834     /// \brief Blue node map writing rule
  1835     ///
  1835     ///
  1836     /// Add a blue map writing rule to the writer.
  1836     /// Add a blue node map writing rule to the writer.
  1837     template <typename Map>
  1837     template <typename Map>
  1838     BpGraphWriter& blueMap(const std::string& caption, const Map& map) {
  1838     BpGraphWriter& blueNodeMap(const std::string& caption, const Map& map) {
  1839       checkConcept<concepts::ReadMap<Node, typename Map::Value>, Map>();
  1839       checkConcept<concepts::ReadMap<Node, typename Map::Value>, Map>();
  1840       _writer_bits::MapStorageBase<Node>* storage =
  1840       _writer_bits::MapStorageBase<Node>* storage =
  1841         new _writer_bits::MapStorage<Node, Map>(map);
  1841         new _writer_bits::MapStorage<Node, Map>(map);
  1842       _blue_maps.push_back(std::make_pair(caption, storage));
  1842       _blue_maps.push_back(std::make_pair(caption, storage));
  1843       return *this;
  1843       return *this;
  1844     }
  1844     }
  1845 
  1845 
  1846     /// \brief Blue map writing rule
  1846     /// \brief Blue node map writing rule
  1847     ///
  1847     ///
  1848     /// Add a blue map writing rule with specialized converter to the
  1848     /// Add a blue node map writing rule with specialized converter to the
  1849     /// writer.
  1849     /// writer.
  1850     template <typename Map, typename Converter>
  1850     template <typename Map, typename Converter>
  1851     BpGraphWriter& blueMap(const std::string& caption, const Map& map,
  1851     BpGraphWriter& blueNodeMap(const std::string& caption, const Map& map,
  1852                            const Converter& converter = Converter()) {
  1852                                const Converter& converter = Converter()) {
  1853       checkConcept<concepts::ReadMap<Node, typename Map::Value>, Map>();
  1853       checkConcept<concepts::ReadMap<Node, typename Map::Value>, Map>();
  1854       _writer_bits::MapStorageBase<Node>* storage =
  1854       _writer_bits::MapStorageBase<Node>* storage =
  1855         new _writer_bits::MapStorage<Node, Map, Converter>(map, converter);
  1855         new _writer_bits::MapStorage<Node, Map, Converter>(map, converter);
  1856       _blue_maps.push_back(std::make_pair(caption, storage));
  1856       _blue_maps.push_back(std::make_pair(caption, storage));
  1857       return *this;
  1857       return *this;
  2056         _writer_bits::writeToken(*_os, it->first) << '\t';
  2056         _writer_bits::writeToken(*_os, it->first) << '\t';
  2057       }
  2057       }
  2058       *_os << std::endl;
  2058       *_os << std::endl;
  2059 
  2059 
  2060       std::vector<Node> nodes;
  2060       std::vector<Node> nodes;
  2061       for (RedIt n(_graph); n != INVALID; ++n) {
  2061       for (RedNodeIt n(_graph); n != INVALID; ++n) {
  2062         nodes.push_back(n);
  2062         nodes.push_back(n);
  2063       }
  2063       }
  2064 
  2064 
  2065       if (label == 0) {
  2065       if (label == 0) {
  2066         IdMap<BGR, Node> id_map(_graph);
  2066         IdMap<BGR, Node> id_map(_graph);
  2116         _writer_bits::writeToken(*_os, it->first) << '\t';
  2116         _writer_bits::writeToken(*_os, it->first) << '\t';
  2117       }
  2117       }
  2118       *_os << std::endl;
  2118       *_os << std::endl;
  2119 
  2119 
  2120       std::vector<Node> nodes;
  2120       std::vector<Node> nodes;
  2121       for (BlueIt n(_graph); n != INVALID; ++n) {
  2121       for (BlueNodeIt n(_graph); n != INVALID; ++n) {
  2122         nodes.push_back(n);
  2122         nodes.push_back(n);
  2123       }
  2123       }
  2124 
  2124 
  2125       if (label == 0) {
  2125       if (label == 0) {
  2126         IdMap<BGR, Node> id_map(_graph);
  2126         IdMap<BGR, Node> id_map(_graph);