}
void edge_add(edge_t *e) {
- splay_insert(edge_weight_tree, e);
- splay_insert(e->from->edge_tree, e);
+ splay_node_t *node = splay_insert(e->from->edge_tree, e);
+
+ if(!node) {
+ logger(DEBUG_ALWAYS, LOG_ERR, "Edge from %s to %s already exists in edge_tree\n", e->from->name, e->to->name);
+ return;
+ }
+
e->reverse = lookup_edge(e->to, e->from);
if(e->reverse) {
e->reverse->reverse = e;
}
+
+ node = splay_insert(edge_weight_tree, e);
+
+ if(!node) {
+ logger(DEBUG_ALWAYS, LOG_ERR, "Edge from %s to %s already exists in edge_weight_tree\n", e->from->name, e->to->name);
+ return;
+ }
}
void edge_del(edge_t *e) {