home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
vis-ftp.cs.umass.edu
/
vis-ftp.cs.umass.edu.tar
/
vis-ftp.cs.umass.edu
/
pub
/
Software
/
ASCENDER
/
ascendMar8.tar
/
UMass
/
BuildingFinder
/
Staging
/
sortNodes.c
< prev
next >
Wrap
C/C++ Source or Header
|
1994-01-24
|
1KB
|
69 lines
#include "../polygons.h"
MGvertexList *sort_top_K_nodes(MGvertex *meta_graph, int k)
{
int size, i;
MGvertexList *list;
MGvertex *node;
MGedgeList *eptr;
double max = 999999.99;
double newmax;
fprintf(stderr,"Sorting top %d nodes\n",k);
list = (MGvertexList *) malloc(sizeof(MGvertexList));
list->eList = (MGedgeList *) malloc(sizeof(MGedgeList));
node = get_max_MG(meta_graph,max, &newmax);
list->eList->vertex = node;
list->eList->next = NULL;
fprintf(stderr,"MAX: %f\n",max);
max = newmax;
eptr = list->eList;
for (i=1 ; i < k; i++) {
fprintf(stderr,"%d\n",i);
fprintf(stderr,"MAX: %f\n",max);
node = get_max_MG(meta_graph,max, &newmax);
fprintf(stderr,"bak: %f\n",newmax);
if (node != NULL) {
eptr->next = (MGedgeList *) malloc(sizeof(MGedgeList));
eptr->next->vertex = node;
eptr = eptr->next;
eptr->next = NULL;
max = newmax;
} else
break;
}
fprintf(stderr,"Done.\n");
return(list);
}
MGvertex *get_max_MG(MGvertex *graph, double max, double *new)
{
MGvertex *ptr, *temp;
double current=-9999.99;
temp = NULL;
ptr = graph;
while (ptr != NULL) {
if ((ptr->confidence > current) && (ptr->confidence < max)) {
current = ptr->confidence;
temp = ptr;
}
ptr = ptr->next;
}
if (temp != NULL) {
*new = temp->confidence;
return(temp);
} else {
*new = 0.0;
return(NULL);
}
}