From: Matthew Fernandez Date: Fri, 30 Dec 2022 17:44:06 +0000 (-0800) Subject: sfdpgen: remove 'PriorityQueue' code X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=51cffd3ee2f0578f419ccfe8e6674a1bd6fbb3e3;p=graphviz sfdpgen: remove 'PriorityQueue' code The last use of this was removed in d42aea4877c8ff9ea0d1cc4f23b45f2d1b958622. --- diff --git a/ci/clang_format.py b/ci/clang_format.py index c52102ef6..84788a23a 100644 --- a/ci/clang_format.py +++ b/ci/clang_format.py @@ -518,8 +518,6 @@ EXCLUDE = ( "lib/rbtree/test_red_black_tree.c", "lib/sfdpgen/Multilevel.c", "lib/sfdpgen/Multilevel.h", - "lib/sfdpgen/PriorityQueue.c", - "lib/sfdpgen/PriorityQueue.h", "lib/sfdpgen/post_process.c", "lib/sfdpgen/post_process.h", "lib/sfdpgen/sfdp.h", diff --git a/cmd/gvmap/country_graph_coloring.c b/cmd/gvmap/country_graph_coloring.c index f5ad497e5..6a44c4cfe 100644 --- a/cmd/gvmap/country_graph_coloring.c +++ b/cmd/gvmap/country_graph_coloring.c @@ -12,8 +12,6 @@ #include "country_graph_coloring.h" #include #include "power.h" - -#include #include #include diff --git a/lib/sfdpgen/CMakeLists.txt b/lib/sfdpgen/CMakeLists.txt index a562422e4..493699af9 100644 --- a/lib/sfdpgen/CMakeLists.txt +++ b/lib/sfdpgen/CMakeLists.txt @@ -6,7 +6,6 @@ add_library(sfdpgen STATIC # Header files Multilevel.h post_process.h - PriorityQueue.h sfdp.h sfdpinternal.h sparse_solve.h @@ -17,7 +16,6 @@ add_library(sfdpgen STATIC # Source files Multilevel.c post_process.c - PriorityQueue.c sfdpinit.c sparse_solve.c spring_electrical.c diff --git a/lib/sfdpgen/Makefile.am b/lib/sfdpgen/Makefile.am index 5bfaa72bc..1677b7702 100644 --- a/lib/sfdpgen/Makefile.am +++ b/lib/sfdpgen/Makefile.am @@ -16,7 +16,7 @@ endif noinst_HEADERS = sfdpinternal.h spring_electrical.h \ sparse_solve.h post_process.h \ stress_model.h uniform_stress.h \ - Multilevel.h sfdp.h PriorityQueue.h + Multilevel.h sfdp.h if WITH_SFDP noinst_LTLIBRARIES = libsfdpgen_C.la @@ -25,6 +25,6 @@ endif libsfdpgen_C_la_SOURCES = sfdpinit.c spring_electrical.c \ sparse_solve.c post_process.c \ stress_model.c uniform_stress.c \ - Multilevel.c PriorityQueue.c + Multilevel.c EXTRA_DIST = sfdp.vcxproj* diff --git a/lib/sfdpgen/Multilevel.c b/lib/sfdpgen/Multilevel.c index 1bc2e6fd5..440d0bd66 100644 --- a/lib/sfdpgen/Multilevel.c +++ b/lib/sfdpgen/Multilevel.c @@ -9,7 +9,6 @@ *************************************************************************/ #include -#include #include #include #include diff --git a/lib/sfdpgen/PriorityQueue.c b/lib/sfdpgen/PriorityQueue.c deleted file mode 100644 index b56d65c7a..000000000 --- a/lib/sfdpgen/PriorityQueue.c +++ /dev/null @@ -1,187 +0,0 @@ -/************************************************************************* - * Copyright (c) 2011 AT&T Intellectual Property - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: Details at https://graphviz.org - *************************************************************************/ - -#include -#include -#include -#include -#include -#include - -PriorityQueue PriorityQueue_new(int n, int ngain){ - PriorityQueue q; - int i; - q = N_GNEW(1,struct PriorityQueue_struct); - q->count = 0; - q->n = n; - q->ngain = ngain; - q->gain_max = -1;/* no entries yet */ - q->buckets = N_GNEW((ngain+1),DoubleLinkedList); - for (i = 0; i < ngain+1; i++) (q->buckets)[i] = NULL; - - q->where = N_GNEW((n+1),DoubleLinkedList); - for (i = 0; i < n+1; i++) (q->where)[i] = NULL; - - q->gain = N_GNEW((n+1),int); - for (i = 0; i < n+1; i++) (q->gain)[i] = -999; - return q; - -} - -void PriorityQueue_delete(PriorityQueue q){ - int i; - - if (q){ - if (q->buckets){ - for (i = 0; i < q->ngain+1; i++) DoubleLinkedList_delete((q->buckets)[i], free); - free(q->buckets); - } - - free(q->where); - - free(q->gain); - free(q); - } -} - -PriorityQueue PriorityQueue_push(PriorityQueue q, int i, int gain){ - DoubleLinkedList l; - int *data, gainold; - - assert(q); - assert(gain <= q->ngain); - - - if (!(q->where)[i]){ - /* this entry is no in the queue yet, so this is a new addition */ - - (q->count)++; - if (gain > q->gain_max) q->gain_max = gain; - q->gain[i] = gain; - - data = N_GNEW(1,int); - data[0] = i; - if ((l = (q->buckets)[gain])){ - (q->buckets)[gain] = (q->where)[i] = DoubleLinkedList_prepend(l, data); - } else { - (q->buckets)[gain] = (q->where)[i] = DoubleLinkedList_new(data); - } - - } else { - /* update gain for an exisiting entry */ - l = q->where[i]; - gainold = q->gain[i]; - q->where[i] = NULL; - (q->count)--; - DoubleLinkedList_delete_element(l, free, &((q->buckets)[gainold])); - return PriorityQueue_push(q, i, gain); - } - return q; -} - -int PriorityQueue_pop(PriorityQueue q, int *i, int *gain){ - int gain_max; - DoubleLinkedList l; - int *data; - - if (!q || q->count <= 0) return 0; - *gain = gain_max = q->gain_max; - (q->count)--; - l = (q->buckets)[gain_max]; - data = DoubleLinkedList_get_data(l); - *i = data[0]; - - DoubleLinkedList_delete_element(l, free, &((q->buckets)[gain_max])); - if (!(q->buckets)[gain_max]){/* the bin that contain the best gain is empty now after poping */ - while (gain_max >= 0 && !(q->buckets)[gain_max]) gain_max--; - q->gain_max = gain_max; - } - q->where[*i] = NULL; - q->gain[*i] = -999; - return 1; -} - - - - -int PriorityQueue_get_gain(PriorityQueue q, int i){ - return q->gain[i]; -} - -int PriorityQueue_remove(PriorityQueue q, int i){ - /* remove an entry from the queue. If error, return 0. */ - int gain, gain_max; - DoubleLinkedList l; - - if (!q || q->count <= 0) return 0; - gain = q->gain[i]; - (q->count)--; - l = (q->where)[i]; - - DoubleLinkedList_delete_element(l, free, &((q->buckets)[gain])); - - if (gain == (gain_max = q->gain_max) && !(q->buckets)[gain_max]){/* the bin that contain the best gain is empty now after poping */ - while (gain_max >= 0 && !(q->buckets)[gain_max]) gain_max--; - q->gain_max = gain_max; - } - q->where[i] = NULL; - q->gain[i] = -999; - return 1; -} - -/* - -main(){ - int i, gain; - - - PriorityQueue q; - q = PriorityQueue_new(10,100); - PriorityQueue_push(q, 3, 1); - PriorityQueue_push(q, 2, 2); - PriorityQueue_push(q, 4, 2); - PriorityQueue_push(q, 5, 2); - PriorityQueue_push(q, 1, 100); - PriorityQueue_push(q, 2, 1); - while (PriorityQueue_pop(q, &i, &gain)){ - printf("i = %d gain = %d\n", i, gain); - } - - printf("=========\n"); - PriorityQueue_push(q, 3, 1); - PriorityQueue_push(q, 2, 2); - PriorityQueue_push(q, 4, 2); - PriorityQueue_push(q, 5, 2); - PriorityQueue_push(q, 1, 100); - PriorityQueue_push(q, 2, 1); - PriorityQueue_push(q, 2, 100); - while (PriorityQueue_pop(q, &i, &gain)){ - printf("i = %d gain = %d\n", i, gain); - } - - - printf("====after removing 3 and 2 =====\n"); - PriorityQueue_push(q, 3, 1); - PriorityQueue_push(q, 2, 2); - PriorityQueue_push(q, 4, 2); - PriorityQueue_push(q, 5, 2); - PriorityQueue_push(q, 1, 100); - PriorityQueue_push(q, 2, 1); - PriorityQueue_push(q, 2, 100); - PriorityQueue_remove(q, 3); - PriorityQueue_remove(q, 2); - while (PriorityQueue_pop(q, &i, &gain)){ - printf("i = %d gain = %d\n", i, gain); - } - PriorityQueue_delete(q); - -} - -*/ diff --git a/lib/sfdpgen/PriorityQueue.h b/lib/sfdpgen/PriorityQueue.h deleted file mode 100644 index 3a2d9fad4..000000000 --- a/lib/sfdpgen/PriorityQueue.h +++ /dev/null @@ -1,39 +0,0 @@ -#pragma once -#include -struct PriorityQueue_struct { - /* a simple priority queue structure: entries are all integers, gains are all integers in [0, gainmax], total n elements */ - int count;/* how many entries are in?*/ - - /* max index value of an entry */ - int n; - - /* only ngain buckets are allowed */ - int ngain; - - /* current highest gain */ - int gain_max; - - /* the ngain buckets. Each bucket i holds all entries with gain = i.*/ - DoubleLinkedList *buckets; - - /* a mapping which maps an entry's index to an element in a DoubleLinkedList */ - DoubleLinkedList *where; - - /* the gain of entry i is gain[i] */ - int *gain; -}; - -typedef struct PriorityQueue_struct *PriorityQueue; - - -PriorityQueue PriorityQueue_new(int n, int ngain); - -void PriorityQueue_delete(PriorityQueue q); - -/* if entry i is already in the list, then an update of gain is carried out*/ -PriorityQueue PriorityQueue_push(PriorityQueue q, int i, int gain); - -int PriorityQueue_pop(PriorityQueue q, int *i, int *gain);/* return 0 if nmothing left, 1 otherwise */ - -int PriorityQueue_remove(PriorityQueue q, int i);/* return 0 if error */ -int PriorityQueue_get_gain(PriorityQueue q, int i); diff --git a/lib/sfdpgen/sfdp.vcxproj b/lib/sfdpgen/sfdp.vcxproj index 923cc6271..d25f64448 100644 --- a/lib/sfdpgen/sfdp.vcxproj +++ b/lib/sfdpgen/sfdp.vcxproj @@ -80,7 +80,6 @@ - diff --git a/lib/sfdpgen/sfdp.vcxproj.filters b/lib/sfdpgen/sfdp.vcxproj.filters index b9f507495..abec0214b 100644 --- a/lib/sfdpgen/sfdp.vcxproj.filters +++ b/lib/sfdpgen/sfdp.vcxproj.filters @@ -26,9 +26,6 @@ Source Files - - Source Files - Source Files