I'm using igraph C library and I want to generate a undirected, without loop, and a single edge network with power law degree distribution. The parameters I have are:
I want to use the igraph_static_power_law_game
graph generator and I wrote the following code.
#include <igraph.h>
int main() {
igraph_t g;
int igraph_static_power_law_game(&g, 25000, 25000, 2.16104, -1, 0, 0, 1);
igraph_destroy(&g);
return 0;
}
I use the the following command to compile the code.
gcc testpw.cpp -I/usr/local/Cellar/igraph/0.7.1/include/igraph -L/usr/local/Cellar/igraph/0.7.1/lib -ligraph -o testpw
And the following error appeared.
error: excess elements in scalar initializer
int igraph_static_power_law_game(&g, 25000, 25000, 2.16104, -1, 0, 0, 1);
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.
Since I can't find an example of using igraph C library to generate power-law degree network online, I don't know what's the way to make it. Am I doing something wrong here?
If you're compiling C code, you don't need the int
before igraph_static_power_law_game()
, because that makes the line look like a faulty declaration of the function instead of an invocation of the function.
Or, if you're compiling C++ code, the compiler is interpreting the contents of the parentheses as an initializer for the variable igraph_static_power_law_game
and complaining that a single int
variable does not need multiple initializers.
Either way, writing:
igraph_static_power_law_game(&g, 25000, 25000, 2.16104, -1, 0, 0, 1);
fixes the immediate compilation error. You should probably be using something like:
if (igraph_static_power_law_game(&g, 25000, 25000, 2.16104, -1, 0, 0, 1) != 0)
…report error…
so that if the function fails, you know about it.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.