反转一个邻接表,没有考虑权值.是为另一个例程服务的一个函数.贴出来吧.
for (i = 0; i < capacity; i++)
{
scan = (*padj) -> list[i].adjoin_to ;
name = (*pht) -> lists[(*padj) -> list[i].hash_value].name ;
while (scan)
{
w = (*pht) -> lists[scan -> hash_value].index_in_adjacenty_list ;
/* The incipient value of cvw is FALSE */
if (FALSE == scan -> cvw)
{
/* Create a new vertex */
new_vertex = Make_Adjoin_To_Vertex (pht, name, 0) ;
/* Borrow the territory of cvw to target */
new_vertex -> cvw = TRUE ;
if (NULL == new_vertex)
return 0 ;
if (NULL == (*padj) -> list[w].adjoin_to)
(*padj) -> list[w].adjoin_to = new_vertex ;
else
{
temp_2 = Find_End (&(*padj) -> list[w].adjoin_to) ;
(*temp_2) -> next = new_vertex ;
}
temp_1 = scan ;
(*padj) -> list[i].adjoin_to = scan -> next ;
scan = scan -> next ;
free (temp_1) ;
}
else
scan = scan -> next ;
}
}
return 1 ;
}