7 #include "pbqp_edge_t.h"
9 #include "pbqp_node_t.h"
12 pbqp_edge *alloc_edge(pbqp *pbqp, int src_index, int tgt_index, pbqp_matrix *costs)
14 if (tgt_index < src_index) {
15 return alloc_edge(pbqp, tgt_index, src_index, costs);
18 pbqp_edge *edge = obstack_alloc(&pbqp->obstack, sizeof(*edge));
21 pbqp_node *src_node = get_node(pbqp, src_index);
24 pbqp_node *tgt_node = get_node(pbqp, tgt_index);
27 edge->costs = pbqp_matrix_copy(pbqp, costs);
30 * Connect edge with incident nodes. Since the edge is allocated, we know
31 * that it don't appear in the edge lists of the nodes.
33 ARR_APP1(pbqp_edge *, src_node->edges, edge);
34 edge->src = src_index;
35 ARR_APP1(pbqp_edge *, tgt_node->edges, edge);
36 edge->tgt = tgt_index;