-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGraph.hpp
More file actions
38 lines (30 loc) · 1.05 KB
/
Graph.hpp
File metadata and controls
38 lines (30 loc) · 1.05 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
// Ariel shamay
// 207565573
// arielsh49@gmail.com
#ifndef GRAPH_HPP
#define GRAPH_HPP
#include <vector>
#include <utility>
using namespace std;
namespace ariel {
class Graph {
private:
bool directed;
std::vector<std::vector<int>> adjacencyMatrix;
public:
void loadGraph(const std::vector<std::vector<int>>& matrix);
void printGraph() const;
bool isDirected() const;
std::vector<std::pair<size_t, std::pair<size_t, int>>> getEdges() const;
std::vector<std::size_t> getNeighbors(std::size_t node) const;
int getEdgeWeight(size_t ver1, size_t ver2) const;
// Inline functions
bool getDirected() const { return this->directed; }
std::size_t getNumberOfNodes() const { return adjacencyMatrix.size(); }
bool isEdge(size_t from, size_t to) const { return adjacencyMatrix[from][to] != 0; }
std::vector<std::vector<int>> getMatrix() const { return adjacencyMatrix; }
};
using StartNode = size_t;
using EndNode = size_t;
}
#endif // GRAPH_HPP