473,397 Members | 1,960 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

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
Expand|Select|Wrap|Line Numbers
  1. Graph::neighborSet (NodeSet ns[], int node, int hop) const
  2. {
  3.     int i, nb;
  4.  
  5.     ns[0].setSize (size - 1);
  6.     ns[0].clear ();
  7.     ns[0] += node;
  8.  
  9.     for (i = 1; i <= hop; i ++) {
  10.         ns[i] = ns[i-1];
  11.         for (nb = ns[i-1].firstMember(); nb; nb = ns[i-1].nextMember(nb)) {
  12.             ns[i] += absorbants[nb];
  13.             ns[i] += dominators[nb];
  14.         }
  15.     }
  16. }
  17.  
called from here:
Expand|Select|Wrap|Line Numbers
  1. void    Graph::criteriaSort () const
  2. {
  3.     int * node_list;
  4.     NodeSet s (node_num);
  5.     struct criteria
  6.     {
  7.         char c;
  8.         int node_group;
  9.         int * node_list;
  10.         //node_list = new int [node_num];
  11.  
  12.     } v[node_num];
  13.     int i=1;
  14.     count = 0;
  15.     while(neighborCount(i)>=1)
  16.     {
  17.  
  18.         node_list = new int [node_num];
  19.         int k = 0;
  20.         for(int nb = s.firstMember();nb;nb=s.nextMember(nb))
  21.         {
  22.             if(neighborCount(nb)>=(node_num/2*i) && neighborCount(nb)<(node_num/i))
  23.             {
  24.                 v[i].node_group = i;
  25.                 v[i].node_list[k] = nb;
  26.                 k++;
  27.             }
  28.         }
  29.         count = i++;
  30.  
  31.     }
  32.     int * neighbors;
  33.     struct info
  34.     {
  35.         char color;
  36.         int * neighbors;
  37.     } n[node_num];
  38.  
  39.     neighbors = new int [node_num];
  40.     for(int y=1;y<=node_num;y++)   // Set all nodes to white
  41.     {
  42.          n[y].color = 'w';
  43.          n[y].neighbors = neighborSet(s,y,1) ;
  44.     }
  45.     int m;
  46.     int q = 1;
  47.     while(q < count)   // covering each node_group
  48.     {
  49.  
  50.         for(int j=0;j;j++)    // change the color of all the nodes in the node_list to black
  51.         {
  52.             m = v[q].node_list[j];
  53.             if(n[m].color == 'w')  //check if the node is already gray or black
  54.             {
  55.                 n[m].color = 'b';
  56.             }
  57.             if(n[m].color == 'g' || 'b')
  58.             {
  59.                 int *h= n[m].neighbors;
  60.                 int p = sizeof(h)/sizeof(* h);
  61.                 for(int l=0;l<p;l++)  // change the color of neighbors of each node in the node_list to gray
  62.                 {
  63.                     int o = h[l];
  64.                     if(n[o].color == 'w') // check if any of the neighbor's is white
  65.                     {
  66.                         n[o].color = 'g';
  67.                         n[m].color = 'b';
  68.                     }
  69.                 }
  70.             }
  71.  
  72.         }
  73.         q++;
  74.     }
  75.  
  76.     for(int z=1;z<=node_num;z++)   // Set all nodes to white
  77.     {
  78.          if(n[z].color == 'b')
  79.          {
  80.                 printf("%d\n", z);
  81.          }
  82.     }
  83. }
  84.  
Feb 2 '11 #1
0 1046

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Murat Tasan | last post by:
so i have a situation that i know cannot be solved directly, and i've already worked around it, but i was hoping to find an explanation as to why this behavior is as it is... i have an abstract...
31
by: CeZaR | last post by:
Hi, How can i specify the return type of a function returning a managed array of chars. If i try to write: "char __gc func()" i get an error! How can i do that? Thanks!
3
by: C++ | last post by:
According to Thinking in C++ "You cannot modify the return type of a virtual function during overriding.but there is a special case in which you can slightly modify the return type. If you¡¯re...
8
by: WakeBdr | last post by:
I'm writing a class that will query a database for some data and return the result to the caller. I need to be able to return the result of the query in several different ways: list, xml,...
3
by: Mitchel | last post by:
I'm kind of new to java & I'm trying to do a grade project called Grade.java Its suposed to make a grade book but I keep on geting 2 errors. Both say return type required. I put the error points in...
8
by: =?Utf-8?B?RG91Z2xhcyBNYXJxdWFyZHQ=?= | last post by:
Using VB.Net 2005. I have my interfaces and enums defined in a DLL. For example, I have this enum: Public Enum OpStatusTypes Normal InProgress Paused End Enum
1
by: poopsy | last post by:
i am writing a function where i have to return variables with datatypes text and real. wat wil be the return type of my function, text or real or..??? plz help thx
7
by: asit | last post by:
#include <stdio.h> //#include <stdlib.h> int main() { int c; printf("c before call=%d\n",c); c=message(); printf("c after call=%d\n",c); return 0;
3
by: burtoncn | last post by:
Hi, Just a little background information on the project I am working on! I am responsible for creating a database to automatically generate travel claims for conference attendees (Approx. 300)...
18
by: Carl Forsman | last post by:
there are 2 ways to return a value from a function ==================== 1) passing a reference as parameter - the following will return time void Table::Get(char* FieldName, *SYSTEMTIME time) {...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.