What would be the return type of this function?

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
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
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];
		}
	}
}

called from here:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
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 = neighborSet(s,y,1) ;
    }
    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);
         }
    }
}
Since you're not returning anything, the return value would logically be "void"

See this posts for details:

http://www.cplusplus.com/forum/beginner/34654/#msg187786
closed account (D80DSL3A)
You call the function on line 43: n[y].neighbors = neighborSet(s,y,1) ;
On line 36 I see that the lvalue is an int*: int * neighbors; so I guess neighborSet() should return a pointer to an integer.
Topic archived. No new replies allowed.