I'm trying to return the values of this function to the place where it's being called from. What would be the return type of the function neighborSet.
called function is
called from here:
called function is
Code:
Graph::neighborSet (NodeSet ns[], int node, int hop) const
{
int i, nb;
ns[0].setSize (size - 1);
ns[0].clear ();
ns[0] += node;
for (i = 1; i <= hop; i ++) {
ns[i] = ns[i-1];
for (nb = ns[i-1].firstMember(); nb; nb = ns[i-1].nextMember(nb)) {
ns[i] += absorbants[nb];
ns[i] += dominators[nb];
}
}
}
Code:
void Graph::criteriaSort () const
{
int * node_list;
NodeSet s (node_num);
struct criteria
{
char c;
int node_group;
int * node_list;
//node_list = new int [node_num];
} v[node_num];
int i=1;
count = 0;
while(neighborCount(i)>=1)
{
node_list = new int [node_num];
int k = 0;
for(int nb = s.firstMember();nb;nb=s.nextMember(nb))
{
if(neighborCount(nb)>=(node_num/2*i) && neighborCount(nb)<(node_num/i))
{
v[i].node_group = i;
v[i].node_list[k] = nb;
k++;
}
}
count = i++;
}
int * neighbors;
struct info
{
char color;
int * neighbors;
} n[node_num];
neighbors = new int [node_num];
for(int y=1;y<=node_num;y++) // Set all nodes to white
{
n[y].color = 'w';
n[y].neighbors = [B][I]neighborSet(s,y,1) ;[/I][/B]
}
int m;
int q = 1;
while(q < count) // covering each node_group
{
for(int j=0;j;j++) // change the color of all the nodes in the node_list to black
{
m = v[q].node_list[j];
if(n[m].color == 'w') //check if the node is already gray or black
{
n[m].color = 'b';
}
if(n[m].color == 'g' || 'b')
{
int *h= n[m].neighbors;
int p = sizeof(h)/sizeof(* h);
for(int l=0;l<p;l++) // change the color of neighbors of each node in the node_list to gray
{
int o = h[l];
if(n[o].color == 'w') // check if any of the neighbor's is white
{
n[o].color = 'g';
n[m].color = 'b';
}
}
}
}
q++;
}
for(int z=1;z<=node_num;z++) // Set all nodes to white
{
if(n[z].color == 'b')
{
printf("%d\n", z);
}
}
}