-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconnectivity.cpp
More file actions
86 lines (64 loc) · 1.37 KB
/
connectivity.cpp
File metadata and controls
86 lines (64 loc) · 1.37 KB
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#include "iostream"
#include "stdlib.h"
using namespace std;
bool checkEmpty(int arr[], int n){
int flag = 0;
for(int i = 0; i < n; i++)
{
/* code */
if(arr[i] == 1){
flag = 1;
break;
}
}
if(flag)
return false;
else
return true;
}
int main(int argc, char const *argv[])
{
int graph[20][20];
int V;
char a;
int vertices[V],c=1;
for(int i = 0; i < V; i++)
{
/* code */
vertices[i] = 1;
}
cout<<"Enter the number of vertices";
for(int i = 0; i < V; i++)
{
for(int j = 0; j < V; j++)
{
if(i == j){
graph[i][j] = 0;
continue;
}
cout<<"Is there an edge between "<<i<<" and "<<"j";
cin>>a;
if(a=='Y'|| a=='y')
{
graph[i][j] =1;
}
else
graph[i][j] = 0;
graph[j][i] = graph[i][j];
}
}
int start = 0;
while(true){
if(checkEmpty(vertices,V))
break;
int copy[20][20];
for(int i = 0; i < V; i++)
{
for(int j = 0; j < V; j++)
{
copy[i][j] = graph[i][j];
}
}
}
return 0;
}