Declaration Parameters Remarks Example See Also
| Declaration
void __stdcall nbrhdCCDM(
void (*fitness)(float *, int), // fitness function
bool symmetric, // symmetric links?
float (*probLink)(float,float) // link probability function
);

Parameters
- fitness
- The name of a function to set the fitness of all agents. (See Remarks.)
- symmetric
- Indicates whether links in the network are reciprocal.
- probLink
- The name of a function to set the fitness of all agents. (See Remarks.)

Remarks
This function is available through the API. It can be called within the model-supplied routine onSimCreate to generate an arbitrary network, as described by [caldarelli02]. Although designed with scale-free networks in mind, it is able to generate many random networks. Along with the parameter symmetric the function nbrhdCCDM takes two functions as parameters:
fitness
fitness is the name of a function with the following declaration:
void fitness(
float *fit, // pointer to array fit[0..agentCount-1] of type float
int agentCount // number of agents in simulation
);
The fitness function takes in an array fit[0..agentCount-1] of floats and fills it with fitnesses sampled from a random distribution. On completion the elements of fit[] are randomly assigned to agents, in order to construct the network as described in [caldarelli02].
probLink
probLink is the name of an optional function with the following declaration:
float probLink(
float f1, // fitness of first agent
float f2 // fitness of second agent
);
The probLink function calculates the probability that the second agent is a neighbour of the first if they have fitnesses f1 and f2, respectively. If symmetric=true then it is assumed that probLink(f1,f2)=probLink(f2,f1). The probLink parameter is optional in nbrhdCCDM, if not supplied probLink(f1,f2)=f1*f2 is assumed.

Example
tParam beta;
void powerlawFitness(float *fit, int agentCount)
// fill fit[0..agentCount-1] with deviates sampled from p(fit) = (beta-1) * fit^(-beta)
{
float fitMax = 1;
// sample deviates from power-law distribution, uses beta=param[2] set in setNbrhd()
for (int i=0; i<agentCount; i++) {
fit[i] = pow(rand(), 1.0/(1.0-beta));
if (fit[i] > fitMax) fitMax = fit[i];
}
// normalize (so that can use default probLink() )
for (int i=0; i<agentCount; i++) fit[i] /= fitMax;
}
void __stdcall setNbrhd(double *param)
{
// set exponent beta>1 for powerlawFitness()
beta = param[2];
// symmetric, scale-free network with link distribution exponent = beta
nbrhdCCDM(powerlawFitness, true); // use default probLink(f1,f2)=f1*f2
}

See AlsoonSimCreate, nbrhd1D, nbrhdBlocks, nbrhdFractal, nbrhdMoore, nbrhdRandom, nbrhdRandomER, nbrhdVonNeumann. |