Skip to content

Commit 138f140

Browse files
author
igor
committed
initial
0 parents  commit 138f140

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+5317
-0
lines changed

.gitkeep

Whitespace-only changes.

Makefile

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
CC=g++ -std=c++17 -Wall -Werror -Wextra
2+
CHECKFLAGS=-lgtest
3+
CURRENTDIR = $(shell pwd)
4+
BUILD_DIR=build
5+
APP=Navigator
6+
REPORTDIR=gcov_report
7+
GCOV=--coverage
8+
OPEN=
9+
FILTER=
10+
CPPCHECKFLAG = --enable=all --suppress=unusedStructMember --suppress=missingIncludeSystem --language=c++ --std=c++17
11+
TEST_LIB:=./tests/tests_main.cc \
12+
./lib/s21_graph.cc \
13+
./lib/s21_graph_algorithms.cc \
14+
./lib/ant_algorithm.cc \
15+
./lib/annealing_algorithm.cc \
16+
./lib/genetic_algorithm.cc
17+
MVC:=main.cc \
18+
./lib/s21_graph.cc \
19+
./lib/s21_graph_algorithms.cc \
20+
./lib/ant_algorithm.cc \
21+
./lib/annealing_algorithm.cc \
22+
./lib/genetic_algorithm.cc \
23+
./view/console.cc \
24+
./controller/controller.cc \
25+
./model/navigator.cc
26+
27+
OS = $(shell uname)
28+
29+
ifeq ($(OS), Linux)
30+
CC+=-D OS_LINUX -g -s
31+
CHECKFLAGS+=-lpthread
32+
CHECK_LEAKS=CK_FORK=no valgrind --leak-check=full --show-leak-kinds=all --track-origins=yes --log-file=log.txt
33+
OPEN=xdg-open
34+
DIR=
35+
QTFLAGS=-spec linux-g++
36+
else
37+
CC+=-D OS_MAC
38+
CHECK_LEAKS=CK_FORK=no leaks --atExit --
39+
FILTER=--gtest_filter=-*.Exception*
40+
OPEN=open
41+
DIR=/$(APP).app
42+
QTFLAGS=
43+
endif
44+
45+
all: build
46+
47+
s21_graph.a:
48+
@$(CC) -c ./lib/s21_graph.cc -o ./s21_graph.o
49+
@ar rcs s21_graph.a ./s21_graph.o
50+
@rm -rf s21_graph.o
51+
52+
s21_graph_algorithms.a:
53+
@$(CC) -c ./lib/s21_graph_algorithms.cc -o ./s21_graph_algorithms.o
54+
@ar rcs s21_graph_algorithms.a ./s21_graph_algorithms.o
55+
@rm -rf s21_graph_algorithms.o
56+
57+
build:
58+
@$(CC) $(MVC) -o $(APP)
59+
./$(APP)
60+
61+
rebuild: clean build
62+
63+
dvi:
64+
doxygen ./docs/Doxyfile
65+
$(OPEN) ./docs/html/index.html
66+
67+
tests: mostlyclean
68+
@$(CC) $(TEST_LIB) $(CHECKFLAGS) -o Test
69+
@./Test
70+
@rm -rf *.o *.a Test
71+
72+
gcov_report: mostlyclean
73+
@$(CC) $(TEST_LIB) -o Test $(GCOV) $(CHECKFLAGS)
74+
@./Test
75+
@lcov --no-external -c -d . -o $(APP).info
76+
@genhtml -o $(REPORTDIR) $(APP).info
77+
@$(OPEN) ./$(REPORTDIR)/index.html
78+
79+
check: style cppcheck leaks
80+
81+
style:
82+
@clang-format -style=google -verbose -n */*.cc */*.h
83+
84+
cppcheck:
85+
@cppcheck $(CPPCHECKFLAG) */*.cc */*/*.cc *.cc */*.h */*/*.h *.h
86+
87+
leaks: mostlyclean
88+
@$(CC) $(TEST_LIB) $(CHECKFLAGS) -o Test
89+
@$(CHECK_LEAKS) ./Test $(FILTER)
90+
@rm -rf *.o *.a Test
91+
92+
clean:
93+
@rm -rf *.o *.a *.out *.gcno *.gch *.gcda *.info *.tgz $(REPORTDIR) Test $(BUILD_DIR) $(APP_DIR) $(APP) ./docs/html
94+
95+
mostlyclean:
96+
@rm -rf *.o *.out *.gcno *.gch *.gcda *.info *.tgz $(REPORTDIR) Test

README.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# Simple Navigator v1.0
2+
The "Simple Navigator v1.0" is an app written in C++. The console application provides implementation several algorithms on graphs, such as traversal, finding shortest paths, finding the minimum spanning tree and solving travelling salesman problem.
3+
4+
## Features
5+
- Console interface
6+
7+
![Navigator Console Screenshot](./docs/images/Navigator_console.png)
8+
9+
- Load graph as adjacency matrix from a specific file.
10+
- Non-recursive depth-first search in the graph.
11+
- Breadth-first search in the graph from a given vertex.
12+
- Searching for the shortest path between two vertices in a graph using Dijkstra's algorithm.
13+
- Searching for the shortest paths between all pairs of vertices in a graph using the Floyd-Warshall algorithm.
14+
15+
![Floyd-Warshall Screenshot](./docs/images/Floyd_Warshall.png)
16+
17+
- Searching for the minimal spanning tree in a graph using Prim's algorithm.
18+
19+
![Prim Screenshot](./docs/images/Prim.png)
20+
21+
- Solving the traveling salesman's problem using the ant colony algorithm.
22+
- Solving the traveling salesman's problem using the annealing simulation algorithm.
23+
- Solving the traveling salesman's problem using the genetic algorithm.
24+
25+
![TSM Screenshot](./docs/images/TSM.png)
26+
27+
- Performing a comparison of speed of the three algorithms for TSM problem.
28+
29+
![Compare algorithms Screenshot](./docs/images/Compare_algorithms.png)
30+
31+
## License
32+
Copyright (c). All rights reserved.

controller/controller.cc

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#include "controller.h"
2+
3+
Controller::Controller(Navigator* model) : model_(model) {}
4+
5+
void Controller::FirstItem(std::string filename) {
6+
model_->Navigator::FirstItem(filename);
7+
}
8+
9+
GraphAlgorithms::Vector Controller::SecondItem(int start) {
10+
return model_->SecondItem(start);
11+
}
12+
13+
GraphAlgorithms::Vector Controller::ThirdItem(int start) {
14+
return model_->ThirdItem(start);
15+
}
16+
17+
int Controller::FourthItem(int vertex1, int vertex2) {
18+
return model_->FourthItem(vertex1, vertex2);
19+
}
20+
21+
GraphAlgorithms::Matrix Controller::FivthItem() { return model_->FivthItem(); }
22+
23+
GraphAlgorithms::Matrix Controller::SixthItem() { return model_->SixthItem(); }
24+
25+
TsmResult Controller::SeventhItem() { return model_->SeventhItem(); }
26+
27+
std::vector<std::pair<double, double>> Controller::EighthItem(int cycles) {
28+
return model_->EighthItem(cycles);
29+
}

controller/controller.h

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#ifndef SRC_CONTROLLER_CONTROLLER_H
2+
#define SRC_CONTROLLER_CONTROLLER_H
3+
4+
#include "../model/navigator.h"
5+
6+
class Controller {
7+
public:
8+
explicit Controller(Navigator* model);
9+
10+
void FirstItem(std::string filename);
11+
GraphAlgorithms::Vector SecondItem(int start);
12+
GraphAlgorithms::Vector ThirdItem(int start);
13+
int FourthItem(int vertex1, int vertex2);
14+
GraphAlgorithms::Matrix FivthItem();
15+
GraphAlgorithms::Matrix SixthItem();
16+
TsmResult SeventhItem();
17+
std::vector<std::pair<double, double>> EighthItem(int cycles);
18+
19+
private:
20+
Navigator* model_;
21+
};
22+
23+
#endif // SRC_CONTROLLER_CONTROLLER_H

0 commit comments

Comments
 (0)