Reorder incident nodes of removed edge.
[libfirm] / pbqp_edge.c
index aeb4608..31b9028 100644 (file)
@@ -1,3 +1,31 @@
+/*
+ * Copyright (C) 1995-2008 University of Karlsruhe.  All right reserved.
+ *
+ * This file is part of libFirm.
+ *
+ * This file may be distributed and/or modified under the terms of the
+ * GNU General Public License version 2 as published by the Free Software
+ * Foundation and appearing in the file LICENSE.GPL included in the
+ * packaging of this file.
+ *
+ * Licensees holding valid libFirm Professional Edition licenses may use
+ * this file in accordance with the libFirm Commercial License.
+ * Agreement provided with the Software.
+ *
+ * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+ * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE.
+ */
+
+/**
+ * @file
+ * @brief   PBQP edges.
+ * @date    02.10.2008
+ * @author  Sebastian Buchwald
+ * @version $Id$
+ */
+#include "config.h"
+
 #include "adt/array.h"
 #include "assert.h"
 
@@ -65,7 +93,20 @@ void delete_edge(pbqp_edge *edge)
        disconnect_edge(tgt_node, edge);
 }
 
-pbqp_edge *pbqp_edge_deep_copy(pbqp *pbqp, pbqp_edge *edge)
+pbqp_edge *pbqp_edge_deep_copy(pbqp *pbqp, pbqp_edge *edge,
+               pbqp_node *src_node, pbqp_node *tgt_node)
 {
-       return alloc_edge(pbqp, edge->src->index, edge->tgt->index, edge->costs);
+       pbqp_edge *copy = obstack_alloc(&pbqp->obstack, sizeof(*copy));
+       assert(copy);
+       assert(src_node);
+       assert(tgt_node);
+
+       copy->costs = pbqp_matrix_copy(pbqp, edge->costs);
+
+       /* Connect edge with incident nodes. */
+       copy->src = src_node;
+       copy->tgt = tgt_node;
+       copy->bucket_index = UINT_MAX;
+
+       return copy;
 }