Continued implementation of PBQP solver: Fixed errors and warnings.
[libfirm] / pbqp_edge.c
1 #include "assert.h"
2
3 #include "kaps.h"
4 #include "matrix.h"
5 #include "pbqp_edge.h"
6 #include "pbqp_edge_t.h"
7 #include "pbqp_node.h"
8 #include "pbqp_node_t.h"
9 #include "pbqp_t.h"
10
11 pbqp_edge *alloc_edge(pbqp *pbqp, int src_index, int tgt_index, matrix *costs)
12 {
13         if (tgt_index < src_index) {
14                 return alloc_edge(pbqp, tgt_index, src_index, costs);
15         }
16
17         pbqp_edge *edge = obstack_alloc(&pbqp->obstack, sizeof(*edge));
18         assert(edge);
19
20         pbqp_node *src_node = get_node(pbqp, src_index);
21         assert(src_node);
22         edge->src = src_node;
23
24         pbqp_node *tgt_node = get_node(pbqp, tgt_index);
25         assert(tgt_node);
26         edge->tgt = tgt_node;
27
28         edge->costs = matrix_copy(pbqp, costs);
29
30         // TODO: connect edge with nodes
31
32         return edge;
33 }