-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
71 lines (60 loc) · 1.91 KB
/
main.cpp
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
/*
* File: main.cpp
* Author: Dhavalkumar Suthar
*
* Created on October 4, 2015, 3:29 PM
*/
#include <cstdlib>
#include <iostream>
#include "Graph.h"
using namespace std;
/*
* This program tests the functionality of the PathFinder.
* Given a graph, it tests whether there exists a path between given two
* nodes or not.
*/
int main(int argc, char** argv) {
//Allocate a graph object...
Graph myGraph(5);
myGraph.addEdge(0, 1);
myGraph.addEdge(0, 4);
myGraph.addEdge(2, 0);
myGraph.addEdge(3, 3);
myGraph.addEdge(2, 3);
myGraph.addEdge(4, 2);
myGraph.addEdge(0, 2);
myGraph.addEdge(1, 2);
//Define starting and ending vertices...
int startingPoint = 0;
int endingPoint = 3;
//Check if two vertices are connected or not..
if (myGraph.isConnected(startingPoint, endingPoint))
{
cout << "Vertice "<< startingPoint << " and " << endingPoint << " are connected";
}
else
{
cout << "Vertice "<< startingPoint << " and " << endingPoint << " are NOT connected\n";
}
//Once again Check if two vertices are connected or not..
startingPoint = 4, endingPoint = 1;
if (myGraph.isConnected(startingPoint, endingPoint))
{
cout << "Vertice "<< startingPoint << " and " << endingPoint << " are connected";
}
else
{
cout << "Vertice "<< startingPoint << " and " << endingPoint << " are NOT connected";
}
//One final time Check if two vertices are connected or not..
startingPoint = 3, endingPoint = 1;
if (myGraph.isConnected(startingPoint, endingPoint))
{
cout << "Vertice "<< startingPoint << " and " << endingPoint << " are connected";
}
else
{
cout << "Vertice "<< startingPoint << " and " << endingPoint << " are NOT connected";
}
return 0;
}