File: tutorial1.c

package info (click to toggle)
igraph 1.0.1%2Bds-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 22,444 kB
  • sloc: ansic: 155,759; cpp: 32,544; xml: 2,960; python: 411; makefile: 168; javascript: 20; sh: 9
file content (33 lines) | stat: -rw-r--r-- 916 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#include <igraph.h>

int main(void) {
    igraph_int_t num_vertices = 1000;
    igraph_int_t num_edges = 1000;
    igraph_real_t diameter, mean_degree;
    igraph_t graph;

    /* Initialize the library. */
    igraph_setup();

    /* Ensure identical results across runs. */
    igraph_rng_seed(igraph_rng_default(), 42);

    igraph_erdos_renyi_game_gnm(
            &graph, num_vertices, num_edges,
            IGRAPH_UNDIRECTED, IGRAPH_SIMPLE_SW, IGRAPH_EDGE_UNLABELED);

    igraph_diameter(
        &graph, /* weights = */ NULL,
        &diameter,
        /* from = */ NULL, /* to = */ NULL,
        /* vertex_path = */ NULL, /* edge_path = */ NULL,
        IGRAPH_UNDIRECTED, /* unconn= */ true);

    igraph_mean_degree(&graph, &mean_degree, IGRAPH_LOOPS);
    printf("Diameter of a random graph with average degree %g: %g\n",
           mean_degree, diameter);

    igraph_destroy(&graph);

    return 0;
}