Skip to content

Commit c79c2c7

Browse files
authored
Merge pull request #7 from lias-laboratory/memory-cleanup
New minor release and memory efficiency enhanced
2 parents f776e83 + 97bd70c commit c79c2c7

File tree

4 files changed

+54
-278
lines changed

4 files changed

+54
-278
lines changed

README.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,6 @@ You can install Radius Clustering using pip:
2626
pip install radius-clustering
2727
```
2828

29-
> Note: This package is not yet available on PyPI. You may need to install it from the source.
30-
3129
## Usage
3230

3331
Here's a basic example of how to use Radius Clustering:
@@ -53,7 +51,11 @@ print(labels)
5351

5452
## Documentation
5553

56-
To build the documentation, you can run the following command, assuming you have Sphinx installed:
54+
You can find the full documentation for Radius Clustering [here](https://lias-laboratory.github.io/radius_clustering/).
55+
56+
### Building the documentation
57+
58+
To build the documentation, you can run the following command, assuming you have all dependencies needed installed:
5759

5860
```bash
5961
cd docs
@@ -73,7 +75,7 @@ If you want to know more about the experiments conducted with the package, pleas
7375

7476
## Contributing
7577

76-
Contributions to MDS Clustering are welcome! Please feel free to submit a Pull Request.
78+
Contributions to Radius Clustering are welcome! Please feel free to submit a Pull Request.
7779

7880
## License
7981

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
44

