Graphical power-law bi-degree sequence generator

About the code

The code is a simple generator of a graphical sequence of power-law distributed integer pairs. It extracts and return a sequence of pairs of integer numbers, with the elements distributed according to a power-law with the specified exponents. The sequence is created using the method described in [1], and tested for graphicality using the fast algorithm described in [2].

If you use this code for your research, I kindly ask you to cite Refs. 1 and 2 in your publications.

Download the code

How to use

The code consists of the files PLBDSgen.c, PLBDSgen.h and PLBDSG.h. To use it, just include PLBDSG.h in your code, and compile PLBDSgen.c with your other source files, remembering to use the option -lm as it needs to link to the math library.

To create and store a graphical bi-degree sequence, the user should invoke the function plbdsgen. The prototype of the function is

int **plbdsgen(const int nodes, const double gamin, const double gamout, double (*rng)(void));

The function returns a pointer to a nodes by 2 array containing the bi-degree sequence. The first column (array[node][0]) contains the in-degrees, and the second column (array[node][1]) contains the out-degrees. In- and out-degrees are power-law distributed, with exponents gamin and gamout, respectively. The sequence is created with the user-specified random number generator rng. The sequence is guaranteed to be graphical, and it is already in lexicographic non-increasing order. The random number generator must be a function taking no input parameters and returning a double precision floating point number between 0 and 1. The generator must be already seeded. This leaves the user the choice of the generator to use. After finishing working with a sequence, the memory used should be cleaned using free first on a pointer to the first element and then on a pointer to the 2d array.

A minimal proof of concept program is included, in the file poc.c. The code can be compiled on a standard GNU/Linux distribution with the command

gcc -std=c99 -lm -o poc PLBDSgen.c poc.c

The program generates and prints two bi-degree sequences with 100 nodes each. The first sequence has in-degree exponent 2.2 and out-degree exponent 3.5, and the second has in-degree exponent 3.7 and out-degree exponent 2.5. The proof of concept uses a simple random number generator. Please note that (pseudo) random number generation for scientific or cryptographic applications is a complex subject, and the actual generator to use in publication-level sampling should be an established, tested, one. In the proof of concept, a simple one is used just for sake of simplicity. It should probably not be used otherwise, and definitely not be used for cryptographic applications, as there exist more appropriate and far better generators.

References

[1] Williams and del Genio, PLoS ONE

[2] Kim, del Genio, Bassler and Toroczkai, New J. Phys.

Release information

Current version

Old versions

About the code

The code is a simple generator of a graphical sequence of power-law distributed integer pairs. It extracts and return a sequence of pairs of integer numbers, with the elements distributed according to a power-law with the specified exponents. The sequence is created using the method described in [1], and tested for graphicality using the fast algorithm described in [2].

If you use this code for your research, I kindly ask you to cite Refs. 1 and 2 in your publications.

Download the code

How to use

The code consists of the files PLBDSgen.c, PLBDSgen.h and PLBDSG.h. To use it, just include PLBDSG.h in your code, and compile PLBDSgen.c with your other source files, remembering to use the option -lm as it needs to link to the math library.

To create and store a graphical bi-degree sequence, the user should invoke the function plbdsgen. The prototype of the function is

int **plbdsgen(const int nodes, const double gamin, const double gamout, double (*rng)(void));

The function returns a pointer to a nodes by 2 array containing the bi-degree sequence. The first column (array[node][0]) contains the in-degrees, and the second column (array[node][1]) contains the out-degrees. In- and out-degrees are power-law distributed, with exponents gamin and gamout, respectively. The sequence is created with the user-specified random number generator rng. The sequence is guaranteed to be graphical, and it is already in lexicographic non-increasing order. The random number generator must be a function taking no input parameters and returning a double precision floating point number between 0 and 1. The generator must be already seeded. This leaves the user the choice of the generator to use. After finishing working with a sequence, the memory used should be cleaned using free first on a pointer to the first element and then on a pointer to the 2d array.

A minimal proof of concept program is included, in the file poc.c. The code can be compiled on a standard GNU/Linux distribution with the command

gcc -std=c99 -lm -o poc PLBDSgen.c poc.c

The program generates and prints two bi-degree sequences with 100 nodes each. The first sequence has in-degree exponent 2.2 and out-degree exponent 3.5, and the second has in-degree exponent 3.7 and out-degree exponent 2.5. The proof of concept uses a simple random number generator. Please note that (pseudo) random number generation for scientific or cryptographic applications is a complex subject, and the actual generator to use in publication-level sampling should be an established, tested, one. In the proof of concept, a simple one is used just for sake of simplicity. It should probably not be used otherwise, and definitely not be used for cryptographic applications, as there exist more appropriate and far better generators.

References

[1] Williams and del Genio, PLoS ONE

**9**(10), e110121 (2014)[2] Kim, del Genio, Bassler and Toroczkai, New J. Phys.

**14**, 023012 (2012)Release information

Current version

**5.0**: does what described above.Old versions

**4.0**: initial release.