This repository was archived by the owner on Jul 3, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgraph.h
52 lines (41 loc) · 1.33 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
#ifndef _GRAPH_H_
#define _GRAPH_H_
#include "minHeap.h"
#include <vector>
#include <list>
#include <iostream>
#include <queue>
#include <float.h>
#include "Semipath.h"
using namespace std;
class Graph {
struct Edge {
int dest; // Destination node
double weight; // An integer weight
string line, name;
};
struct Node {
list<Edge> adj; // The list of outgoing edges (to adjacent nodes)
double dist;
int pred;
bool visited;
};
int n; // Graph size (vertices are numbered from 1 to n)
bool hasDir = true; // false: undirect; true: directed
vector<Node> nodes; // The list of nodes being represented
public:
// Constructor: nr nodes and direction (default: undirected)
Graph(int nodes);
// Add edge from source to destination with a certain weight
void addEdge(int src, int dest, double weight, const string& line, string name);
bool hasEdge(int src, int dest, double weight, string line, string name);
double dijkstra_distance(int a, int b);
list<Semipath> dijkstra_path(int a, int b);
void dijkstra(int a); //distancia para o grafo inteiro
void bfs(int v);
double bfs_distance(int a, int b);
list<Semipath> bfs_path(int a, int b);
list<Semipath> get_path(list<int> path);
Graph();
};
#endif