-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgraph.h
44 lines (32 loc) · 886 Bytes
/
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
//
// Created by Emil Akopyan on 08.10.2020.
//
#ifndef KSNWRK_GRAPH_H
#define KSNWRK_GRAPH_H
#include <vector>
#include <utility>
#include <cmath>
class Graph
{
public:
typedef std::pair<double,int> edge; //weight, vertex. The first vertex is determined by the position in AL
typedef std::vector<std::vector<edge>> adjList;
typedef std::pair<double, double> vertex;
public:
Graph(int n)
{
std::vector<vertex> coordinates (n);
std::vector<std::vector<edge>> edges (n);
_vertices = coordinates;
_adjlist = edges;
};
void addNewEdge(int u, double weight, int v);
void addNewVert(int i,double x, double y);
vertex getVertex(int n);
static double calculateDistance(vertex u, vertex v);
void primsAlgorithm();
private:
adjList _adjlist;
std::vector<vertex> _vertices;
};
#endif //KSNWRK_GRAPH_H