#pragma once #include "graph.hpp" #include #include #include std::ostream &operator<<(std::ostream &s, const Edge &e) { s << '{' << e.u << ',' << e.v << '}'; return s; } // Mathematica style export std::ostream &operator<<(std::ostream &s, const Graph &g) { if (g.edgeCount() == 0) { s << '{' << '}'; return s; } s << '{' << g.getEdge(0).u << '<' << '-' << '>' << g.getEdge(0).v; for (unsigned int i = 1; i < g.edgeCount(); ++i) { const Edge &e = g.getEdge(i); s << ',' << e.u << '<' << '-' << '>' << e.v; } s << '}'; return s; } template std::ostream &operator<<(std::ostream &s, const std::pair& p) { s << '{' << p.first << ',' << p.second << '}'; return s; } template std::ostream& output_array(std::ostream& s, FwdIterator begin, FwdIterator end) { if (begin == end) { s << '{' << '}'; return s; } s << '{' << *begin++; for (; begin != end; ++begin) { s << ',' << *begin; } s << '}'; return s; } template std::ostream& operator<<(std::ostream& s, const std::vector& v) { return output_array(s, std::begin(v), std::end(v)); } // Mathematica style export for normal arrays // SFINAE to disable char arrays since it will mess up // things of the form s << "some string"; template < typename T, std::size_t N, typename = typename std::enable_if::value>::type> std::ostream& operator<<(std::ostream& s, const T (&v)[N]) { return output_array(s, std::begin(v), std::end(v)); } template std::ostream& operator<<(std::ostream& s, const std::array& v) { return output_array(s, std::begin(v), std::end(v)); }