From 5e8856790c50c30ea208e5cd28021818e5f2fcbf Mon Sep 17 00:00:00 2001 From: Quentin Young Date: Thu, 8 Sep 2016 18:14:16 +0000 Subject: [PATCH] lib: Remove automatic node deletion Signed-off-by: Quentin Young --- lib/graph.c | 14 +------------- lib/graph.h | 4 ---- 2 files changed, 1 insertion(+), 17 deletions(-) diff --git a/lib/graph.c b/lib/graph.c index be7d5aef38..314cf86850 100644 --- a/lib/graph.c +++ b/lib/graph.c @@ -65,12 +65,6 @@ graph_delete_node (struct graph *graph, struct graph_node *node) for (unsigned int j = 0; j < vector_active (adj->to); j++) if (vector_slot (adj->to, j) == node) vector_unset (adj->to, j); - - // if the node is orphaned, delete it - if (vector_active (adj->to) == 0 && - vector_active (adj->from) == 0 && - adj != node) - graph_delete_node (graph, adj); } // for all nodes that we have an edge to, remove us from their ->from @@ -80,15 +74,9 @@ graph_delete_node (struct graph *graph, struct graph_node *node) for (unsigned int j = 0; j < vector_active (adj->from); j++) if (vector_slot (adj->from, j) == node) vector_unset (adj->from, j); - - // if the node is orphaned, delete it - if (vector_active (adj->to) == 0 && - vector_active (adj->from) == 0 && - adj != node) - graph_delete_node (graph, adj); } - // if there is a deletion callback, call it! + // if there is a deletion callback, call it if (node->del && node->data) (*node->del) (node->data); diff --git a/lib/graph.h b/lib/graph.h index bccbbb94a0..b6a03b938a 100644 --- a/lib/graph.h +++ b/lib/graph.h @@ -61,10 +61,6 @@ graph_new_node (struct graph *graph, void *data, void (*del) (void*)); * Before deletion, this function removes all edges to and from this node from * any neighbor nodes. * - * If, as a result of this operation, any neighbor node has no edges either to - * or from itself, that node will be deleted as well. If the graph topology is - * e.g. a star this will result in the deletion of all nodes. - * * If *data and *del are non-null, the following call is made: * (*node->del) (node->data); * -- 2.39.5