[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[igraph] Question on erdos_renyi random graph generator

From: Richard Geddes
Subject: [igraph] Question on erdos_renyi random graph generator
Date: Sat, 01 Dec 2007 13:35:44 -0500
User-agent: Thunderbird (X11/20071022)


I'm attempting to generate random graph data and took an example in the
tutorial and modified it a bit to generate an edgelist output file:

#include <cstdio>
#include <string>
#include <igraph.h>
int main(void) {
    FILE* ofile;
    ofile = fopen("erdos_renyi.pairs", "w");
    igraph_t graph;

     igraph_erdos_renyi_game(&graph, IGRAPH_ERDOS_RENYI_GNP, 1000,
5.0/1000, IGRAPH_UNDIRECTED,     
    igraph_write_graph_edgelist(&graph, ofile);

    printf("Erdos Renyi random graph generated\n");


    return 0;

I expected 1000 different vertices because the manual says:

--- snip ---

int igraph_erdos_renyi_game(igraph_t *graph, igraph_erdos_renyi_t type,
    igraph_integer_t n, igraph_real_t p_or_m,
    igraph_bool_t directed, igraph_bool_t loops);


   The number of vertices in the graph.

--- snip ---

I notice highest vertex value is consistently 999... ie the 1000th
element starting from 0.  But, the number of vertices generated is not
consistent... I ran the test 10 times and got the following number of
vertices for each run:  988, 997, 992, 992, 995, 994, 991, 994, 993, 990

I'm using a home-grown program to count the edges/vertices.  I've
checked it using standard known datasets, and it produces consistent

I've also verified these results using the netstats program by Aaron
Clauset :

1) Is this function supposed to generate a random number of vertices?
2) Is there an igraph function to verify the number of vertices generated?

Thank you

reply via email to

[Prev in Thread] Current Thread [Next in Thread]