-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGraph.hpp
54 lines (43 loc) · 2.42 KB
/
Graph.hpp
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
47
48
49
50
51
52
53
54
// Mail: [email protected]
// Author: Tzohar Lary
#ifndef GRAPH_HPP
#define GRAPH_HPP
#include <vector>
#include <string>
namespace ariel {
class Graph {
private:
std::vector<std::vector<int>> adjacencyMatrix;
public:
void loadGraph(const std::vector<std::vector<int>>& matrix);
bool isEmpty() const;
void addNode();
void removeNode();
void setEdge(int fromNode, int toNode, int value);
const std::vector<std::vector<int>>& getAdjacencyMatrix() const;
std::string printGraph() const;
// All the following operators with reference, it for avoid copy of the object and affect time complexity
// all the const functions are for avoid changing the object
Graph operator+(const Graph& other) const; // Matrix addition
Graph& operator+=(const Graph& other); // Matrix addition
Graph operator+() const; // Unary plus operator - returns the original value of the graph (no change)
Graph operator-(const Graph& other) const; // Matrix subtraction
Graph& operator-=(const Graph& other); // Matrix subtraction
Graph operator-() const; // Unary minus operator - returns the negative value of the graph (all values multiplied by -1)
bool operator==(const Graph& other) const; // Matrix equality check
bool operator!=(const Graph& other) const; // Matrix inequality check
bool operator<(const Graph& other) const; // Matrix less than check
bool operator<=(const Graph& other) const; // Matrix less than or equal to check
bool operator>(const Graph& other) const; // Matrix greater than check
bool operator>=(const Graph& other) const; // Matrix greater than or equal to check
Graph operator++(int); // Postfix increment operator - returns the original value before increment
Graph& operator++(); // Prefix increment operator - returns the value after increment
Graph operator--(int); // Postfix decrement operator - returns the original value before decrement
Graph& operator--(); // Prefix decrement operator - returns the value after decrement
Graph operator*(const Graph& other) const; // Matrix multiplication
Graph& operator*=(int scalar); // Scalar multiplication
Graph& operator/=(int scalar); // Scalar division
};
std::ostream& operator<<(std::ostream& outputStream, const Graph& graph);
}
#endif // GRAPH_HPP