Graphical power-law sequence generator
About the code
The code is a simple generator of a power-law distributed graphical degree sequence. It extracts and return a sequence of integer numbers, distributed according to a power-law with the specified exponent. The sequence is tested for graphicality using the fast algorithm described in [1].
If you use this code for your research, I kindly ask you to cite Ref. 1 in your publications.
Download the code
How to use
The code consists of the files PLSeqGen.c, PLSeqGen.h and PLSG.h. To use it, just include PLSG.h in your code, and compile PLSeqGen.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 degree sequence, the user should invoke the function plseqgen. The prototype of the function is
int *plseqgen(const int nodes, const double gam, double (*rng)(void))
The function returns a pointer to a degree sequence of length nodes and exponent gam, created with the user-specified random number generator rng. The sequence is guaranteed to be graphical, and it is already in 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.
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 PLSeqGen.c poc.c
The program generates and prints two sequences with 100 nodes each, the first with exponent 2.5, the second with exponent 3.5, using 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] del Genio, Kim, Toroczkai and Bassler, PLoSOne 5 (4), e10012
Release information
Current version
4.1: fixed function prototyping.
Old versions
4.0: initial release.
About the code
The code is a simple generator of a power-law distributed graphical degree sequence. It extracts and return a sequence of integer numbers, distributed according to a power-law with the specified exponent. The sequence is tested for graphicality using the fast algorithm described in [1].
If you use this code for your research, I kindly ask you to cite Ref. 1 in your publications.
Download the code
How to use
The code consists of the files PLSeqGen.c, PLSeqGen.h and PLSG.h. To use it, just include PLSG.h in your code, and compile PLSeqGen.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 degree sequence, the user should invoke the function plseqgen. The prototype of the function is
int *plseqgen(const int nodes, const double gam, double (*rng)(void))
The function returns a pointer to a degree sequence of length nodes and exponent gam, created with the user-specified random number generator rng. The sequence is guaranteed to be graphical, and it is already in 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.
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 PLSeqGen.c poc.c
The program generates and prints two sequences with 100 nodes each, the first with exponent 2.5, the second with exponent 3.5, using 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] del Genio, Kim, Toroczkai and Bassler, PLoSOne 5 (4), e10012
Release information
Current version
4.1: fixed function prototyping.
Old versions
4.0: initial release.