-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGraph.h
77 lines (59 loc) · 2.46 KB
/
Graph.h
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
//******************************
//
//
//Graph.h Defines the Graph Class
//******************************
#ifndef GRAPH_H
#define GRAPH_H
#include <cstdlib>
#include <ctime>
#include <vector>
#include <iostream>
#include "Node.h"
#include "Edge.h"
namespace graph {
//const int graph_size = 7;
class Graph {
//******************
//Constructors
public:
Graph(std::size_t newsize=0):
gsize(newsize),
graph(gsize ? new bool*[gsize] : nullptr)
{
std::cout << "consructor called"<< std::endl;
srand(time(0));
for(int i=0; i<gsize; ++i) {
graph[i] = new bool[gsize];
}
fill();
setEdges();
}
//destructor
~Graph();
//******************
//Member Functions
//******************
int V (); // returns the number of vertices in the graph
int E (); // returns the number of edges in the graph
bool adjacent ( Node& x, Node& y); // tests whether there is an edge from node x to node y.
void neighbors ( Node& x); // lists all nodes y such that there is an edge from x to y.
//void addEdge ( int x, int y); // adds to G the edge from x to y, if it is not there.
void addEdge ( const Node*& x, const Node*& y); // adds to G the edge from x to y, if it is not there.
void deleteEdge ( const Node*& x, const Node*& y); // removes the edge from x to y, if it is there.
int get_node_value ( const Node*& x); // returns the value associated with the node x.
void set_node_value( Node& x, int a); // sets the value associated with the node x to a.
int get_edge_value( Node& x, Node& y); // returns the value associated to the edge (x,y).
void set_edge_value ( Node& x, Node& y, double v); // sets the value associated to the edge (x,y) to v.
void print();
//Edge findEdge(std::list<Edge*> elist); //Search the std::list<Edges> to find the edges with matching nodes
private:
std::size_t gsize;
std::vector<Node*> nodes;
std::vector<Edge*> edges;
void fill();
void setEdges();
bool** graph;
};
} //namespace graph
#endif