39 int (*match)(
const void *key1,
const void *key2);
40 void (*destroy)(
void *data);
47 void (*destroy)(
void *data))
52 if ((grtmp = (
Graph)malloc(
sizeof(
struct Graph_))) == NULL)
56 grtmp->destroy = destroy;
61 if ((grtmp->vertices =
SLISTinit(NULL)) == NULL)
78 if (
SLISTremnext(graph->vertices, NULL, (
void **)&vtx) == 0)
84 if (graph->destroy != NULL)
85 graph->destroy(vtx->vertexdata);
113 vtx->vertexdata = (
void *)data;
116 if ((vtx->adj_vertices =
SLISTinit(graph->destroy)) == NULL)
188 if (
SLISTremnext(graph->vertices, prev, (
void **)&vtx) != 0)
192 *data = vtx->vertexdata;
232 void GRAPHprint(
Graph graph,
void (*vtxcallback)(
const void *data),
void (*edgecallback)(
const void *data))
237 for (element =
SLISThead(graph->vertices); element != NULL; element =
SLISTnext(element))
239 printf(
"\nVertex#%02d: ", nr);
241 printf(
"\nEdges #%02d: ", nr);
247 void GRAPHtraverse(
Graph graph,
void (*vtxcallback)(
const void *data),
void (*edgecallback)(
const void *data))
251 for (element =
SLISThead(graph->vertices); element != NULL; element =
SLISTnext(element))
297 return graph->vcount;
302 return graph->ecount;
307 return GRAPHfindedge(graph, vtxdata, adjdata) == NULL ? 0 : 1;
347 list = graph->vertices;