mirror of
https://gitee.com/apaki/unicstl.git
synced 2025-07-03 23:56:54 +08:00
添加edge的新建和释放函数
This commit is contained in:
parent
0520bb99ae
commit
6965fa1e25
22
src/graph.c
22
src/graph.c
@ -359,6 +359,28 @@ static void greph_node_free(struct _graph_node** node)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static struct _graph_edge* graph_edge_new(void *obj, uint32_t obj_size)
|
||||||
|
{
|
||||||
|
struct _graph_edge* new_edge = (struct _graph_edge*)malloc(sizeof(struct _graph_edge));
|
||||||
|
if (new_edge == NULL)
|
||||||
|
{
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
new_edge->next = NULL;
|
||||||
|
new_edge->weight = 0;
|
||||||
|
new_edge->target = NULL;
|
||||||
|
return new_edge;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void greph_edge_free(struct _graph_edge** edge)
|
||||||
|
{
|
||||||
|
if(edge != NULL && *edge != NULL)
|
||||||
|
{
|
||||||
|
free(*edge);
|
||||||
|
*edge = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static uint32_t graph_size(struct _graph* self)
|
static uint32_t graph_size(struct _graph* self)
|
||||||
{
|
{
|
||||||
if(self == NULL)
|
if(self == NULL)
|
||||||
|
Loading…
Reference in New Issue
Block a user