Add base paper and tarjan's SCC algorithm
This commit is contained in:
@@ -1,61 +0,0 @@
|
||||
#ifndef GRAPH_H_
|
||||
#define GRAPH_H_
|
||||
|
||||
#include <map>
|
||||
#include <set>
|
||||
#include <vector>
|
||||
#include <utility>
|
||||
|
||||
namespace graph {
|
||||
|
||||
template<typename V>
|
||||
class Graph {
|
||||
public:
|
||||
Graph() = default;
|
||||
|
||||
// Add vertex v
|
||||
void insert(const V& v);
|
||||
|
||||
// Add edge between v and u
|
||||
void insert(const V& v, const V& u);
|
||||
|
||||
// Delete vertex v
|
||||
void erase(const V& v);
|
||||
|
||||
// Delete edge between v and u
|
||||
void erase(const V& v, const V& u);
|
||||
|
||||
// Return true if v and u are connected
|
||||
bool connected(const V& v, const V& u);
|
||||
private:
|
||||
std::map<V, std::set<V>> adjacency;
|
||||
};
|
||||
|
||||
template<typename V>
|
||||
inline void Graph<V>::insert(const V& v) {
|
||||
adjacency[v];
|
||||
}
|
||||
|
||||
template<typename V>
|
||||
inline void Graph<V>::insert(const V& v, const V& u) {
|
||||
adjacency[v].insert(u);
|
||||
}
|
||||
|
||||
template<typename V>
|
||||
inline void Graph<V>::erase(const V& v) {
|
||||
adjacency.erase(v);
|
||||
}
|
||||
|
||||
template<typename V>
|
||||
inline void Graph<V>::erase(const V& v, const V& u) {
|
||||
adjacency[v].erase(u);
|
||||
}
|
||||
|
||||
template<typename V>
|
||||
inline bool Graph<V>::connected(const V& v, const V& u) {
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace graph
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user