#ifndef GRAPH_H_ #define GRAPH_H_ #include #include #include #include #include namespace graph { template class Graph { public: Graph() = default; // Add vertex v void insert(const T& v); // Add edge between v and u void insert(const T& v, const T& u); // Reverse graph directions Graph reverse(); // Number of vertices std::uint16_t V(); // Number of edges // TODO: Calculate bidirectional edges once std::uint16_t E(); // Adjacency matrix representation std::set vertices; std::map> adjMatrix; }; template void Graph::insert(const T& v) { vertices.insert(v); } template void Graph::insert(const T& v, const T& u) { vertices.insert(v); vertices.insert(u); adjMatrix[v].insert(u); } template Graph Graph::reverse() { return Graph(); } template std::uint16_t Graph::V() { return vertices.size(); } template std::uint16_t Graph::E() { std::uint16_t edges = 0; for (const auto& v : vertices) { edges += adjMatrix[v].size(); } return edges; } } // namespace graph #endif