diff --git a/cpp/exports.hpp b/cpp/exports.hpp new file mode 100644 index 0000000000000000000000000000000000000000..8be142765b6e1d9e4d7aafa700f6d8b67d67655a --- /dev/null +++ b/cpp/exports.hpp @@ -0,0 +1,23 @@ +#pragma once +#include "graph.hpp" + +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; +} +