-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDirectedGraph.h
More file actions
46 lines (31 loc) · 1.11 KB
/
DirectedGraph.h
File metadata and controls
46 lines (31 loc) · 1.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#pragma once
#include <string>
#include <unordered_map>
#include <memory>
#include <vector>
#include "Node.h" // Includes definition for Node
class DirectedGraph {
private:
std::unordered_map<std::string, std::shared_ptr<Node>> nodes;
size_t edgeCounter;
public:
DirectedGraph();
//node operations
void addNode(const std::string& id);
void removeNode(const std::string& id);
bool hasNode(const std::string& id) const;
//Edge operations
void addEdge(const std::string& from, const std::string& to);
void removeEdge(const std::string& from, const std::string& to);
bool hasEdge(const std::string& from, const std::string& to) const;
//Accessors
std::shared_ptr<Node> getNode(const std::string& id) const;
std::vector<std::string> getNodeIds() const;
size_t nodeCount() const;
size_t edgeCount() const;
//dotfile export
void exportToDOT(const std::string& filename) const;
//traversal functions
std::vector<std::string> bfs(const std::string startId) const;
std::vector<std::string> dfs(const std::string startId) const;
};