Пример #1
0
// driver program to test above function
int main()
{
   /* Let us create the following graph
          2    3
      (0)--(1)--(2)
       |   / \   |
      6| 8/   \5 |7
       | /     \ |
      (3)-------(4)
            9          */
   /*int graph[V][V] = {{0, 2, 0, 6, 0},
                      {2, 0, 3, 8, 5},
                      {0, 3, 0, 0, 7},
                      {6, 8, 0, 0, 9},
                      {0, 5, 7, 9, 0},
                     };*/

	int graph[V][V] = {{0, 1, 1, 0, 0, 0, 0},
						{0, 0, 0, 1, 1, 0, 0},
						{0, 0, 0, 0, 0, 0, 0},
						{0, 0, 0, 0, 0, 1, 1},
						{0, 0, 0, 1, 0, 0, 1},
						{0, 0, 1, 0, 0, 0, 0},
						{0, 0, 0, 0, 0, 1, 0}
	                  };

    // Print the solution
    primMST(graph);

    return 0;
}
Пример #2
0
int main()
{
    int graph[V][V],i,j;
    printf("Enter the graph:");
    for(i = 0; i < V; i++)
        for(j = 0; j < V; j++)
            scanf("%d", &graph[i][j]);
    primMST(graph);
    return 0;
}