diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index f15649c..65cee33 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -1,6 +1,6 @@ ## Description -Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context. List any dependencies that are required for this change. +Please include a summary of the change and which issue is fixed. Also include relevant motivation and context. List any dependencies that are required for this change. Fixes # (issue) @@ -15,7 +15,7 @@ Please delete options that are not relevant. ## How Has This Been Tested? -Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration. +Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Also list any relevant details for your test configuration. - [ ] Test A - [ ] Test B diff --git a/CHANGELOG.md b/CHANGELOG.md index 8a2c366..bddb140 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -76,4 +76,4 @@ All notable changes to this project will be documented in this file. - Added a badge for the code style (Ruff) in the README. - Added a badge for the license in the README. - Added CI/CD pipelines for PyPI deployment (including test coverage, compiling extensions and wheels, and uploading to PyPI). -- Resolving issues with compiling Cython extensions on Windows and MacOS. +- Resolving issues with compiling Cython extensions on Windows and macOS. diff --git a/README.md b/README.md index 9b9cf78..d4fe58b 100644 --- a/README.md +++ b/README.md @@ -72,7 +72,7 @@ print(labels) ## Documentation -You can find the full documentation for Radius Clustering [here](https://contrib.scikit-learn.org/radius_clustering/). +See the [full documentation for Radius Clustering](https://contrib.scikit-learn.org/radius_clustering/). ### Building the documentation diff --git a/docs/source/details.rst b/docs/source/details.rst index 379c336..ff50cc3 100644 --- a/docs/source/details.rst +++ b/docs/source/details.rst @@ -28,7 +28,7 @@ The Radius Clustering package implements a clustering algorithm based on the Min The MDS problem is a well-known NP-Hard problem in graph theory, and it has been proven to be linked to the clustering under radius constraint problem. The MDS problem is defined as follows: -Given a undirected weighted graph :math:`G = (V,E)` where :math:`V` is a set of vertices and :math:`E` is a set of edges, +Given an undirected weighted graph :math:`G = (V,E)` where :math:`V` is a set of vertices and :math:`E` is a set of edges, a dominating set :math:`D` is a subset of :math:`V` such that every vertex in :math:`V` is either in :math:`D` or adjacent to a vertex in :math:`D`. The goal is to find a dominating set :math:`D` such that the number of vertices in :math:`D` is minimized. This problem is known to be NP-Hard. diff --git a/docs/source/installation.rst b/docs/source/installation.rst index c2b93d6..62b13ce 100644 --- a/docs/source/installation.rst +++ b/docs/source/installation.rst @@ -67,7 +67,7 @@ Installing from PyPI python -m pip show radius-clustering # show radius-clustering version and location python -m pip freeze # show all installed packages in the environment - .. tab-item:: MacOS + .. tab-item:: macOS :class-label: tab-4 :sync: macos @@ -183,7 +183,7 @@ To install Radius Clustering from the source, you need to have a C and C++ compi In Build Tools, install C++ toolchain. Ensure that it is added to the system PATH. You are now ready to install Radius Clustering from source. - .. tab-item:: MacOS + .. tab-item:: macOS :class-label: tab-4 :sync: macos diff --git a/examples/plot_iris_example.py b/examples/plot_iris_example.py index c31d9a5..bf02f19 100644 --- a/examples/plot_iris_example.py +++ b/examples/plot_iris_example.py @@ -255,7 +255,7 @@ def get_order_labels(kmeans, rad, data): t_kmeans = time.time() - t0 # %% -# Reapllying the same process as before +# Reapplying the same process as before # -------------------------------------- rad_centers_index = np.array(rad.centers_) diff --git a/src/radius_clustering/utils/main-emos.c b/src/radius_clustering/utils/main-emos.c index bce003e..e30a557 100644 --- a/src/radius_clustering/utils/main-emos.c +++ b/src/radius_clustering/utils/main-emos.c @@ -131,24 +131,24 @@ static int test_2adj(int node1,int node2){ assert(marked(node)==0); } set_marked_status(node1); - for_each_neighbor(node1,neibor){ - if(involved(neibor)){ - set_marked_status(neibor); + for_each_neighbor(node1,neighbor){ + if(involved(neighbor)){ + set_marked_status(neighbor); } } int adj=0; - for_each_neighbor(node2,neibor){ - if(neibor==node1) + for_each_neighbor(node2,neighbor){ + if(neighbor==node1) adj=1; - if(involved(neibor) && !branched(neibor) && marked(neibor)){ + if(involved(neighbor) && !branched(neighbor) && marked(neighbor)){ flag=1; break; } } clr_marked_status(node1); - for_each_neighbor(node1,neibor){ - if(involved(neibor)) - clr_marked_status(neibor); + for_each_neighbor(node1,neighbor){ + if(involved(neighbor)) + clr_marked_status(neighbor); } if(flag) return flag; @@ -191,11 +191,11 @@ two vertices adj iif: */ static inline int is_2_adj(int marked_node,int test_node){ - for_each_neighbor(test_node,neibor){ - if(neibor==marked_node){ + for_each_neighbor(test_node,neighbor){ + if(neighbor==marked_node){ if(!(branched(test_node) && branched(marked_node))) return 1; - }else if(involved(neibor) && !branched(neibor) && marked(neibor)) + }else if(involved(neighbor) && !branched(neighbor) && marked(neighbor)) return 1; } return 0; @@ -235,15 +235,15 @@ static void build_adjacent_matrix_for_free_nodes(){ for(int j=0;jPID[node1].newid); set_adj_bit(idx,PID[node1].newid); break; @@ -258,9 +258,9 @@ static void build_adjacent_matrix_for_free_nodes(){ } } clr_marked_status(node); - for_each_neighbor(node,neibor){ - if(active(neibor) && involved(neibor)) - clr_marked_status(neibor); + for_each_neighbor(node,neighbor){ + if(active(neighbor) && involved(neighbor)) + clr_marked_status(neighbor); } } for(int i=SUB_PROBLEM_SIZE-1;i>=CUR_UND_IDX;i--){ @@ -330,16 +330,16 @@ static inline int insert_cur_node(int node){ -static void test_iset_consistance(){ +static void test_iset_consistency(){ for(int j=0;jmaxlb){ @@ -626,9 +626,9 @@ static int repartition_vertices(int maxlb){ continue; set_marked_status(node); - for_each_neighbor(node,neibor){ - if(active(neibor)) - set_marked_status(neibor); + for_each_neighbor(node,neighbor){ + if(active(neighbor)) + set_marked_status(neighbor); } for(int j=isno(node)+1;j>%d is absorbed @%d\n",node,CUR_LEVEL); return TRUE; } -static void reduce_dominated_vertice(){ +static void reduce_dominated_vertices(){ for(int i=CUR_LEVEL;imax_count){ @@ -928,12 +928,12 @@ static void push_fixed_vertices(){ set_domed_status(prenode); set_branched_status(prenode); - for_each_neighbor(prenode,neibor){ - if(active(neibor) && !domed(neibor)){ + for_each_neighbor(prenode,neighbor){ + if(active(neighbor) && !domed(neighbor)){ int first=CFG[CUR_UND_IDX]; - if(first!=neibor) - swap_cfg(first,neibor); - set_domed_status(neibor); + if(first!=neighbor) + swap_cfg(first,neighbor); + set_domed_status(neighbor); CUR_UND_IDX++; } } @@ -974,8 +974,8 @@ static inline void sorting_branch_vertices(int startidx){ assert(!branched(bnode)); if(!domed(bnode)) count=1; - for_each_neighbor(bnode,neibor){ - if(active(neibor) && !domed(neibor)) + for_each_neighbor(bnode,neighbor){ + if(active(neighbor) && !domed(neighbor)) count++; } Node_Degree[bnode]=count; @@ -992,7 +992,7 @@ void search_domset(){ #endif while(CUR_LEVEL>=0){ #if CHECK - check_consistance(); + check_consistency(); #endif if((bnode=CUR_BRA_NODE)!=NONE){ rollback_branch_node(bnode); @@ -1032,14 +1032,14 @@ void search_domset(){ domc++; } - for_each_neighbor(bnode,neibor){ - if(active(neibor) && !domed(neibor)){ + for_each_neighbor(bnode,neighbor){ + if(active(neighbor) && !domed(neighbor)){ domc++; - assert(!fixed(neibor)); + assert(!fixed(neighbor)); int first=CFG[CUR_UND_IDX]; - if(first!=neibor) - swap_cfg(first,neibor); - set_domed_status(neibor); + if(first!=neighbor) + swap_cfg(first,neighbor); + set_domed_status(neighbor); CUR_UND_IDX++; } } @@ -1070,7 +1070,7 @@ void search_domset(){ } #endif #ifdef CHECK - test_iset_consistance(); + test_iset_consistency(); #endif #else for(int i=SUB_PROBLEM_SIZE-1;i>=CUR_UND_IDX;i--){ @@ -1102,8 +1102,8 @@ void search_domset(){ int count=0; if(domed(node)){ - for_each_neighbor(node,neibor){ - if(active(neibor) && !domed(neibor)){ + for_each_neighbor(node,neighbor){ + if(active(neighbor) && !domed(neighbor)){ count++; break; } @@ -1189,11 +1189,11 @@ int fast_search_initial_solution(){ if(fixed(node)){ push_back(VEC_SOLUTION,int,node); set_branched_status(node); - for_each_neighbor(node,neibor){ - if(!active(neibor) || node==neibor)continue; - if(!domed(neibor)){ + for_each_neighbor(node,neighbor){ + if(!active(neighbor) || node==neighbor)continue; + if(!domed(neighbor)){ NB_Domed++; - set_domed_status(neibor); + set_domed_status(neighbor); } } if(!domed(node)){ @@ -1207,9 +1207,9 @@ int fast_search_initial_solution(){ if(fixed(node))continue; if(!domed(node))Val[node]=1; else Val[node]=0; - for_each_neighbor(node,neibor){ - if(neibor==node)continue; - if(active(neibor) && !domed(neibor)){ + for_each_neighbor(node,neighbor){ + if(neighbor==node)continue; + if(active(neighbor) && !domed(neighbor)){ Val[node]++; } } @@ -1233,13 +1233,13 @@ int fast_search_initial_solution(){ assert(Val[bnode]>0 && Val[bnode]<=Node_Degree[bnode]+1); push_back(VEC_SOLUTION,int,bnode); set_branched_status(bnode); - for_each_neighbor(bnode,neibor){ - if(!active(neibor) || bnode==neibor)continue; - if(!domed(neibor)){ + for_each_neighbor(bnode,neighbor){ + if(!active(neighbor) || bnode==neighbor)continue; + if(!domed(neighbor)){ NB_Domed++; - set_domed_status(neibor); - for_each_neighbor(neibor,nei)if(active(nei) && !fixed(nei) && nei!=neibor)Val[nei]--; - Val[neibor]--; + set_domed_status(neighbor); + for_each_neighbor(neighbor,nei)if(active(nei) && !fixed(nei) && nei!=neighbor)Val[nei]--; + Val[neighbor]--; } } if(!domed(bnode)){ @@ -1278,8 +1278,8 @@ static int search_initial_solution(){ if(!domed(node)) count=1; - for_each_neighbor(node,neibor){ - if(active(neibor) && !domed(neibor)) + for_each_neighbor(node,neighbor){ + if(active(neighbor) && !domed(neighbor)) count++; } if(count>max){ @@ -1292,8 +1292,8 @@ static int search_initial_solution(){ push_back(VEC_SOLUTION,int,bnode); set_domed_status(bnode); set_branched_status(bnode); - for_each_neighbor(bnode,neibor){ - set_domed_status(neibor); + for_each_neighbor(bnode,neighbor){ + set_domed_status(neighbor); } }else{ int *ptr=CFG,*end=CFG+SUB_PROBLEM_SIZE; @@ -1394,8 +1394,8 @@ void check_final_solution(){ set_marked_status(node); assert(!included(node)); set_included_status(node); - for_each_neighbor(node,neibor){ - set_marked_status(neibor); + for_each_neighbor(node,neighbor){ + set_marked_status(neighbor); } } @@ -1410,8 +1410,8 @@ void check_final_solution(){ for_each_vertex(node){ if(deleted(node)){ int flag=0; - for_each_neighbor(node,neibor){ - if(included(neibor)){ + for_each_neighbor(node,neighbor){ + if(included(neighbor)){ flag=1; break; } @@ -1443,9 +1443,9 @@ void check_and_save_solution(){ set_included_status(node); push_back(VEC_SOLUTION,int,node); set_marked_status(node); - for_each_neighbor(node,neibor){ - if(active(neibor)) - set_marked_status(neibor); + for_each_neighbor(node,neighbor){ + if(active(neighbor)) + set_marked_status(neighbor); } } for_each_vertex(node){ @@ -1456,7 +1456,7 @@ void check_and_save_solution(){ } } -void check_consistance(){ +void check_consistency(){ for(int i=0;i=1 && CFG[i]<=NB_NODE); @@ -1485,15 +1485,15 @@ void check_consistance(){ int node=branch_node_at_level(i); assert(node>=1 && node<=NB_NODE); assert(domed(node)); - for_each_neighbor(node,neibor){ - if(!active(neibor)) + for_each_neighbor(node,neighbor){ + if(!active(neighbor)) continue; - assert(domed(neibor)); - assert(active(neibor)); - assert(LOC[neibor] free_size) { - Node_Neibors[i] = (int *) malloc(block_size * sizeof(int)); - BLOCK_LIST[BLOCK_COUNT++] = Node_Neibors[i]; + Node_Neighbors[i] = (int *) malloc(block_size * sizeof(int)); + BLOCK_LIST[BLOCK_COUNT++] = Node_Neighbors[i]; free_size = block_size - (Node_Degree[i - offset] + 1); } else { - Node_Neibors[i] = Node_Neibors[i - 1] + Node_Neighbors[i] = Node_Neighbors[i - 1] + Node_Degree[i - 1 - offset] + 1; free_size = free_size - (Node_Degree[i - offset] + 1); } @@ -275,9 +275,9 @@ static void allcoate_memory_for_adjacency_list(int nb_node, int nb_edge,int offs } else { BLOCK_COUNT = 1; BLOCK_LIST[BLOCK_COUNT - 1] = Init_Adj_List; - Node_Neibors[1] = Init_Adj_List; + Node_Neighbors[1] = Init_Adj_List; for (i = 2; i <= NB_NODE; i++) { - Node_Neibors[i] = Node_Neibors[i - 1] + Node_Degree[i - 1 - offset] + Node_Neighbors[i] = Node_Neighbors[i - 1] + Node_Degree[i - 1 - offset] + 1; } } @@ -308,8 +308,8 @@ static int _read_graph_from_edge_list(unsigned int* edges, int n, int nb_edges) } NB_NODE = max_node; - Node_Neibors = (int **)malloc((NB_NODE + 1) * sizeof(int *)); - allcoate_memory_for_adjacency_list(NB_NODE, nb_edge, 1); + Node_Neighbors = (int **)malloc((NB_NODE + 1) * sizeof(int *)); + allocate_memory_for_adjacency_list(NB_NODE, nb_edge, 1); memset(Node_Degree, 0, (NB_NODE + 1) * sizeof(int)); nb_edge = 0; @@ -322,13 +322,13 @@ static int _read_graph_from_edge_list(unsigned int* edges, int n, int nb_edges) r_node += offset; } for (i = 0; i < Node_Degree[l_node]; i++) { - if (Node_Neibors[l_node][i] == r_node) + if (Node_Neighbors[l_node][i] == r_node) break; } if (i == Node_Degree[l_node]) { - Node_Neibors[l_node][Node_Degree[l_node]] = r_node; - Node_Neibors[r_node][Node_Degree[r_node]] = l_node; + Node_Neighbors[l_node][Node_Degree[l_node]] = r_node; + Node_Neighbors[r_node][Node_Degree[r_node]] = l_node; Node_Degree[l_node]++; Node_Degree[r_node]++; nb_edge++; @@ -339,7 +339,7 @@ static int _read_graph_from_edge_list(unsigned int* edges, int n, int nb_edges) NB_EDGE = nb_edge; Max_Degree = 0; for (node = 1; node <= NB_NODE; node++) { - Node_Neibors[node][Node_Degree[node]] = NONE; + Node_Neighbors[node][Node_Degree[node]] = NONE; if (Node_Degree[node] > Max_Degree) { Max_Degree = Node_Degree[node]; Max_Degree_Node = node; @@ -387,50 +387,50 @@ static inline void reduce_graph2(){ if(deleted(node))continue; set_marked_status(node); - for_each_neighbor(node,neibor){ - set_marked_status(neibor); + for_each_neighbor(node,neighbor){ + set_marked_status(neighbor); } - for_each_neighbor(node,neibor){ - if(fixed(neibor)){ - set_branched_status(neibor); + for_each_neighbor(node,neighbor){ + if(fixed(neighbor)){ + set_branched_status(neighbor); continue; } - for_each_neighbor(neibor,neibor2){ - if(!marked(neibor2)){ - set_branched_status(neibor); + for_each_neighbor(neighbor,neighbor2){ + if(!marked(neighbor2)){ + set_branched_status(neighbor); break; } } } - for_each_neighbor(node,neibor){ - if(branched(neibor)) + for_each_neighbor(node,neighbor){ + if(branched(neighbor)) continue; - for_each_neighbor(neibor,neibor2){ - if(branched(neibor2)){ - set_involved_status(neibor); + for_each_neighbor(neighbor,neighbor2){ + if(branched(neighbor2)){ + set_involved_status(neighbor); break; } } - if(!involved(neibor)){ + if(!involved(neighbor)){ fixed(node)=1; break; } } if(fixed(node)){ - for_each_neighbor(node,neibor){ - if(!branched(neibor)) - deleted(neibor)=1; + for_each_neighbor(node,neighbor){ + if(!branched(neighbor)) + deleted(neighbor)=1; } } clr_marked_status(node); - for_each_neighbor(node,neibor){ - clr_marked_status(neibor); - clr_involved_status(neibor); - clr_branched_status(neibor); + for_each_neighbor(node,neighbor){ + clr_marked_status(neighbor); + clr_involved_status(neighbor); + clr_branched_status(neighbor); } } @@ -441,10 +441,10 @@ static inline void reduce_graph2(){ if(deleted(node)) continue; - int *ptr=Node_Neibors[node],count=0; - for_each_neighbor(node,neibor){ - if(!deleted(neibor)){ - *ptr++=neibor;count++; + int *ptr=Node_Neighbors[node],count=0; + for_each_neighbor(node,neighbor){ + if(!deleted(neighbor)){ + *ptr++=neighbor;count++; } } *ptr=NONE; @@ -476,7 +476,7 @@ static inline void reduce_graph(){ Me = Que[Ql++]; if (Dis[Me] == 2)break; for (int j = 0; j < Node_Degree[Me]; j++) { - tt = Node_Neibors[Me][j]; + tt = Node_Neighbors[Me][j]; //if(Deleted[tt])continue; //if(Me==1)printf("**%d\n",tt); if (Dis[tt] <= 1)continue; @@ -498,7 +498,7 @@ static inline void reduce_graph(){ if(Col[Que[j]]==1)continue; Me=Que[j]; for(int k=0;k