forked from lucasmoura/SimpleGraph
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
52 lines (38 loc) · 876 Bytes
/
main.cpp
File metadata and controls
52 lines (38 loc) · 876 Bytes
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
#include <iostream>
#include "graph.h"
using namespace std;
int main()
{
Graph *graph = new Graph();
graph->addVertex(1);
graph->addVertex(2);
graph->addVertex(3);
graph->addVertex(4);
graph->addVertex(5);
graph->addVertex(6);
graph->addVertex(7);
cout<<graph<<endl;
graph->addEdge(1,2,5);
graph->addEdge(1,7,5);
graph->addEdge(2,3,5);
graph->addEdge(2,6,5);
graph->addEdge(3,4,5);
graph->addEdge(3,5,4);
cout<<graph<<endl;
cout<<"\nSearching for a vertex..."<<endl;
int result = graph->breadthFirstSearch(1,5);
cout<<endl;
if (!result)
cout<<"Vertex found with success"<<endl;
else
cout<<"Vertex not found"<<endl;
cout<<"\nSearching for a vertex..."<<endl;
result = graph->depthFirstSearch(1,7);
cout<<endl;
if (!result)
cout<<"Vertex found with success"<<endl;
else
cout<<"Vertex not found"<<endl;
delete graph;
return 0;
}