I need to start program that counts from top branch wich is: 1, this program counts from 0, could anyone help? Here is the code:
#include <iostream>
#include <climits>
#define V 7
using namespace std;
class Graph
{
private:
int parent[V], dist[V];
bool mark[V];
int src = 1;
int i, v, count;
public:
int graph[V][V] =
{
{0, 2, 0, 1, 4, 0, 0},
{2, 0, 0, 3, 1, 0, 0},
{4, 0, 0, 2, 2, 5, 0},
{1, 3, 2, 0, 7, 8, 4},
{0, 10, 7, 7, 0, 0, 6},
{0, 8, 5, 8, 0, 0, 1},
{4, 0, 0, 4, 6, 1, 0}
};
int minDist();
void MST();
void printMST();
};
int main()
{
Graph G;
G.MST();
G.printMST();
return 0;
}
int Graph::minDist()
{
int min = INT_MAX, min_index;
I'm confused. It sounds to me like you are having trouble because your nodes are numbered from zero, and your output lists a node as 0, 1, 2, etc instead of 1, 2, 3, etc. Is that it?