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, 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);
25 pbqp_node *tgt_node = get_node(pbqp, tgt_index);
29 edge->costs = matrix_copy(pbqp, costs);
32 * Connect edge with incident nodes. Since the edge is allocated, we know
33 * that it don't appear in the edge lists of the nodes.
35 ARR_APP1(pbqp_edge *, src_node->edges, edge);
37 ARR_APP1(pbqp_edge *, tgt_node->edges, edge);