Skip to content

Commit 842eb11

Browse files
author
g-batalhao-a
committed
Added GraphViewer
1 parent 9892cec commit 842eb11

27 files changed

+1236
-100
lines changed

.idea/.gitignore

+2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/.name

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/MeatWagons.iml

+2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/misc.xml

+9
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/modules.xml

+8
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/vcs.xml

+6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Entrega_II/CMakeLists.txt

+8-1
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,12 @@ cmake_minimum_required(VERSION 3.15)
22
project(Entrega_II)
33

44
set(CMAKE_CXX_STANDARD 14)
5+
# The line below is necessary if you are under Windows only
6+
# Comment the line below if you are under Linux or Mac OS
7+
link_libraries(ws2_32 wsock32)
8+
include_directories(src)
9+
include_directories(Mapas-20200420)
510

6-
add_executable(Entrega_II main.cpp src/Graph.h src/menus.cpp src/menus.h src/utils.cpp src/utils.h src/Prisoner.cpp src/Prisoner.h src/Graph.cpp)
11+
add_executable(Entrega_II main.cpp src/graph/Graph.h src/menu/menus.cpp src/util/utils.cpp src/prison/Prisoner.cpp
12+
src/graphviewer/connection.cpp src/graphviewer/edgetype.h src/graphviewer/graphviewer.cpp
13+
src/util/Parser.cpp src/gui/GUI.cpp)

Entrega_II/main.cpp

+9-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
#include <iostream>
22

3-
#include "src/menus.h"
3+
#include "menu/menus.h"
4+
#include "graph/Graph.h"
5+
#include "src/util/Parser.h"
6+
#include "src/gui/GUI.h"
47

58
using namespace std;
69

@@ -10,6 +13,10 @@ int main() {
1013
vector<Prisoner*> vec;
1114
int op;
1215
int num = 0;
16+
Graph<coord> graph = parseMap("../Mapas-20200420/GridGraphs/GridGraphs/4x4/nodes.txt", "../Mapas-20200420/GridGraphs/GridGraphs/4x4/edges.txt");
17+
18+
GUI gui = GUI(graph, 600, 600);
19+
gui.show();
1320

1421
while ((op = mainMenu()) != 0) {
1522
switch (op) {
@@ -33,5 +40,6 @@ int main() {
3340
}
3441
}
3542

43+
3644
return 0;
3745
}

Entrega_II/src/Graph.h

-77
This file was deleted.

Entrega_II/src/Graph.cpp renamed to Entrega_II/src/graph/Graph.cpp

+34-19
Original file line numberDiff line numberDiff line change
@@ -9,38 +9,49 @@
99
* Class Vertex
1010
* ================================================================================================
1111
*/
12+
/*
13+
template<class T>
14+
Vertex<T>::Vertex(int id): id(id) {}
1215
13-
Vertex::Vertex(int id): id(id) {
14-
}
15-
16-
Edge * Vertex::addEdge(Vertex *dest, double w) {
17-
Edge * e = new Edge(this, dest, w);
16+
template<class T>
17+
Edge<T>* Vertex<T>::addEdge(Vertex<T> *dest, double w) {
18+
Edge<T> * e = new Edge<T>(this, dest, w);
1819
this->outgoing.push_back(e);
1920
dest->incoming.push_back(e);
2021
return e;
2122
}
2223
23-
int Vertex::getID() const {
24+
template<class T>
25+
int Vertex<T>::getID() const {
2426
return this->id;
2527
}
2628
27-
vector<Edge *> Vertex::getAdj() const {
29+
template<class T>
30+
vector<Edge<T> *> Vertex<T>::getAdj() const {
2831
return this->outgoing;
2932
}
3033
34+
template<class T>
35+
T Vertex<T>::getInfo() const {
36+
return this->info;
37+
}
38+
3139
3240
/* ================================================================================================
3341
* Class Edge
3442
* ================================================================================================
3543
*/
44+
/*
45+
template<class T>
46+
Edge<T>::Edge(Vertex<T> *o, Vertex<T> *d, double w): orig(o), dest(d), weight(w){}
3647
37-
Edge::Edge(Vertex *o, Vertex *d, double w): orig(o), dest(d), weight(w){}
38-
39-
double Edge::getWeight() const {
48+
template<class T>
49+
double Edge<T>::getWeight() const {
4050
return weight;
4151
}
4252
43-
Vertex* Edge::getDest() const {
53+
template<class T>
54+
Vertex<T>* Edge<T>::getDest() const {
4455
return dest;
4556
}
4657
@@ -49,17 +60,19 @@ Vertex* Edge::getDest() const {
4960
* Class Graph
5061
* ================================================================================================
5162
*/
52-
53-
Vertex * Graph::addVertex(const int &id) {
54-
Vertex *v = findVertex(id);
63+
/*
64+
template<class T>
65+
Vertex<T> * Graph<T>::addVertex(const T &id) {
66+
Vertex<T> *v = findVertex(id);
5567
if (v != nullptr)
5668
return v;
57-
v = new Vertex(id);
69+
v = new Vertex<T>(id);
5870
vertexSet.push_back(v);
5971
return v;
6072
}
6173
62-
Edge * Graph::addEdge(const int &sourc, const int &dest, double w) {
74+
template<class T>
75+
Edge<T> * Graph<T>::addEdge(const int &sourc, const int &dest, double w) {
6376
auto s = findVertex(sourc);
6477
auto d = findVertex(dest);
6578
if (s == nullptr || d == nullptr)
@@ -68,15 +81,17 @@ Edge * Graph::addEdge(const int &sourc, const int &dest, double w) {
6881
return s->addEdge(d, w);
6982
}
7083
71-
Vertex* Graph::findVertex(const int & id) const {
84+
template<class T>
85+
Vertex<T>* Graph<T>::findVertex(const int & id) const {
7286
for (auto v : vertexSet)
7387
if (v->id == id)
7488
return v;
7589
return nullptr;
7690
}
7791
78-
vector<Vertex *> Graph::getVertexSet() const {
92+
template<class T>
93+
vector<Vertex<T> *> Graph<T>::getVertexSet() const {
7994
return vertexSet;
8095
}
81-
96+
*/
8297

0 commit comments

Comments
 (0)