File tree 1 file changed +8
-8
lines changed
Travelling Salesman Problem/C++
1 file changed +8
-8
lines changed Original file line number Diff line number Diff line change @@ -9,10 +9,10 @@ void takeInput()
9
9
{
10
10
int i,j;
11
11
12
- cout<<" Enter the number of villages: " ;
13
- cin>>n;
12
+ cout<<" Enter the number of villages: " ; // Take input for number of destinations to be visited
13
+ cin>>n;
14
14
15
- cout<<" \n Enter the Cost Matrix\n " ;
15
+ cout<<" \n Enter the Cost Matrix\n " ; // input of the cost matrix
16
16
17
17
for (i=0 ;i < n;i++)
18
18
{
@@ -26,15 +26,15 @@ void takeInput()
26
26
27
27
cout<<" \n\n The cost list is:" ;
28
28
29
- for ( i=0 ;i < n;i++)
29
+ for ( i=0 ;i < n;i++) // Calculates the cost list for the matrix
30
30
{
31
31
cout<<" \n " ;
32
32
33
33
for (j=0 ;j < n;j++)
34
34
cout<<" \t " <<ary[i][j];
35
35
}
36
36
}
37
-
37
+ // Computes the least cost and returns the value
38
38
int least (int c)
39
39
{
40
40
int i,nc=999 ;
@@ -56,7 +56,7 @@ int least(int c)
56
56
57
57
return nc;
58
58
}
59
-
59
+ // Provides min cost for a city
60
60
void mincost (int city)
61
61
{
62
62
int i,ncity;
@@ -77,7 +77,7 @@ void mincost(int city)
77
77
78
78
mincost (ncity);
79
79
}
80
-
80
+ // Driver code for the above functions
81
81
int main ()
82
82
{
83
83
takeInput ();
@@ -88,4 +88,4 @@ int main()
88
88
cout<<" \n\n Minimum cost is " <<cost;
89
89
90
90
return 0 ;
91
- }
91
+ }
You can’t perform that action at this time.
0 commit comments