Hi guys I m programming C for an assingment in VC++ 2008. I simulate adjList for graph implementation. i can readly add edge between two vertex and print the graph. and i want to remove edge between two vertex and print the graph again. whatever i do,i cant print the graph after deleting the edge. i get 0xfeefee :( what is this? and how can i resolve this program.
my delete function and print the graph function are illustrated below.
void deleteEdge(Graph G, Vertex V, Vertex W)
{
Edge list,prev,temp;
list=V->list;
prev=NULL;
//
while(list!=NULL && list->to->value!=W->value){
prev=list;
list=list->next;
}
// have found the element.
if(list!=NULL){
temp=list;
// if first element of list is deleted.
if(prev==NULL)
list=list->next;
else
prev->next=list->next;
// reallocate.
free(temp);
}
}
void GRAPHprint(Graph G)
{
Vertex tmp;
Edge list;
for(tmp = G->head;tmp!=NULL;tmp=tmp->next)
{
fprintf(stdout,"V:%d\t",tmp->value);
list=tmp->list;
while(list!=NULL)
{
fprintf(stdout,"%d\t",list->to->value);
list=list->next;
}
fprintf(stdout, "\n");
}
system("pause");
}