Is there anybody out there that could help me with the following problem???
http://ice.prohosting.com/jbratset/cgi-bin/Project.doc
Here is my code so far:
#include <stdio.h>
#define GRAPHSIZE 10
#define MAXNEIGHBOURS 4
struct Graph{
int degree;
int Neighbors[MAXNEIGHBOURS];
int Neigh_Weight[MAXNEIGHBOURS];
};
struct Graph GraphArray[GRAPHSIZE];
main()
{
int vtx, vtx_degree, neighbor, neighbour_id, weight;
for ( vtx = 0; vtx < GRAPHSIZE; vtx++){
printf(" Total Neighbors for vertex Nr: %d ?\n",vtx);
scanf("%d", &vtx_degree);
GraphArray[vtx].degree = vtx_degree;
for (neighbor = 0; neighbor < vtx_degree; neighbor++){
printf(" Give the id of neighbor Nr: %d\n", neighbor + 1);
scanf("%d", &neighbour_id);
GraphArray[vtx].Neighbors[neighbor] = neighbour_id;
printf(" Weight for the edge <%d %d>\n", vtx, neighbour_id);
scanf ("%d", &weight);
GraphArray[vtx].Neigh_Weight[neighbor] = weight;
}
}
for (vtx = 0; vtx < GRAPHSIZE; vtx++){
vtx_degree = GraphArray[vtx].degree;
printf(" vtx = %d total_neighbors = %d\n", vtx, vtx_degree);
for ( neighbor = 0; neighbor < vtx_degree; neighbor++){
neighbour_id = GraphArray[vtx].Neighbors[neighbor];
weight = GraphArray[vtx].Neigh_Weight[neighbor];
printf(" vtx =%d neighbour_id= %d weight=%d\n", vtx, neighbour_id, weight);
}
}
}