File: igraph_average_path_length.c

package info (click to toggle)
igraph 0.10.2%2Bds-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 16,176 kB
  • sloc: ansic: 121,500; cpp: 21,699; xml: 2,734; python: 411; makefile: 147; javascript: 20; sh: 9
file content (21 lines) | stat: -rw-r--r-- 614 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21

#include <igraph.h>

int main(void) {
    igraph_t graph;
    igraph_real_t result;

    /* Create a random preferential attachment graph. */
    igraph_barabasi_game(&graph, 30, /*power=*/ 1, 30, 0, 0, /*A=*/ 1,
                         IGRAPH_DIRECTED, IGRAPH_BARABASI_BAG,
                         /*start_from=*/ 0);

    /* Compute the average shortest path length. */
    igraph_average_path_length(&graph, &result, NULL, IGRAPH_UNDIRECTED, 1);
    printf("Average length of all-pairs shortest paths: %g\n", result);

    /* Destroy no-longer-needed objects. */
    igraph_destroy(&graph);

    return 0;
}