]>
wirehaze git hosting - graph-theory.git/blob - graph/adj.c
ec9cd0c8690d0d8acf381d05409a0f515160350c
6 new_graph (unsigned int nv
)
13 if (!(g
= malloc (sizeof *g
)))
18 if (!(g
->v
= calloc (nv
, sizeof *g
->v
)))
28 new_arc (struct graph
*g
, unsigned int vi
, unsigned int vj
)
32 if (vi
>= g
->nv
|| vj
>= g
->nv
)
35 if (!(e
= malloc (sizeof *e
)))
39 e
->next
= g
->v
[vi
].adj
;
46 new_edge (struct graph
*g
, unsigned int vi
, unsigned int vj
)
50 if ((err
= new_arc (g
, vi
, vj
)))
53 if (vi
!= vj
&& (err
= new_arc (g
, vj
, vi
)))
54 return err
; /* should delete the other arc but fuck it we ball */