55
[project]
66
name = "radius-clustering"
7-
version = "1.0.1"
7+
version = "1.1.0"
88
description = "A Clustering under radius constraints algorithm using minimum dominating sets"
99
readme = "README.md"
1010
authors = [

radius_clustering/utils/main-emos.c

Lines changed: 38 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,6 @@ two vertices adj iif:
191191
*/
192192

193193
static inline int is_2_adj(int marked_node,int test_node){
194-
int adj=0, comneibor=0;
195194
for_each_neighbor(test_node,neibor){
196195
if(neibor==marked_node){
197196
if(!(branched(test_node) && branched(marked_node)))
@@ -534,7 +533,6 @@ static int partition_free_vertices(){
534533
}
535534

536535
static inline void clear_iset(int isetno,int insert_node){
537-
int marked_count=0;
538536
int involved=involved(insert_node);
539537
USED(TMP_STK)=0;
540538
for_each_vec_item(iSET[isetno],int,it){
@@ -570,7 +568,6 @@ static inline void clear_iset(int isetno,int insert_node){
570568
static int improve_partition(int maxlb,int target){
571569
for(int i=SUB_PROBLEM_SIZE-1;i>=CUR_UND_IDX;i--){
572570
int node=CFG[i];
573-
int inserted=0;
574571

575572
set_marked_status(node);
576573
for_each_neighbor(node,neibor){
@@ -634,7 +631,6 @@ static int repartition_vertices(int maxlb){
634631
set_marked_status(neibor);
635632
}
636633

637-
int inserted=0;
638634
for(int j=isno(node)+1;j<MAXIS;j++){
639635
if(USED(iSET[j])==0){
640636
break;
@@ -861,7 +857,7 @@ static int dominated_number(int bnode){
861857
}
862858

863859
int max_dominated_number(){
864-
int max_count=0,max_idx=-1;
860+
int max_count=0;
865861
for(int i=CUR_BRA_IDX,bnode=BNODE(i);bnode!=NONE;bnode=BNODE(++i)){
866862
int count= dominated_number(bnode);
867863
if(count>max_count)
@@ -1382,16 +1378,6 @@ void solve_subproblems(){
13821378
}while(ptr<end);
13831379
}
13841380

1385-
static void print_final_solution(char *inst){
1386-
printf("--------------------------------\n");
1387-
printf("Solution: ");
1388-
for(size_t i=0;i<USED(VEC_SOLUTION);i++){
1389-
printf("%d ",ITEM(VEC_SOLUTION,i));
1390-
}
1391-
printf("\n");
1392-
printf(">>> %s |V| %d |E| %d FIXED %d INIT %d BEST %d TREE %llu TIME(s) %0.2lf\n",inst,NB_NODE,NB_EDGE,NB_FIXED,INIT_UPPER_BOUND,USED(VEC_SOLUTION),NB_TREE, get_utime());
1393-
}
1394-
13951381
// Define global variables
13961382
extern unsigned long long total_branches = 0;
13971383
extern unsigned long long pruned_branches = 0;
@@ -1513,6 +1499,43 @@ void check_consistance(){
15131499

15141500

15151501
void cleanup(){
1502+
1503+
// Free all allocated memory
1504+
if (CFG != NULL) {
1505+
free(CFG);
1506+
CFG = NULL;
1507+
}
1508+
if (LOC != NULL) {
1509+
free(LOC);
1510+
LOC = NULL;
1511+
}
1512+
if (STATUS != NULL) {
1513+
free(STATUS);
1514+
STATUS = NULL;
1515+
}
1516+
if (PID != NULL) {
1517+
free(PID);
1518+
PID = NULL;
1519+
}
1520+
free_stack(BRA_STK);
1521+
free_stack(FIX_STK);
1522+
free_stack(TMP_STK);
1523+
free_stack(ADJ_STK);
1524+
free_stack(VEC_SOLUTION);
1525+
free_stack(VEC_SUBGRAPHS);
1526+
1527+
for (int i = 0; i <= MAXIS; i++) {
1528+
free_stack(iSET[i]);
1529+
}
1530+
1531+
if (ADJIDX != NULL) {
1532+
free(ADJIDX);
1533+
ADJIDX = NULL;
1534+
}
1535+
1536+
1537+
1538+
free_block();
15161539
// Reset all global variables
15171540
BLOCK_COUNT = 0;
15181541
NB_NODE = 0;
@@ -1541,59 +1564,6 @@ void cleanup(){
15411564
CUT_OFF = 0;
15421565
BEST_SOL_TIME = 0;
15431566
instance[0] = '\0';
1544-
1545-
// Free all allocated memory
1546-
if (CFG != NULL) {
1547-
free(CFG);
1548-
CFG = NULL;
1549-
}
1550-
if (LOC != NULL) {
1551-
free(LOC);
1552-
LOC = NULL;
1553-
}
1554-
if (STATUS != NULL) {
1555-
free(STATUS);
1556-
STATUS = NULL;
1557-
}
1558-
if (PID != NULL) {
1559-
free(PID);
1560-
PID = NULL;
1561-
}
1562-
if (BRA_STK != NULL) {
1563-
free(BRA_STK);
1564-
BRA_STK = NULL;
1565-
}
1566-
if (FIX_STK != NULL) {
1567-
free(FIX_STK);
1568-
FIX_STK = NULL;
1569-
}
1570-
if (TMP_STK != NULL) {
1571-
free(TMP_STK);
1572-
TMP_STK = NULL;
1573-
}
1574-
if (ADJ_STK != NULL) {
1575-
free(ADJ_STK);
1576-
ADJ_STK = NULL;
1577-
}
1578-
if (ADJIDX != NULL) {
1579-
free(ADJIDX);
1580-
ADJIDX = NULL;
1581-
}
1582-
if (VEC_SOLUTION != NULL) {
1583-
free(VEC_SOLUTION);
1584-
VEC_SOLUTION = NULL;
1585-
}
1586-
if (VEC_SUBGRAPHS != NULL) {
1587-
free(VEC_SUBGRAPHS);
1588-
VEC_SUBGRAPHS = NULL;
1589-
}
1590-
1591-
for (int i = 0; i <= MAXIS; i++) {
1592-
if (iSET[i] != NULL) {
1593-
free(iSET[i]);
1594-
iSET[i] = NULL;
1595-
}
1596-
}
15971567
}
15981568

15991569

0 commit comments

Comments
 (0)