diff --git a/src/edge.c b/src/edge.c index 0e35cd1e..8feeccb6 100644 --- a/src/edge.c +++ b/src/edge.c @@ -81,13 +81,21 @@ void free_edge(edge_t *e) { } void edge_add(edge_t *e) { - splay_insert(edge_weight_tree, e); - splay_insert(e->from->edge_tree, e); + if (splay_insert(e->from->edge_tree, e)) { + e->reverse = lookup_edge(e->to, e->from); - e->reverse = lookup_edge(e->to, e->from); + if(e->reverse) + e->reverse->reverse = e; - if(e->reverse) - e->reverse->reverse = e; + if (!splay_insert(edge_weight_tree, e)) + logger(DEBUG_ALWAYS, LOG_ERR, + "%s:%d: edge from: %s to: %s exists in edge_weight_tree", + __FUNCTION__, __LINE__, e->from->name, e->to->name); + } else { + logger(DEBUG_ALWAYS, LOG_ERR, + "%s:%d: edge from: %s to: %s exists in e->from->edge_tree", + __FUNCTION__, __LINE__, e->from->name, e->to->name); + } } void edge_del(edge_t *e) {