int main() { igraph_t g; igraph_vector_t result; long i; igraph_vector_init(&result, 0); igraph_small(&g, 7, 0, 0,1,0,2,0,3,1,2,1,3,2,3,3,4,4,5,4,6,5,6, -1); igraph_convergence_degree(&g, &result, 0, 0); for (i=0; i<igraph_ecount(&g); i++) printf("%.4f ", (float)igraph_vector_e(&result, i)); printf("\n"); igraph_destroy(&g); igraph_small(&g, 6, 1, 1,0,2,0,3,0,4,0,0,5, -1); igraph_convergence_degree(&g, &result, 0, 0); for (i=0; i<igraph_ecount(&g); i++) printf("%.4f ", (float)igraph_vector_e(&result, i)); printf("\n"); igraph_destroy(&g); igraph_vector_destroy(&result); return 0; }
int main() { igraph_t small, big; igraph_matrix_t small_coords, big_coords, merged_coords; igraph_vector_ptr_t graph_ptr, coords_ptr; igraph_arpack_options_t arpack_opts; /* To make things reproducible */ igraph_rng_seed(igraph_rng_default(), 42); igraph_small(&big, 10, IGRAPH_UNDIRECTED, 0,1, 1,2, 2,3, 3,4, 4,5, 5,6, 6,7, 7,8, 8,9, 9,0, -1); igraph_small(&small, 3, IGRAPH_UNDIRECTED, 0,1, 1,2, 2,0, -1); igraph_arpack_options_init(&arpack_opts); igraph_matrix_init(&big_coords, 0, 0); igraph_layout_mds(&big, &big_coords, /*dist=*/ 0, /*dim=*/ 2, &arpack_opts); igraph_matrix_init(&small_coords, 0, 0); igraph_layout_mds(&small, &small_coords, /*dist=*/ 0, /*dim=*/ 2, &arpack_opts); igraph_vector_ptr_init(&graph_ptr, 2); igraph_vector_ptr_init(&coords_ptr, 2); igraph_matrix_init(&merged_coords, 0, 0); VECTOR(graph_ptr)[0] = &big; VECTOR(graph_ptr)[1] = &small; VECTOR(coords_ptr)[0] = &big_coords; VECTOR(coords_ptr)[1] = &small_coords; igraph_layout_merge_dla(&graph_ptr, &coords_ptr, &merged_coords); igraph_matrix_print(&merged_coords); igraph_matrix_destroy(&merged_coords); igraph_matrix_destroy(&small_coords); igraph_matrix_destroy(&big_coords); igraph_vector_ptr_destroy(&graph_ptr); igraph_vector_ptr_destroy(&coords_ptr); igraph_destroy(&small); igraph_destroy(&big); #ifdef __APPLE__ return 0; #else return 77; #endif }
int main() { igraph_t g; igraph_vector_t eb; igraph_small(&g, 0, IGRAPH_UNDIRECTED, 0, 1, 0, 2, 0, 3, 0, 4, 0, 5, 0, 6, 0, 7, 0, 8, 0, 10, 0, 11, 0, 12, 0, 13, 0, 17, 0, 19, 0, 21, 0, 31, 1, 2, 1, 3, 1, 7, 1, 13, 1, 17, 1, 19, 1, 21, 1, 30, 2, 3, 2, 7, 2, 8, 2, 9, 2, 13, 2, 27, 2, 28, 2, 32, 3, 7, 3, 12, 3, 13, 4, 6, 4, 10, 5, 6, 5, 10, 5, 16, 6, 16, 8, 30, 8, 32, 8, 33, 9, 33, 13, 33, 14, 32, 14, 33, 15, 32, 15, 33, 18, 32, 18, 33, 19, 33, 20, 32, 20, 33, 22, 32, 22, 33, 23, 25, 23, 27, 23, 29, 23, 32, 23, 33, 24, 25, 24, 27, 24, 31, 25, 31, 26, 29, 26, 33, 27, 33, 28, 31, 28, 33, 29, 32, 29, 33, 30, 32, 30, 33, 31, 32, 31, 33, 32, 33, -1); igraph_vector_init(&eb, igraph_ecount(&g)); igraph_edge_betweenness(&g, &eb, IGRAPH_UNDIRECTED); print_vector(&eb, stdout); igraph_vector_destroy(&eb); igraph_destroy(&g); igraph_small(&g, 0, IGRAPH_UNDIRECTED, 0, 1, 0, 2, 0, 3, 1, 4, -1); igraph_vector_init(&eb, igraph_ecount(&g)); igraph_edge_betweenness_estimate(&g, &eb, IGRAPH_UNDIRECTED, 2); print_vector(&eb, stdout); igraph_vector_destroy(&eb); igraph_destroy(&g); igraph_small(&g, 0, IGRAPH_UNDIRECTED, 0, 1, 0, 3, 1, 2, 1, 4, 2, 5, 3, 4, 3, 6, 4, 5, 4, 7, 5, 8, 6, 7, 7, 8, -1); igraph_vector_init(&eb, igraph_ecount(&g)); igraph_edge_betweenness_estimate(&g, &eb, IGRAPH_UNDIRECTED, 2); print_vector(&eb, stdout); igraph_vector_destroy(&eb); igraph_destroy(&g); return 0; }
void test_unweighted() { igraph_t g; igraph_vector_t edges, eb; long int i; long int no_of_edges; /* Zachary Karate club */ igraph_small(&g, 0, IGRAPH_UNDIRECTED, 0, 1, 0, 2, 0, 3, 0, 4, 0, 5, 0, 6, 0, 7, 0, 8, 0, 10, 0, 11, 0, 12, 0, 13, 0, 17, 0, 19, 0, 21, 0, 31, 1, 2, 1, 3, 1, 7, 1, 13, 1, 17, 1, 19, 1, 21, 1, 30, 2, 3, 2, 7, 2, 8, 2, 9, 2, 13, 2, 27, 2, 28, 2, 32, 3, 7, 3, 12, 3, 13, 4, 6, 4, 10, 5, 6, 5, 10, 5, 16, 6, 16, 8, 30, 8, 32, 8, 33, 9, 33, 13, 33, 14, 32, 14, 33, 15, 32, 15, 33, 18, 32, 18, 33, 19, 33, 20, 32, 20, 33, 22, 32, 22, 33, 23, 25, 23, 27, 23, 29, 23, 32, 23, 33, 24, 25, 24, 27, 24, 31, 25, 31, 26, 29, 26, 33, 27, 33, 28, 31, 28, 33, 29, 32, 29, 33, 30, 32, 30, 33, 31, 32, 31, 33, 32, 33, -1); igraph_vector_init(&edges, 0); igraph_vector_init(&eb, 0); igraph_community_edge_betweenness(&g, &edges, &eb, 0 /*merges */, 0 /*bridges */, /*modularity=*/ 0, /*membership=*/ 0, IGRAPH_UNDIRECTED, /*weights=*/ 0); no_of_edges=igraph_ecount(&g); for (i=0; i<no_of_edges; i++) { printf("%li ", (long int)VECTOR(edges)[i]); } printf("\n"); for (i=0; i<no_of_edges; i++) { printf("%.2f ", VECTOR(eb)[i]); } printf("\n"); /* Try it once again without storage space for edges */ igraph_community_edge_betweenness(&g, 0, &eb, 0 /*merges */, 0 /*bridges */, /*modularity=*/ 0, /*membership=*/ 0, IGRAPH_UNDIRECTED, /*weights=*/ 0); for (i=0; i<no_of_edges; i++) { printf("%.2f ", VECTOR(eb)[i]); } printf("\n"); igraph_vector_destroy(&eb); igraph_vector_destroy(&edges); igraph_destroy(&g); }
int main() { igraph_t graph; igraph_vector_ptr_t separators; int i, n; igraph_small(&graph, 0, /*directed=*/ 0, 0,1,0,2, 1,3,1,4, 2,3,2,5, 3,4,3,5, 4,6, 5,6, -1); igraph_vector_ptr_init(&separators, 0); igraph_all_minimal_st_separators(&graph, &separators); n=igraph_vector_ptr_size(&separators); for (i=0; i<n; i++) { igraph_vector_t *sep=VECTOR(separators)[i]; igraph_vector_print(sep); igraph_vector_destroy(sep); igraph_free(sep); } igraph_vector_ptr_destroy(&separators); igraph_destroy(&graph); return 0; }
int main() { igraph_t g; igraph_vector_t weights; igraph_real_t weights_data[] = { 0,2,1, 0,5,2, 1,1,0, 2,2,8, 1,1,3, 1,1,4, 2,1 }; igraph_matrix_t res; igraph_small(&g, 10, IGRAPH_DIRECTED, 0,1, 0,2, 0,3, 1,2, 1,4, 1,5, 2,3, 2,6, 3,2, 3,6, 4,5, 4,7, 5,6, 5,8, 5,9, 7,5, 7,8, 8,9, 5,2, 2,1, -1); igraph_vector_view(&weights, weights_data, sizeof(weights_data)/sizeof(igraph_real_t)); igraph_matrix_init(&res, 0, 0); igraph_shortest_paths_dijkstra(&g, &res, igraph_vss_all(), igraph_vss_all(), &weights, IGRAPH_OUT); print_matrix(&res); igraph_matrix_destroy(&res); igraph_destroy(&g); return 0; }
int main(int argc,char** argv) { igraph_vector_t *lp; igraph_t g; // all ggen methods should fail on incorrect arguments assert(ggen_analyze_longest_path(NULL) == NULL); // an empty graph as a longest path of zero igraph_empty(&g,10,1); lp = ggen_analyze_longest_path(&g); assert(lp != NULL); assert(igraph_vector_size(lp) == 0); igraph_destroy(&g); igraph_vector_destroy(lp); free((void *)lp); // a full dag as a longest path of containing all vertices igraph_full_citation(&g,10,1); lp = ggen_analyze_longest_path(&g); assert(lp != NULL); assert(igraph_vector_size(lp) == 10); igraph_destroy(&g); igraph_vector_destroy(lp); free((void *)lp); // a wrong graph (not dag) should fail // graph is 0 -> 1 -> 2 and 2 -> 0 igraph_small(&g,10,1,0,1,1,2,2,0,-1); assert(ggen_analyze_longest_path(&g) == NULL); igraph_destroy(&g); // a simple graph should work too // graph is 0 -> 1 -> 2 and 0 -> 2 igraph_small(&g,10,1,0,1,1,2,0,2,-1); lp = ggen_analyze_longest_path(&g); assert(lp != NULL); assert(igraph_vector_size(lp) == 3); igraph_destroy(&g); igraph_vector_destroy(lp); free((void *)lp); return 0; }
int main() { igraph_t g; igraph_small(&g, 0, IGRAPH_DIRECTED, 0,1, 1,2, 2,3, 3,4, 6,1, -1); igraph_write_graph_edgelist(&g, stdout); igraph_destroy(&g); return 0; }
int main() { igraph_t karate; igraph_vector_t parents, weights; igraph_rng_seed(igraph_rng_default(), 42); igraph_small(&karate, 34, IGRAPH_UNDIRECTED, 0,1,0,2,0,3,0,4,0,5,0,6,0,7,0,8,0,10,0,11,0,12,0,13, 0,17,0,19,0,21,0,31, 1,2,1,3,1,7,1,13,1,17,1,19,1,21,1,30, 2,3,2,7,2,27,2,28,2,32,2,9,2,8,2,13, 3,7,3,12,3,13, 4,6,4,10, 5,6,5,10,5,16, 6,16, 8,30,8,32,8,33, 9,33, 13,33, 14,32,14,33, 15,32,15,33, 18,32,18,33, 19,33, 20,32,20,33, 22,32,22,33, 23,25,23,27,23,32,23,33,23,29, 24,25,24,27,24,31, 25,31, 26,29,26,33, 27,33, 28,31,28,33, 29,32,29,33, 30,32,30,33, 31,32,31,33, 32,33, -1); igraph_vector_init(&parents, 0); igraph_vector_init(&weights, 0); igraph_hrg_consensus(&karate, &parents, &weights, /* hrg= */ 0, /* start= */ 0, /* num_samples= */ 100); /* Check */ igraph_vector_print(&parents); igraph_vector_print(&weights); igraph_vector_destroy(&parents); igraph_vector_destroy(&weights); igraph_destroy(&karate); #ifdef __APPLE__ return 0; #else return 77; #endif }
int main() { igraph_t g; igraph_vector_t edges, eb; long int i; long int no_of_edges; /* Zachary Karate club */ igraph_small(&g, 0, IGRAPH_UNDIRECTED, 0, 1, 0, 2, 0, 3, 0, 4, 0, 5, 0, 6, 0, 7, 0, 8, 0, 10, 0, 11, 0, 12, 0, 13, 0, 17, 0, 19, 0, 21, 0, 31, 1, 2, 1, 3, 1, 7, 1, 13, 1, 17, 1, 19, 1, 21, 1, 30, 2, 3, 2, 7, 2, 8, 2, 9, 2, 13, 2, 27, 2, 28, 2, 32, 3, 7, 3, 12, 3, 13, 4, 6, 4, 10, 5, 6, 5, 10, 5, 16, 6, 16, 8, 30, 8, 32, 8, 33, 9, 33, 13, 33, 14, 32, 14, 33, 15, 32, 15, 33, 18, 32, 18, 33, 19, 33, 20, 32, 20, 33, 22, 32, 22, 33, 23, 25, 23, 27, 23, 29, 23, 32, 23, 33, 24, 25, 24, 27, 24, 31, 25, 31, 26, 29, 26, 33, 27, 33, 28, 31, 28, 33, 29, 32, 29, 33, 30, 32, 30, 33, 31, 32, 31, 33, 32, 33, -1); igraph_vector_init(&edges, 0); igraph_vector_init(&eb, 0); igraph_community_edge_betweenness(&g, &edges, &eb, 0 /*merges */, 0 /*bridges */, IGRAPH_UNDIRECTED); no_of_edges=igraph_ecount(&g); for (i=0; i<no_of_edges; i++) { printf("%li ", (long int)VECTOR(edges)[i]); } printf("\n"); for (i=0; i<no_of_edges; i++) { printf("%.2f ", VECTOR(eb)[i]); } printf("\n"); igraph_vector_destroy(&eb); igraph_vector_destroy(&edges); igraph_destroy(&g); return 0; }
int main() { igraph_t g, tree; igraph_vector_t eb, edges; long int i; igraph_small(&g, 0, IGRAPH_UNDIRECTED, 0, 1, 0, 2, 0, 3, 0, 4, 0, 5, 0, 6, 0, 7, 0, 8, 0, 10, 0, 11, 0, 12, 0, 13, 0, 17, 0, 19, 0, 21, 0, 31, 1, 2, 1, 3, 1, 7, 1, 13, 1, 17, 1, 19, 1, 21, 1, 30, 2, 3, 2, 7, 2, 8, 2, 9, 2, 13, 2, 27, 2, 28, 2, 32, 3, 7, 3, 12, 3, 13, 4, 6, 4, 10, 5, 6, 5, 10, 5, 16, 6, 16, 8, 30, 8, 32, 8, 33, 9, 33, 13, 33, 14, 32, 14, 33, 15, 32, 15, 33, 18, 32, 18, 33, 19, 33, 20, 32, 20, 33, 22, 32, 22, 33, 23, 25, 23, 27, 23, 29, 23, 32, 23, 33, 24, 25, 24, 27, 24, 31, 25, 31, 26, 29, 26, 33, 27, 33, 28, 31, 28, 33, 29, 32, 29, 33, 30, 32, 30, 33, 31, 32, 31, 33, 32, 33, -1); igraph_vector_init(&eb, igraph_ecount(&g)); igraph_edge_betweenness(&g, &eb, IGRAPH_UNDIRECTED, /*weights=*/ 0); for (i=0; i<igraph_vector_size(&eb); i++) { VECTOR(eb)[i] = -VECTOR(eb)[i]; } igraph_minimum_spanning_tree_prim(&g, &tree, &eb); igraph_write_graph_edgelist(&tree, stdout); igraph_vector_init(&edges, 0); igraph_minimum_spanning_tree(&g, &edges, &eb); igraph_vector_print(&edges); igraph_vector_destroy(&edges); igraph_destroy(&tree); igraph_destroy(&g); igraph_vector_destroy(&eb); return 0; }
int test_graph_from_leda_tutorial() { /* Test graph from the LEDA tutorial: * http://www.leda-tutorial.org/en/unofficial/ch05s03s05.html */ igraph_t graph; igraph_vector_bool_t types; igraph_vector_long_t matching; igraph_integer_t matching_size; igraph_bool_t is_matching; int i; igraph_small(&graph, 0, 0, 0, 8, 0, 12, 0, 14, 1, 9, 1, 10, 1, 13, 2, 8, 2, 9, 3, 10, 3, 11, 3, 13, 4, 9, 4, 14, 5, 14, 6, 9, 6, 14, 7, 8, 7, 12, 7, 14 , -1); igraph_vector_bool_init(&types, 15); for (i = 0; i < 15; i++) VECTOR(types)[i] = (i >= 8); igraph_vector_long_init(&matching, 0); igraph_i_maximum_bipartite_matching_unweighted(&graph, &types, &matching_size, &matching); if (matching_size != 6) { printf("matching_size is %ld, expected: 6\n", (long)matching_size); return 1; } igraph_is_maximal_matching(&graph, &types, &matching, &is_matching); if (!is_matching) { printf("not a matching: "); igraph_vector_long_print(&matching); return 3; } else igraph_vector_long_print(&matching); igraph_vector_long_destroy(&matching); igraph_vector_bool_destroy(&types); igraph_destroy(&graph); return 0; }
int main() { igraph_t g; igraph_vector_t edges; long int i; /*igraph_small(&g,0, IGRAPH_UNDIRECTED, 0, 1, 0, 2, 0, 3, 0, 4, 0, 5, 0, 6, 0, 7, 0, 8, 0, 10, 0, 11, 0, 12, 0, 13, 0, 17, 0, 19, 0, 21, 0, 31, 1, 2, 1, 3, 1, 7, 1, 13, 1, 17, 1, 19, 1, 21, 1, 30, 2, 3, 2, 7, 2, 8, 2, 9, 2, 13, 2, 27, 2, 28, 2, 32, 3, 7, 3, 12, 3, 13, 4, 6, 4, 10, 5, 6, 5, 10, 5, 16, 6, 16, 8, 30, 8, 32, 8, 33, 9, 33, 13, 33, 14, 32, 14, 33, 15, 32, 15, 33, 18, 32, 18, 33, 19, 33, 20, 32, 20, 33, 22, 32, 22, 33, 23, 25, 23, 27, 23, 29, 23, 32, 23, 33, 24, 25, 24, 27, 24, 31, 25, 31, 26, 29, 26, 33, 27, 33, 28, 31, 28, 33, 29, 32, 29, 33, 30, 32, 30, 33, 31, 32, 31, 33, 32, 33, -1);*/ igraph_small(&g, 10, IGRAPH_DIRECTED, 0,1, 0,2, 0,3, 1,2, 1,4, 1,5, 2,3, 2,6, 3,2, 6,3, 4,5, 4,7, 5,6, 5,8, 5,9, 7,5, 7,8, 8,9, 5,2, 2,1, -1); /*FILE *fp; fp=fopen("abc.gml","w"); igraph_write_graph_gml(&g,fp,NULL,0);*/ igraph_vector_init(&edges, 0); igraph_i_minimum_spanning_tree_unweighted(&g, &edges); igraph_vector_print(&edges); igraph_vector_destroy(&edges); igraph_destroy(&g); return 0; }
int main() { igraph_t g; igraph_matrix_t m; igraph_small(&g, 0, IGRAPH_DIRECTED, 0,1, 2,1, 2,0, 3,0, -1); igraph_matrix_init(&m, 0, 0); igraph_bibcoupling(&g, &m, igraph_vss_all()); print_matrix(&m, stdout); igraph_cocitation(&g, &m, igraph_vss_all()); print_matrix(&m, stdout); igraph_matrix_destroy(&m); igraph_destroy(&g); return 0; }
int main() { igraph_t g, g2; igraph_vector_ptr_t sep; igraph_vs_t vs; igraph_small(&g, 7, IGRAPH_UNDIRECTED, 1,0, 2,0, 3,0, 4,0, 5,0, 6,0, -1); igraph_vector_ptr_init(&sep, 0); igraph_minimum_size_separators(&g, &sep); print_and_destroy(&sep); igraph_destroy(&g); /* ----------------------------------------------------------- */ igraph_small(&g, 5, IGRAPH_UNDIRECTED, 0,3, 1,3, 2,3, 0,4, 1,4, 2,4, -1); igraph_vector_ptr_init(&sep, 0); igraph_minimum_size_separators(&g, &sep); print_and_destroy(&sep); igraph_destroy(&g); /* ----------------------------------------------------------- */ igraph_small(&g, 5, IGRAPH_UNDIRECTED, 2,0, 3,0, 4,0, 2,1, 3,1, 4,1, -1); igraph_vector_ptr_init(&sep, 0); igraph_minimum_size_separators(&g, &sep); print_and_destroy(&sep); igraph_destroy(&g); /* ----------------------------------------------------------- */ igraph_small(&g, 10, IGRAPH_UNDIRECTED, 0,2, 0,3, 1,2, 1,3, 5,2, 5,3, 6,2, 6,3, 7,2, 7,3, 8,2, 8,3, 9,2, 9,3, 2,4, 4,3, -1); igraph_vector_ptr_init(&sep, 0); igraph_minimum_size_separators(&g, &sep); print_and_destroy(&sep); igraph_destroy(&g); /* ----------------------------------------------------------- */ igraph_full(&g, 4, IGRAPH_UNDIRECTED, /*loops=*/ 0); igraph_vector_ptr_init(&sep, 0); igraph_minimum_size_separators(&g, &sep); print_and_destroy(&sep); igraph_destroy(&g); /* ----------------------------------------------------------- */ igraph_small(&g, 23, IGRAPH_UNDIRECTED, 0,1, 0,2, 0,3, 0,4, 0,5, 1,2, 1,3, 1,4, 1,6, 2,3, 2,5, 2,6, 3,4, 3,5, 3,6, 4,5, 4,6, 4,20, 5,6, 6,7, 6,10, 6,13, 6,18, 7,8, 7,10, 7,13, 8,9, 9,11, 9,12, 10,11, 10,13, 11,15, 12,15, 13,14, 14,15, 16,17, 16,18, 16,19, 17,19, 17,20, 18,19, 18,21, 18,22, 19,20, 20,21, 20,22, 21,22, -1); igraph_vector_ptr_init(&sep, 0); igraph_minimum_size_separators(&g, &sep); printf("Orig:\n"); print_and_destroy(&sep); igraph_vector_ptr_init(&sep, 0); igraph_vs_vector_small(&vs, 0,1,2,3,4,5,6, 16,17,18,19,20,21,22, -1); igraph_induced_subgraph(&g, &g2, vs, IGRAPH_SUBGRAPH_AUTO); igraph_minimum_size_separators(&g2, &sep); printf("1-7,17-23:\n"); print_and_destroy(&sep); igraph_vs_destroy(&vs); igraph_destroy(&g2); igraph_vector_ptr_init(&sep, 0); igraph_vs_vector_small(&vs, 6,7,8,9,10,11,12,13,14,15, -1); igraph_induced_subgraph(&g, &g2, vs, IGRAPH_SUBGRAPH_AUTO); igraph_minimum_size_separators(&g2, &sep); printf("7-16:\n"); print_and_destroy(&sep); igraph_vs_destroy(&vs); igraph_destroy(&g2); igraph_vector_ptr_init(&sep, 0); igraph_vs_vector_small(&vs, 16,17,18,19,20,21,22, -1); igraph_induced_subgraph(&g, &g2, vs, IGRAPH_SUBGRAPH_AUTO); igraph_minimum_size_separators(&g2, &sep); printf("17-23:\n"); print_and_destroy(&sep); igraph_vs_destroy(&vs); igraph_destroy(&g2); igraph_vector_ptr_init(&sep, 0); igraph_vs_vector_small(&vs, 6,7,10,13, -1); igraph_induced_subgraph(&g, &g2, vs, IGRAPH_SUBGRAPH_AUTO); igraph_minimum_size_separators(&g2, &sep); printf("7,8,11,14:\n"); print_and_destroy(&sep); igraph_vs_destroy(&vs); igraph_destroy(&g2); igraph_vector_ptr_init(&sep, 0); igraph_vs_vector_small(&vs, 0,1,2,3,4,5,6, -1); igraph_induced_subgraph(&g, &g2, vs, IGRAPH_SUBGRAPH_AUTO); igraph_minimum_size_separators(&g2, &sep); printf("1-7:\n"); print_and_destroy(&sep); igraph_vs_destroy(&vs); igraph_destroy(&g2); igraph_destroy(&g); return 0; }
int main() { igraph_t g, g2; igraph_vector_t weight; igraph_attribute_combination_t comb; igraph_i_set_attribute_table(&igraph_cattribute_table); igraph_small(&g, 4, IGRAPH_DIRECTED, 0, 1, 0, 1, 0, 1, 1, 2, 2, 3, -1); igraph_vector_init_seq(&weight, 1, igraph_ecount(&g)); SETEANV(&g, "weight", &weight); igraph_vector_destroy(&weight); /* ****************************************************** */ igraph_copy(&g2, &g); igraph_attribute_combination(&comb, "weight", IGRAPH_ATTRIBUTE_COMBINE_SUM, "", IGRAPH_ATTRIBUTE_COMBINE_IGNORE, IGRAPH_NO_MORE_ATTRIBUTES); igraph_simplify(&g2, /*multiple=*/ 1, /*loops=*/ 1, &comb); igraph_attribute_combination_destroy(&comb); igraph_write_graph_graphml(&g2, stdout); igraph_destroy(&g2); /* ****************************************************** */ /* ****************************************************** */ igraph_copy(&g2, &g); igraph_attribute_combination(&comb, "weight", IGRAPH_ATTRIBUTE_COMBINE_PROD, "", IGRAPH_ATTRIBUTE_COMBINE_IGNORE, IGRAPH_NO_MORE_ATTRIBUTES); igraph_simplify(&g2, /*multiple=*/ 1, /*loops=*/ 1, &comb); igraph_attribute_combination_destroy(&comb); igraph_write_graph_graphml(&g2, stdout); igraph_destroy(&g2); /* ****************************************************** */ /* ****************************************************** */ igraph_copy(&g2, &g); igraph_attribute_combination(&comb, "weight", IGRAPH_ATTRIBUTE_COMBINE_MIN, "", IGRAPH_ATTRIBUTE_COMBINE_IGNORE, IGRAPH_NO_MORE_ATTRIBUTES); igraph_simplify(&g2, /*multiple=*/ 1, /*loops=*/ 1, &comb); igraph_attribute_combination_destroy(&comb); igraph_write_graph_graphml(&g2, stdout); igraph_destroy(&g2); /* ****************************************************** */ /* ****************************************************** */ igraph_copy(&g2, &g); igraph_attribute_combination(&comb, "weight", IGRAPH_ATTRIBUTE_COMBINE_MAX, "", IGRAPH_ATTRIBUTE_COMBINE_IGNORE, IGRAPH_NO_MORE_ATTRIBUTES); igraph_simplify(&g2, /*multiple=*/ 1, /*loops=*/ 1, &comb); igraph_attribute_combination_destroy(&comb); igraph_write_graph_graphml(&g2, stdout); igraph_destroy(&g2); /* ****************************************************** */ /* ****************************************************** */ igraph_copy(&g2, &g); igraph_attribute_combination(&comb, "weight", IGRAPH_ATTRIBUTE_COMBINE_FIRST, "", IGRAPH_ATTRIBUTE_COMBINE_IGNORE, IGRAPH_NO_MORE_ATTRIBUTES); igraph_simplify(&g2, /*multiple=*/ 1, /*loops=*/ 1, &comb); igraph_attribute_combination_destroy(&comb); igraph_write_graph_graphml(&g2, stdout); igraph_destroy(&g2); /* ****************************************************** */ /* ****************************************************** */ igraph_copy(&g2, &g); igraph_attribute_combination(&comb, "weight", IGRAPH_ATTRIBUTE_COMBINE_LAST, "", IGRAPH_ATTRIBUTE_COMBINE_IGNORE, IGRAPH_NO_MORE_ATTRIBUTES); igraph_simplify(&g2, /*multiple=*/ 1, /*loops=*/ 1, &comb); igraph_attribute_combination_destroy(&comb); igraph_write_graph_graphml(&g2, stdout); igraph_destroy(&g2); /* ****************************************************** */ /* ****************************************************** */ igraph_copy(&g2, &g); igraph_attribute_combination(&comb, "weight", IGRAPH_ATTRIBUTE_COMBINE_MEAN, "", IGRAPH_ATTRIBUTE_COMBINE_IGNORE, IGRAPH_NO_MORE_ATTRIBUTES); igraph_simplify(&g2, /*multiple=*/ 1, /*loops=*/ 1, &comb); igraph_attribute_combination_destroy(&comb); igraph_write_graph_graphml(&g2, stdout); igraph_destroy(&g2); /* ****************************************************** */ /* ****************************************************** */ igraph_copy(&g2, &g); igraph_attribute_combination(&comb, "weight", IGRAPH_ATTRIBUTE_COMBINE_FUNCTION, mf, "", IGRAPH_ATTRIBUTE_COMBINE_IGNORE, IGRAPH_NO_MORE_ATTRIBUTES); igraph_simplify(&g2, /*multiple=*/ 1, /*loops=*/ 1, &comb); igraph_attribute_combination_destroy(&comb); igraph_write_graph_graphml(&g2, stdout); igraph_destroy(&g2); /* ****************************************************** */ /* ****************************************************** */ igraph_copy(&g2, &g); igraph_attribute_combination(&comb, "", IGRAPH_ATTRIBUTE_COMBINE_MEAN, IGRAPH_NO_MORE_ATTRIBUTES); igraph_simplify(&g2, /*multiple=*/ 1, /*loops=*/ 1, &comb); igraph_attribute_combination_destroy(&comb); igraph_write_graph_graphml(&g2, stdout); igraph_destroy(&g2); /* ****************************************************** */ igraph_destroy(&g); return 0; }
int main() { igraph_t g, g2; igraph_attribute_combination_t comb; igraph_i_set_attribute_table(&igraph_cattribute_table); igraph_small(&g, 4, IGRAPH_DIRECTED, 0, 1, 0, 1, 0, 1, 1, 2, 2, 3, -1); SETEAB(&g, "type", 0, 1); SETEAB(&g, "type", 1, 1); SETEAB(&g, "type", 2, 0); SETEAB(&g, "type", 3, 0); SETEAB(&g, "type", 4, 1); /* ****************************************************** */ igraph_copy(&g2, &g); igraph_attribute_combination(&comb, "weight", IGRAPH_ATTRIBUTE_COMBINE_SUM, "type", IGRAPH_ATTRIBUTE_COMBINE_FIRST, "", IGRAPH_ATTRIBUTE_COMBINE_IGNORE, IGRAPH_NO_MORE_ATTRIBUTES); igraph_simplify(&g2, /*multiple=*/ 1, /*loops=*/ 1, &comb); igraph_attribute_combination_destroy(&comb); igraph_write_graph_graphml(&g2, stdout, /*prefixattr=*/ 1); igraph_destroy(&g2); /* ****************************************************** */ /* ****************************************************** */ igraph_copy(&g2, &g); igraph_attribute_combination(&comb, "", IGRAPH_ATTRIBUTE_COMBINE_LAST, IGRAPH_NO_MORE_ATTRIBUTES); igraph_simplify(&g2, /*multiple=*/ 1, /*loops=*/ 1, &comb); igraph_attribute_combination_destroy(&comb); igraph_write_graph_graphml(&g2, stdout, /*prefixattr=*/ 1); igraph_destroy(&g2); /* ****************************************************** */ /* ****************************************************** */ igraph_copy(&g2, &g); igraph_attribute_combination(&comb, "", IGRAPH_ATTRIBUTE_COMBINE_IGNORE, "type", IGRAPH_ATTRIBUTE_COMBINE_LAST, IGRAPH_NO_MORE_ATTRIBUTES); igraph_simplify(&g2, /*multiple=*/ 1, /*loops=*/ 1, &comb); igraph_attribute_combination_destroy(&comb); igraph_write_graph_graphml(&g2, stdout, /*prefixattr=*/ 1); igraph_destroy(&g2); /* ****************************************************** */ /* ****************************************************** */ igraph_copy(&g2, &g); igraph_attribute_combination(&comb, "", IGRAPH_ATTRIBUTE_COMBINE_IGNORE, "type", IGRAPH_ATTRIBUTE_COMBINE_SUM, IGRAPH_NO_MORE_ATTRIBUTES); igraph_simplify(&g2, /*multiple=*/ 1, /*loops=*/ 1, &comb); igraph_attribute_combination_destroy(&comb); igraph_write_graph_graphml(&g2, stdout, /*prefixattr=*/ 1); igraph_destroy(&g2); /* ****************************************************** */ /* ****************************************************** */ igraph_copy(&g2, &g); igraph_attribute_combination(&comb, "", IGRAPH_ATTRIBUTE_COMBINE_IGNORE, "type", IGRAPH_ATTRIBUTE_COMBINE_PROD, IGRAPH_NO_MORE_ATTRIBUTES); igraph_simplify(&g2, /*multiple=*/ 1, /*loops=*/ 1, &comb); igraph_attribute_combination_destroy(&comb); igraph_write_graph_graphml(&g2, stdout, /*prefixattr=*/ 1); igraph_destroy(&g2); /* ****************************************************** */ /* ****************************************************** */ igraph_copy(&g2, &g); igraph_attribute_combination(&comb, "", IGRAPH_ATTRIBUTE_COMBINE_IGNORE, "type", IGRAPH_ATTRIBUTE_COMBINE_MIN, IGRAPH_NO_MORE_ATTRIBUTES); igraph_simplify(&g2, /*multiple=*/ 1, /*loops=*/ 1, &comb); igraph_attribute_combination_destroy(&comb); igraph_write_graph_graphml(&g2, stdout, /*prefixattr=*/ 1); igraph_destroy(&g2); /* ****************************************************** */ /* ****************************************************** */ igraph_copy(&g2, &g); igraph_attribute_combination(&comb, "", IGRAPH_ATTRIBUTE_COMBINE_IGNORE, "type", IGRAPH_ATTRIBUTE_COMBINE_MAX, IGRAPH_NO_MORE_ATTRIBUTES); igraph_simplify(&g2, /*multiple=*/ 1, /*loops=*/ 1, &comb); igraph_attribute_combination_destroy(&comb); igraph_write_graph_graphml(&g2, stdout, /*prefixattr=*/ 1); igraph_destroy(&g2); /* ****************************************************** */ /* ****************************************************** */ igraph_copy(&g2, &g); igraph_attribute_combination(&comb, "", IGRAPH_ATTRIBUTE_COMBINE_IGNORE, "type", IGRAPH_ATTRIBUTE_COMBINE_MEAN, IGRAPH_NO_MORE_ATTRIBUTES); igraph_simplify(&g2, /*multiple=*/ 1, /*loops=*/ 1, &comb); igraph_attribute_combination_destroy(&comb); igraph_write_graph_graphml(&g2, stdout, /*prefixattr=*/ 1); igraph_destroy(&g2); /* ****************************************************** */ /* ****************************************************** */ igraph_copy(&g2, &g); igraph_attribute_combination(&comb, "", IGRAPH_ATTRIBUTE_COMBINE_IGNORE, "type", IGRAPH_ATTRIBUTE_COMBINE_MEDIAN, IGRAPH_NO_MORE_ATTRIBUTES); igraph_simplify(&g2, /*multiple=*/ 1, /*loops=*/ 1, &comb); igraph_attribute_combination_destroy(&comb); igraph_write_graph_graphml(&g2, stdout, /*prefixattr=*/ 1); igraph_destroy(&g2); /* ****************************************************** */ igraph_destroy(&g); return 0; }
int main() { igraph_t g; igraph_vector_t weights, result; igraph_bool_t dag; int retval; igraph_vector_init(&result, 0); igraph_set_error_handler(&igraph_error_handler_printignore); /***********************************************************************/ /* Exact solution with integer programming */ /***********************************************************************/ /* Simple unweighted graph */ igraph_small(&g, 0, IGRAPH_DIRECTED, 0,1, 1,2, 2,0, 2,3, 2,4, 0,4, 4,3, 5,0, 6,5, -1); retval = igraph_feedback_arc_set(&g, &result, 0, IGRAPH_FAS_EXACT_IP); if (retval == IGRAPH_UNIMPLEMENTED) return 77; igraph_vector_print(&result); igraph_delete_edges(&g, igraph_ess_vector(&result)); igraph_is_dag(&g, &dag); if (!dag) return 1; igraph_destroy(&g); /* Simple weighted graph */ igraph_small(&g, 0, IGRAPH_DIRECTED, 0,1, 1,2, 2,0, 2,3, 2,4, 0,4, 4,3, 5,0, 6,5, -1); igraph_vector_init_int_end(&weights, -1, 1, 1, 3, 1, 1, 1, 1, 1, 1, -1); igraph_feedback_arc_set(&g, &result, &weights, IGRAPH_FAS_EXACT_IP); igraph_vector_print(&result); igraph_delete_edges(&g, igraph_ess_vector(&result)); igraph_is_dag(&g, &dag); if (!dag) return 2; igraph_vector_destroy(&weights); igraph_destroy(&g); /* Simple unweighted graph with loops */ igraph_small(&g, 0, IGRAPH_DIRECTED, 0,1, 1,2, 2,0, 2,3, 2,4, 0,4, 4,3, 5,0, 6,5, 1,1, 4,4, -1); igraph_feedback_arc_set(&g, &result, 0, IGRAPH_FAS_EXACT_IP); igraph_vector_print(&result); igraph_delete_edges(&g, igraph_ess_vector(&result)); igraph_is_dag(&g, &dag); if (!dag) return 3; igraph_destroy(&g); /* Disjoint union of two almost identical graphs */ igraph_small(&g, 0, IGRAPH_DIRECTED, 0,1, 1,2, 2,0, 2,3, 2,4, 0,4, 4,3, 5,0, 6,5, 1,1, 4,4, 7,8, 8,9, 9,7, 9,10, 9,11, 7,11, 11,10, 12,7, 13,12, -1); igraph_feedback_arc_set(&g, &result, 0, IGRAPH_FAS_EXACT_IP); igraph_vector_print(&result); igraph_delete_edges(&g, igraph_ess_vector(&result)); igraph_is_dag(&g, &dag); if (!dag) return 4; igraph_destroy(&g); /* Graph with lots of isolated vertices */ igraph_small(&g, 10000, IGRAPH_DIRECTED, 0,1, -1); igraph_feedback_arc_set(&g, &result, 0, IGRAPH_FAS_EXACT_IP); igraph_vector_print(&result); igraph_delete_edges(&g, igraph_ess_vector(&result)); igraph_is_dag(&g, &dag); if (!dag) return 5; igraph_destroy(&g); igraph_vector_destroy(&result); return 0; }
int main() { igraph_t g; FILE *karate, *neural; igraph_real_t res; igraph_vector_t types; igraph_vector_t degree, outdegree, indegree; igraph_real_t football_types[] = { 7,0,2,3,7,3,2,8,8,7,3,10,6,2,6,2,7,9,6,1,9,8,8,7,10,0,6,9, 11,1,1,6,2,0,6,1,5,0,6,2,3,7,5,6,4,0,11,2,4,11,10,8,3,11,6, 1,9,4,11,10,2,6,9,10,2,9,4,11,8,10,9,6,3,11,3,4,9,8,8,1,5,3, 5,11,3,6,4,9,11,0,5,4,4,7,1,9,9,10,3,6,2,1,3,0,7,0,2,3,8,0, 4,8,4,9,11 }; karate=fopen("karate.gml", "r"); igraph_read_graph_gml(&g, karate); fclose(karate); igraph_vector_init(&types, 0); igraph_degree(&g, &types, igraph_vss_all(), IGRAPH_ALL, /*loops=*/ 1); igraph_assortativity_nominal(&g, &types, &res, /*directed=*/ 0); printf("%.5f\n", res); igraph_destroy(&g); /*---------------------*/ neural=fopen("celegansneural.gml", "r"); igraph_read_graph_gml(&g, neural); fclose(neural); igraph_degree(&g, &types, igraph_vss_all(), IGRAPH_ALL, /*loops=*/ 1); igraph_assortativity_nominal(&g, &types, &res, /*directed=*/ 1); printf("%.5f\n", res); igraph_assortativity_nominal(&g, &types, &res, /*directed=*/ 0); printf("%.5f\n", res); igraph_destroy(&g); igraph_vector_destroy(&types); /*---------------------*/ karate=fopen("karate.gml", "r"); igraph_read_graph_gml(&g, karate); fclose(karate); igraph_vector_init(°ree, 0); igraph_degree(&g, °ree, igraph_vss_all(), IGRAPH_ALL, /*loops=*/ 1); igraph_vector_add_constant(°ree, -1); igraph_assortativity(&g, °ree, 0, &res, /*directed=*/ 0); printf("%.5f\n", res); igraph_destroy(&g); /*---------------------*/ neural=fopen("celegansneural.gml", "r"); igraph_read_graph_gml(&g, neural); fclose(neural); igraph_degree(&g, °ree, igraph_vss_all(), IGRAPH_ALL, /*loops=*/ 1); igraph_vector_add_constant(°ree, -1); igraph_assortativity(&g, °ree, 0, &res, /*directed=*/ 1); printf("%.5f\n", res); igraph_assortativity(&g, °ree, 0, &res, /*directed=*/ 0); printf("%.5f\n", res); igraph_vector_destroy(°ree); /*---------------------*/ igraph_vector_init(&indegree, 0); igraph_vector_init(&outdegree, 0); igraph_degree(&g, &indegree, igraph_vss_all(), IGRAPH_IN, /*loops=*/ 1); igraph_degree(&g, &outdegree, igraph_vss_all(), IGRAPH_OUT, /*loops=*/ 1); igraph_vector_add_constant(&indegree, -1); igraph_vector_add_constant(&outdegree, -1); igraph_assortativity(&g, &outdegree, &indegree, &res, /*directed=*/ 1); printf("%.5f\n", res); igraph_vector_destroy(&indegree); igraph_vector_destroy(&outdegree); /*---------------------*/ igraph_assortativity_degree(&g, &res, /*directed=*/ 1); printf("%.5f\n", res); igraph_destroy(&g); /*---------------------*/ karate=fopen("karate.gml", "r"); igraph_read_graph_gml(&g, karate); fclose(karate); igraph_assortativity_degree(&g, &res, /*directed=*/ 1); printf("%.5f\n", res); igraph_destroy(&g); /*---------------------*/ igraph_small(&g, sizeof(football_types)/sizeof(igraph_real_t), IGRAPH_UNDIRECTED, 0,1,2,3,0,4,4,5,3,5,2,6,6,7,7,8,8,9,0,9,4,9,5,10,10,11,5,11, 3,11,12,13,2,13,2,14,12,14,14,15,13,15,2,15,4,16,9,16,0,16, 16,17,12,17,12,18,18,19,17,20,20,21,8,21,7,21,9,22,7,22,21, 22,8,22,22,23,9,23,4,23,16,23,0,23,11,24,24,25,1,25,3,26,12, 26,14,26,26,27,17,27,1,27,17,27,4,28,11,28,24,28,19,29,29, 30,19,30,18,31,31,32,21,32,15,32,13,32,6,32,0,33,1,33,25,33, 19,33,31,34,26,34,12,34,18,34,34,35,0,35,29,35,19,35,30,35, 18,36,12,36,20,36,19,36,36,37,1,37,25,37,33,37,18,38,16,38, 28,38,26,38,14,38,12,38,38,39,6,39,32,39,13,39,15,39,7,40,3, 40,40,41,8,41,4,41,23,41,9,41,0,41,16,41,34,42,29,42,18,42, 26,42,42,43,36,43,26,43,31,43,38,43,12,43,14,43,19,44,35,44, 30,44,44,45,13,45,33,45,1,45,37,45,25,45,21,46,46,47,22,47, 6,47,15,47,2,47,39,47,32,47,44,48,48,49,32,49,46,49,30,50, 24,50,11,50,28,50,50,51,40,51,8,51,22,51,21,51,3,52,40,52,5, 52,52,53,25,53,48,53,49,53,46,53,39,54,31,54,38,54,14,54,34, 54,18,54,54,55,31,55,6,55,35,55,29,55,19,55,30,55,27,56,56, 57,1,57,42,57,44,57,48,57,3,58,6,58,17,58,36,58,36,59,58,59, 59,60,10,60,39,60,6,60,47,60,13,60,15,60,2,60,43,61,47,61, 54,61,18,61,26,61,31,61,34,61,61,62,20,62,45,62,17,62,27,62, 56,62,27,63,58,63,59,63,42,63,63,64,9,64,32,64,60,64,2,64,6, 64,47,64,13,64,0,65,27,65,17,65,63,65,56,65,20,65,65,66,59, 66,24,66,44,66,48,66,16,67,41,67,46,67,53,67,49,67,67,68,15, 68,50,68,21,68,51,68,7,68,22,68,8,68,4,69,24,69,28,69,50,69, 11,69,69,70,43,70,65,70,20,70,56,70,62,70,27,70,60,71,18,71, 14,71,34,71,54,71,38,71,61,71,31,71,71,72,2,72,10,72,3,72, 40,72,52,72,7,73,49,73,53,73,67,73,46,73,73,74,2,74,72,74,5, 74,10,74,52,74,3,74,40,74,20,75,66,75,48,75,57,75,44,75,75, 76,27,76,59,76,20,76,70,76,66,76,56,76,62,76,73,77,22,77,7, 77,51,77,21,77,8,77,77,78,23,78,50,78,28,78,22,78,8,78,68, 78,7,78,51,78,31,79,43,79,30,79,19,79,29,79,35,79,55,79,79, 80,37,80,29,80,16,81,5,81,40,81,10,81,72,81,3,81,81,82,74, 82,39,82,77,82,80,82,30,82,29,82,7,82,53,83,81,83,69,83,73, 83,46,83,67,83,49,83,83,84,24,84,49,84,52,84,3,84,74,84,10, 84,81,84,5,84,3,84,6,85,14,85,38,85,43,85,80,85,12,85,26,85, 31,85,44,86,53,86,75,86,57,86,48,86,80,86,66,86,86,87,17,87, 62,87,56,87,24,87,20,87,65,87,49,88,58,88,83,88,69,88,46,88, 53,88,73,88,67,88,88,89,1,89,37,89,25,89,33,89,55,89,45,89, 5,90,8,90,23,90,0,90,11,90,50,90,24,90,69,90,28,90,29,91,48, 91,66,91,69,91,44,91,86,91,57,91,80,91,91,92,35,92,15,92,86, 92,48,92,57,92,61,92,66,92,75,92,0,93,23,93,80,93,16,93,4, 93,82,93,91,93,41,93,9,93,34,94,19,94,55,94,79,94,80,94,29, 94,30,94,82,94,35,94,70,95,69,95,76,95,62,95,56,95,27,95,17, 95,87,95,37,95,48,96,17,96,76,96,27,96,56,96,65,96,20,96,87, 96,5,97,86,97,58,97,11,97,59,97,63,97,97,98,77,98,48,98,84, 98,40,98,10,98,5,98,52,98,81,98,89,99,34,99,14,99,85,99,54, 99,18,99,31,99,61,99,71,99,14,99,99,100,82,100,13,100,2,100, 15,100,32,100,64,100,47,100,39,100,6,100,51,101,30,101,94, 101,1,101,79,101,58,101,19,101,55,101,35,101,29,101,100,102, 74,102,52,102,98,102,72,102,40,102,10,102,3,102,102,103,33, 103,45,103,25,103,89,103,37,103,1,103,70,103,72,104,11,104, 0,104,93,104,67,104,41,104,16,104,87,104,23,104,4,104,9,104, 89,105,103,105,33,105,62,105,37,105,45,105,1,105,80,105,25, 105,25,106,56,106,92,106,2,106,13,106,32,106,60,106,6,106, 64,106,15,106,39,106,88,107,75,107,98,107,102,107,72,107,40, 107,81,107,5,107,10,107,84,107,4,108,9,108,7,108,51,108,77, 108,21,108,78,108,22,108,68,108,79,109,30,109,63,109,1,109, 33,109,103,109,105,109,45,109,25,109,89,109,37,109,67,110, 13,110,24,110,80,110,88,110,49,110,73,110,46,110,83,110,53, 110,23,111,64,111,46,111,78,111,8,111,21,111,51,111,7,111, 108,111,68,111,77,111,52,112,96,112,97,112,57,112,66,112,63, 112,44,112,92,112,75,112,91,112,28,113,20,113,95,113,59,113, 70,113,17,113,87,113,76,113,65,113,96,113,83,114,88,114,110, 114,53,114,49,114,73,114,46,114,67,114,58,114,15,114,104,114, -1); igraph_simplify(&g, /*multiple=*/ 1, /*loops=*/ 1, /*edge_comb=*/ 0); igraph_vector_view(&types, football_types, sizeof(football_types) / sizeof(igraph_real_t)); igraph_assortativity_nominal(&g, &types, &res, /*directed=*/ 0); printf("%.5f\n", res); igraph_destroy(&g); return 0; }
int main() { igraph_t g; igraph_vector_t modularity, membership, edges; igraph_matrix_t memberships; int i, j, k; igraph_vector_init(&modularity,0); igraph_vector_init(&membership,0); igraph_matrix_init(&memberships,0,0); /* Unweighted test graph from the paper of Blondel et al */ igraph_small(&g, 16, IGRAPH_UNDIRECTED, 0, 2, 0, 3, 0, 4, 0, 5, 1, 2, 1, 4, 1, 7, 2, 4, 2, 5, 2, 6, 3, 7, 4, 10, 5, 7, 5, 11, 6, 7, 6, 11, 8, 9, 8, 10, 8, 11, 8, 14, 8, 15, 9, 12, 9, 14, 10, 11, 10, 12, 10, 13, 10, 14, 11, 13, -1); /*FILE *fp; fp=fopen("abc.gml","w"); igraph_write_graph_gml(&g,fp,NULL,0);*/ igraph_community_multilevel(&g, 0, &membership, &memberships, &modularity); show_results(&g, &membership, &memberships, &modularity, stdout); igraph_destroy(&g); /* Ring of 30 cliques */ /*igraph_vector_init(&edges,0); for (i = 0; i < 30; i++) { for (j = 0; j < 5; j++) { for (k = j+1; k < 5; k++) { igraph_vector_push_back(&edges, i*5+j); igraph_vector_push_back(&edges, i*5+k); } } } for (i = 0; i < 30; i++) { igraph_vector_push_back(&edges, i*5 % 150); igraph_vector_push_back(&edges, (i*5+6) % 150); } igraph_create(&g, &edges, 150, 0); igraph_community_multilevel(&g, 0, &membership, &memberships, &modularity); show_results(&g, &membership, &memberships, &modularity, stdout); igraph_destroy(&g);*/ igraph_vector_destroy(&modularity); igraph_vector_destroy(&membership); igraph_vector_destroy(&edges); igraph_matrix_destroy(&memberships); #ifdef __APPLE__ return 0; #else return 77; #endif }
int main() { igraph_t g, g2, cli; igraph_vector_t perm; igraph_vector_ptr_t cliques; igraph_integer_t no; int i; igraph_rng_seed(igraph_rng_default(), 42); /* Create a graph that has a random component, plus a number of relatively small cliques */ igraph_vector_init_seq(&perm, 0, NODES-1); igraph_erdos_renyi_game(&g, IGRAPH_ERDOS_RENYI_GNM, NODES, NODES, /*directed=*/ 0, /*loops=*/ 0, igraph_rng_default()); igraph_full(&cli, CLIQUE_SIZE, /*directed=*/ 0, /*loops=*/ 0); for (i=0; i<NO_CLIQUES; i++) { /* Permute vertices of g */ permutation(&perm); igraph_permute_vertices(&g, &g2, &perm); igraph_destroy(&g); g=g2; /* Add a clique */ igraph_union(&g2, &g, &cli, /*edge_map1=*/ 0, /*edge_map2=*/ 0); igraph_destroy(&g); g=g2; } igraph_simplify(&g, /*multiple=*/ 1, /*loop=*/ 0, /*edge_comb=*/ 0); igraph_vector_destroy(&perm); igraph_destroy(&cli); /* Find the maximal cliques */ igraph_vector_ptr_init(&cliques, 0); igraph_maximal_cliques(&g, &cliques, /*min_size=*/ 3, /*max_size=*/ 0 /*no limit*/); igraph_maximal_cliques_count(&g, &no, /*min_size=*/ 3, /*max_size=*/ 0 /*no limit*/); if (no != igraph_vector_ptr_size(&cliques)) { return 1; } /* Print and destroy them */ print_and_destroy_cliques(&cliques); /* Clean up */ igraph_vector_ptr_destroy(&cliques); igraph_destroy(&g); /* Build a triangle with a loop (thanks to Emmanuel Navarro) */ igraph_small(&g, 3, IGRAPH_UNDIRECTED, 0, 1, 1, 2, 2, 0, 0, 0, -1); /* Find the maximal cliques */ igraph_vector_ptr_init(&cliques, 0); igraph_maximal_cliques(&g, &cliques, /*min_size=*/ 3, /*max_size=*/ 0 /*no limit*/); igraph_maximal_cliques_count(&g, &no, /*min_size=*/ 3, /*max_size=*/ 0 /*no limit*/); if (no != igraph_vector_ptr_size(&cliques)) { return 2; } /* Print and destroy them */ print_and_destroy_cliques(&cliques); /* Clean up */ igraph_vector_ptr_destroy(&cliques); igraph_destroy(&g); return 0; }
int main() { igraph_t g; igraph_vector_t v, res, reset, weights; igraph_arpack_options_t arpack_options; igraph_real_t value; int ret; igraph_pagerank_power_options_t power_options; /* Test graphs taken from http://www.iprcom.com/papers/pagerank/ */ igraph_vector_init(&v, 10); VECTOR(v)[0]=0; VECTOR(v)[1]=1; VECTOR(v)[2]=1; VECTOR(v)[3]=2; VECTOR(v)[4]=2; VECTOR(v)[5]=0; VECTOR(v)[6]=3; VECTOR(v)[7]=2; VECTOR(v)[8]=0; VECTOR(v)[9]=2; igraph_create(&g, &v, 0, 1); igraph_vector_init(&res, 0); oldwarn=igraph_set_warning_handler(warning_handler_stdout); igraph_pagerank_old(&g, &res, igraph_vss_all(), 1, 1000, 0.001, 0.85, 0); print_vector(&res, stdout); igraph_vector_destroy(&res); igraph_vector_destroy(&v); igraph_destroy(&g); igraph_vector_init(&v, 28); VECTOR(v)[ 0]=0; VECTOR(v)[ 1]=1; VECTOR(v)[ 2]=0; VECTOR(v)[ 3]=2; VECTOR(v)[ 4]=0; VECTOR(v)[ 5]=3; VECTOR(v)[ 6]=1; VECTOR(v)[ 7]=0; VECTOR(v)[ 8]=2; VECTOR(v)[ 9]=0; VECTOR(v)[10]=3; VECTOR(v)[11]=0; VECTOR(v)[12]=3; VECTOR(v)[13]=4; VECTOR(v)[14]=3; VECTOR(v)[15]=5; VECTOR(v)[16]=3; VECTOR(v)[17]=6; VECTOR(v)[18]=3; VECTOR(v)[19]=7; VECTOR(v)[20]=4; VECTOR(v)[21]=0; VECTOR(v)[22]=5; VECTOR(v)[23]=0; VECTOR(v)[24]=6; VECTOR(v)[25]=0; VECTOR(v)[26]=7; VECTOR(v)[27]=0; igraph_create(&g, &v, 0, 1); igraph_vector_init(&res, 0); igraph_pagerank_old(&g, &res, igraph_vss_all(), 1, 10000, 0.0001, 0.85, 0); print_vector(&res, stdout); igraph_vector_destroy(&res); igraph_vector_destroy(&v); igraph_destroy(&g); igraph_set_warning_handler(oldwarn); /* New PageRank */ igraph_star(&g, 11, IGRAPH_STAR_UNDIRECTED, 0); igraph_vector_init(&res, 0); igraph_arpack_options_init(&arpack_options); igraph_pagerank(&g, IGRAPH_PAGERANK_ALGO_ARPACK, &res, 0, igraph_vss_all(), 0, 0.85, 0, &arpack_options); print_vector(&res, stdout); igraph_pagerank(&g, IGRAPH_PAGERANK_ALGO_PRPACK, &res, 0, igraph_vss_all(), 0, 0.85, 0, 0); print_vector(&res, stdout); /* Check twice more for consistency */ igraph_pagerank(&g, IGRAPH_PAGERANK_ALGO_ARPACK, &res, 0, igraph_vss_all(), 0, 0.85, 0, &arpack_options); print_vector(&res, stdout); igraph_pagerank(&g, IGRAPH_PAGERANK_ALGO_PRPACK, &res, 0, igraph_vss_all(), 0, 0.85, 0, 0); print_vector(&res, stdout); igraph_pagerank(&g, IGRAPH_PAGERANK_ALGO_ARPACK, &res, 0, igraph_vss_all(), 0, 0.85, 0, &arpack_options); print_vector(&res, stdout); igraph_pagerank(&g, IGRAPH_PAGERANK_ALGO_PRPACK, &res, 0, igraph_vss_all(), 0, 0.85, 0, 0); print_vector(&res, stdout); /* Check personalized PageRank */ igraph_personalized_pagerank_vs(&g, IGRAPH_PAGERANK_ALGO_ARPACK, &res, 0, igraph_vss_all(), 0, 0.5, igraph_vss_1(1), 0, &arpack_options); print_vector(&res, stdout); igraph_personalized_pagerank_vs(&g, IGRAPH_PAGERANK_ALGO_PRPACK, &res, 0, igraph_vss_all(), 0, 0.5, igraph_vss_1(1), 0, 0); print_vector(&res, stdout); /* Errors */ power_options.niter = -1; power_options.eps=0.0001; igraph_set_error_handler(igraph_error_handler_ignore); igraph_set_warning_handler(igraph_warning_handler_ignore); ret=igraph_pagerank(&g, IGRAPH_PAGERANK_ALGO_POWER, &res, /*value=*/ 0, igraph_vss_all(), 1, 0.85, /*weights=*/ 0, &power_options); if (ret != IGRAPH_EINVAL) { return 1; } power_options.niter=10000; power_options.eps=-1; ret=igraph_pagerank(&g, IGRAPH_PAGERANK_ALGO_POWER, &res, /*value=*/ 0, igraph_vss_all(), 1, 0.85, /*weights=*/ 0, &power_options); if (ret != IGRAPH_EINVAL) { return 2; } power_options.niter=10000; power_options.eps=0.0001; ret=igraph_pagerank(&g, IGRAPH_PAGERANK_ALGO_POWER, &res, /*value=*/ 0, igraph_vss_all(), 1, 1.2, /*weights=*/ 0, &power_options); if (ret != IGRAPH_EINVAL) { return 3; } igraph_vector_init(&reset, 2); ret=igraph_personalized_pagerank(&g, IGRAPH_PAGERANK_ALGO_ARPACK, &res, 0, igraph_vss_all(), 0, 0.85, &reset, 0, &arpack_options); if (ret != IGRAPH_EINVAL) { return 4; } ret=igraph_personalized_pagerank(&g, IGRAPH_PAGERANK_ALGO_PRPACK, &res, 0, igraph_vss_all(), 0, 0.85, &reset, 0, 0); if (ret != IGRAPH_EINVAL) { return 4; } igraph_vector_resize(&reset, 10); igraph_vector_fill(&reset, 0); ret=igraph_personalized_pagerank(&g, IGRAPH_PAGERANK_ALGO_ARPACK, &res, 0, igraph_vss_all(), 0, 0.85, &reset, 0, &arpack_options); if (ret != IGRAPH_EINVAL) { return 5; } ret=igraph_personalized_pagerank(&g, IGRAPH_PAGERANK_ALGO_PRPACK, &res, 0, igraph_vss_all(), 0, 0.85, &reset, 0, 0); if (ret != IGRAPH_EINVAL) { return 5; } igraph_vector_destroy(&reset); igraph_destroy(&g); igraph_set_error_handler(igraph_error_handler_abort); /* Special cases: check for empty graph */ igraph_empty(&g, 10, 0); igraph_pagerank(&g, IGRAPH_PAGERANK_ALGO_ARPACK, &res, &value, igraph_vss_all(), 1, 0.85, 0, &arpack_options); if (value != 1.0) { return 6; } igraph_pagerank(&g, IGRAPH_PAGERANK_ALGO_PRPACK, &res, &value, igraph_vss_all(), 1, 0.85, 0, 0); if (value != 1.0) { return 6; } print_vector(&res, stdout); igraph_destroy(&g); /* Special cases: check for full graph, zero weights */ igraph_full(&g, 10, 0, 0); igraph_vector_init(&v, 45); igraph_vector_fill(&v, 0); igraph_pagerank(&g, IGRAPH_PAGERANK_ALGO_ARPACK, &res, &value, igraph_vss_all(), 1, 0.85, &v, &arpack_options); if (value != 1.0) { return 7; } igraph_pagerank(&g, IGRAPH_PAGERANK_ALGO_PRPACK, &res, &value, igraph_vss_all(), 1, 0.85, &v, 0); if (value != 1.0) { return 7; } igraph_vector_destroy(&v); print_vector(&res, stdout); igraph_destroy(&g); /* Another test case for PageRank (bug #792352) */ igraph_small(&g, 9, 1, 0, 5, 1, 5, 2, 0, 3, 1, 5, 4, 5, 7, 6, 0, 8, 0, 8, 1, -1); igraph_vector_init(&weights, 9); VECTOR(weights)[0] = 4; VECTOR(weights)[1] = 5; VECTOR(weights)[2] = 5; VECTOR(weights)[3] = 4; VECTOR(weights)[4] = 4; VECTOR(weights)[5] = 4; VECTOR(weights)[6] = 3; VECTOR(weights)[7] = 4; VECTOR(weights)[8] = 4; igraph_pagerank(&g, IGRAPH_PAGERANK_ALGO_ARPACK, &res, 0, igraph_vss_all(), 1, 0.85, &weights, &arpack_options); print_vector(&res, stdout); igraph_pagerank(&g, IGRAPH_PAGERANK_ALGO_PRPACK, &res, 0, igraph_vss_all(), 1, 0.85, &weights, 0); print_vector(&res, stdout); igraph_vector_destroy(&weights); igraph_destroy(&g); igraph_vector_destroy(&res); return 0; }
int main() { igraph_t g; igraph_vector_t weights; igraph_real_t weights_data_0[] = { 0,2,1, 0,5,2, 1,1,0, 2,2,8, 1,1,3, 1,1,4, 2,1 }; igraph_real_t weights_data_1[] = { 6,7,8,-4,-2,-3,9,2,7 }; igraph_real_t weights_data_2[] = { 6,7,2,-4,-2,-3,9,2,7 }; igraph_matrix_t res; /* Graph with only positive weights */ igraph_small(&g, 10, IGRAPH_DIRECTED, 0,1, 0,2, 0,3, 1,2, 1,4, 1,5, 2,3, 2,6, 3,2, 3,6, 4,5, 4,7, 5,6, 5,8, 5,9, 7,5, 7,8, 8,9, 5,2, 2,1, -1); igraph_vector_view(&weights, weights_data_0, sizeof(weights_data_0)/sizeof(igraph_real_t)); igraph_matrix_init(&res, 0, 0); igraph_shortest_paths_bellman_ford(&g, &res, igraph_vss_all(), igraph_vss_all(), &weights, IGRAPH_OUT); print_matrix(&res); igraph_matrix_destroy(&res); igraph_destroy(&g); printf("\n"); /***************************************/ /* Graph with negative weights */ igraph_small(&g, 5, IGRAPH_DIRECTED, 0,1, 0,3, 1,3, 1,4, 2,1, 3,2, 3,4, 4,0, 4,2, -1); igraph_vector_view(&weights, weights_data_1, sizeof(weights_data_1)/sizeof(igraph_real_t)); igraph_matrix_init(&res, 0, 0); igraph_shortest_paths_bellman_ford(&g, &res, igraph_vss_all(), igraph_vss_all(), &weights, IGRAPH_OUT); print_matrix(&res); /***************************************/ /* Same graph with negative loop */ igraph_set_error_handler(igraph_error_handler_ignore); igraph_vector_view(&weights, weights_data_2, sizeof(weights_data_2)/sizeof(igraph_real_t)); if (igraph_shortest_paths_bellman_ford(&g, &res, igraph_vss_all(), igraph_vss_all(), &weights, IGRAPH_OUT) != IGRAPH_ENEGLOOP) return 1; igraph_matrix_destroy(&res); igraph_destroy(&g); if (!IGRAPH_FINALLY_STACK_EMPTY) return 1; return 0; }
int main() { igraph_t g; igraph_vector_ptr_t cuts, partition1s; long int i, n; igraph_marked_queue_t S; igraph_estack_t T; long int v; igraph_vector_t Isv; /* ----------------------------------------------------------- */ /* This is the example from the Provan-Shier paper, for calculating the dominator tree and finding the right pivot element */ igraph_small(&g, 12, IGRAPH_DIRECTED, /* a->b */ 0,1, /* b->t */ 1,11, /* c->b */ 2,1, /* c->d */ 2,3, /* d->e */ 3,4, /* d->i */ 3,8, /* e->c */ 4,2, /* f->c */ 5,2, /* f->e */ 5,4, /* g->d */ 6,3, /* g->e */ 6,4, /* g->f */ 6,5, /* g->j */ 6,9, /* h->g */ 7,6, /* h->t */ 7,11, /* i->a */ 8,0, /* j->i */ 9,8, /* s->a */ 10,0, /* s->c */ 10,2, /* s->h */ 10,7, -1); /* S={s,a} */ igraph_marked_queue_init(&S, igraph_vcount(&g)); igraph_marked_queue_start_batch(&S); igraph_marked_queue_push(&S, 10); igraph_marked_queue_push(&S, 0); /* T={t} */ igraph_estack_init(&T, igraph_vcount(&g), 1); igraph_estack_push(&T, 11); igraph_vector_init(&Isv, 0); igraph_i_all_st_cuts_pivot(&g, &S, &T, /*source=*/ 10, /*target=*/ 11, &v, &Isv); /* Expected result: v=c, Isv={c,d,e,i} */ printf("%li; ", v); igraph_vector_print(&Isv); igraph_vector_destroy(&Isv); igraph_estack_destroy(&T); igraph_marked_queue_destroy(&S); igraph_destroy(&g); /* ----------------------------------------------------------- */ igraph_small(&g, 3, IGRAPH_DIRECTED, 0,1, 1,2, -1); /* S={}, T={} */ igraph_marked_queue_init(&S, igraph_vcount(&g)); igraph_estack_init(&T, igraph_vcount(&g), 3); igraph_vector_init(&Isv, 0); igraph_i_all_st_cuts_pivot(&g, &S, &T, /*source=*/ 0, /*target=*/ 2, &v, &Isv); printf("%li; ", v); igraph_vector_print(&Isv); igraph_vector_destroy(&Isv); igraph_estack_destroy(&T); igraph_marked_queue_destroy(&S); igraph_destroy(&g); /* ----------------------------------------------------------- */ igraph_small(&g, 3, IGRAPH_DIRECTED, 0,1, 1,2, -1); /* S={}, T={0} */ igraph_marked_queue_init(&S, igraph_vcount(&g)); igraph_estack_init(&T, igraph_vcount(&g), 3); igraph_estack_push(&T, 0); igraph_vector_init(&Isv, 0); igraph_i_all_st_cuts_pivot(&g, &S, &T, /*source=*/ 0, /*target=*/ 2, &v, &Isv); printf("%li; ", v); igraph_vector_print(&Isv); igraph_vector_destroy(&Isv); igraph_estack_destroy(&T); igraph_marked_queue_destroy(&S); igraph_destroy(&g); /* ----------------------------------------------------------- */ igraph_small(&g, 3, IGRAPH_DIRECTED, 0,1, 1,2, -1); /* S={0}, T={} */ igraph_marked_queue_init(&S, igraph_vcount(&g)); igraph_marked_queue_push(&S, 0); igraph_estack_init(&T, igraph_vcount(&g), 3); igraph_vector_init(&Isv, 0); igraph_i_all_st_cuts_pivot(&g, &S, &T, /*source=*/ 0, /*target=*/ 2, &v, &Isv); printf("%li; ", v); igraph_vector_print(&Isv); igraph_vector_destroy(&Isv); igraph_estack_destroy(&T); igraph_marked_queue_destroy(&S); igraph_destroy(&g); /* ----------------------------------------------------------- */ igraph_small(&g, 3, IGRAPH_DIRECTED, 0,1, 1,2, -1); /* S={0}, T={1} */ igraph_marked_queue_init(&S, igraph_vcount(&g)); igraph_marked_queue_push(&S, 0); igraph_estack_init(&T, igraph_vcount(&g), 3); igraph_estack_push(&T, 1); igraph_vector_init(&Isv, 0); igraph_i_all_st_cuts_pivot(&g, &S, &T, /*source=*/ 0, /*target=*/ 2, &v, &Isv); printf("%li; ", v); igraph_vector_print(&Isv); igraph_vector_destroy(&Isv); igraph_estack_destroy(&T); igraph_marked_queue_destroy(&S); igraph_destroy(&g); /* ----------------------------------------------------------- */ igraph_small(&g, 3, IGRAPH_DIRECTED, 0,1, 1,2, -1); /* S={0,1}, T={} */ igraph_marked_queue_init(&S, igraph_vcount(&g)); igraph_marked_queue_push(&S, 0); igraph_marked_queue_push(&S, 1); igraph_estack_init(&T, igraph_vcount(&g), 3); igraph_vector_init(&Isv, 0); igraph_i_all_st_cuts_pivot(&g, &S, &T, /*source=*/ 0, /*target=*/ 2, &v, &Isv); printf("%li; ", v); igraph_vector_print(&Isv); igraph_vector_destroy(&Isv); igraph_estack_destroy(&T); igraph_marked_queue_destroy(&S); igraph_destroy(&g); /* ----------------------------------------------------------- */ igraph_small(&g, 3, IGRAPH_DIRECTED, 0,1, 1,2, -1); igraph_vector_ptr_init(&partition1s, 0); igraph_all_st_cuts(&g, /*cuts=*/ 0, &partition1s, /*source=*/ 0, /*target=*/ 2); n=igraph_vector_ptr_size(&partition1s); for (i=0; i<n; i++) { igraph_vector_t *v=VECTOR(partition1s)[i]; igraph_vector_print(v); igraph_vector_destroy(v); igraph_free(v); } igraph_vector_ptr_destroy(&partition1s); igraph_destroy(&g); /* ----------------------------------------------------------- */ igraph_small(&g, 5, IGRAPH_DIRECTED, 0,1, 1,2, 1,3, 2,4, 3,4, -1); igraph_vector_ptr_init(&partition1s, 0); igraph_all_st_cuts(&g, /*cuts=*/ 0, &partition1s, /*source=*/ 0, /*target=*/ 4); n=igraph_vector_ptr_size(&partition1s); for (i=0; i<n; i++) { igraph_vector_t *v=VECTOR(partition1s)[i]; igraph_vector_print(v); igraph_vector_destroy(v); igraph_free(v); } igraph_vector_ptr_destroy(&partition1s); igraph_destroy(&g); /* ----------------------------------------------------------- */ igraph_small(&g, 6, IGRAPH_DIRECTED, 0,1, 1,2, 1,3, 2,4, 3,4, 1,5, 5,4, -1); igraph_vector_ptr_init(&cuts, 0); igraph_vector_ptr_init(&partition1s, 0); igraph_all_st_cuts(&g, &cuts, &partition1s, /*source=*/ 0, /*target=*/ 4); n=igraph_vector_ptr_size(&partition1s); printf("Partitions and cuts:\n"); for (i=0; i<n; i++) { igraph_vector_t *v=VECTOR(partition1s)[i]; igraph_vector_t *v2=VECTOR(cuts)[i]; printf("P: "); igraph_vector_print(v); igraph_vector_destroy(v); igraph_free(v); printf("C: "); igraph_vector_print(v2); igraph_vector_destroy(v2); igraph_free(v2); } igraph_vector_ptr_destroy(&partition1s); igraph_vector_ptr_destroy(&cuts); igraph_destroy(&g); /* ----------------------------------------------------------- */ igraph_small(&g, 3, IGRAPH_DIRECTED, 0,2, 1,2, -1); igraph_vector_ptr_init(&cuts, 0); igraph_vector_ptr_init(&partition1s, 0); igraph_all_st_cuts(&g, &cuts, &partition1s, /*source=*/ 1, /*target=*/ 2); n=igraph_vector_ptr_size(&partition1s); printf("Partitions and cuts:\n"); for (i=0; i<n; i++) { igraph_vector_t *v=VECTOR(partition1s)[i]; igraph_vector_t *v2=VECTOR(cuts)[i]; printf("P: "); igraph_vector_print(v); igraph_vector_destroy(v); igraph_free(v); printf("C: "); igraph_vector_print(v2); igraph_vector_destroy(v2); igraph_free(v2); } igraph_vector_ptr_destroy(&partition1s); igraph_vector_ptr_destroy(&cuts); igraph_destroy(&g); /* ----------------------------------------------------------- */ igraph_small(&g, 5, IGRAPH_DIRECTED, 0,1, 1,2, 2,3, 3,4, 3,1, -1); igraph_vector_ptr_init(&cuts, 0); igraph_vector_ptr_init(&partition1s, 0); igraph_all_st_cuts(&g, &cuts, &partition1s, /*source=*/ 0, /*target=*/ 4); n=igraph_vector_ptr_size(&partition1s); printf("Partitions and cuts:\n"); for (i=0; i<n; i++) { igraph_vector_t *v=VECTOR(partition1s)[i]; igraph_vector_t *v2=VECTOR(cuts)[i]; printf("P: "); igraph_vector_print(v); igraph_vector_destroy(v); igraph_free(v); printf("C: "); igraph_vector_print(v2); igraph_vector_destroy(v2); igraph_free(v2); } igraph_vector_ptr_destroy(&partition1s); igraph_vector_ptr_destroy(&cuts); igraph_destroy(&g); /* ----------------------------------------------------------- */ igraph_small(&g, 7, IGRAPH_DIRECTED, 0,1,0,2, 1,3,2,3, 1,4,1,5,1,6, 4,2,5,2,6,2, -1); igraph_vector_ptr_init(&cuts, 0); igraph_vector_ptr_init(&partition1s, 0); igraph_all_st_cuts(&g, &cuts, &partition1s, /*source=*/ 0, /*target=*/ 3); n=igraph_vector_ptr_size(&partition1s); printf("Partitions and cuts:\n"); for (i=0; i<n; i++) { igraph_vector_t *v=VECTOR(partition1s)[i]; igraph_vector_t *v2=VECTOR(cuts)[i]; printf("P: "); igraph_vector_print(v); igraph_vector_destroy(v); igraph_free(v); printf("C: "); igraph_vector_print(v2); igraph_vector_destroy(v2); igraph_free(v2); } igraph_vector_ptr_destroy(&partition1s); igraph_vector_ptr_destroy(&cuts); igraph_destroy(&g); return 0; }
void test_weighted() { igraph_t g; igraph_vector_t edges, eb, weights; igraph_real_t weights_array[] = { 4, 1, 3, 2, 5, 8, 6, 7 }; igraph_real_t edges_array1[] = { 2, 3, 0, 1, 4, 7, 5, 6 }; igraph_real_t edges_array2[] = { 2, 3, 6, 5, 0, 1, 4, 7 }; igraph_real_t eb_array1_lo[] = { 4, 5, 3+1/3.0-EPS, 4, 2.5, 4, 1, 1 }; igraph_real_t eb_array1_hi[] = { 4, 5, 3+1/3.0+EPS, 4, 2.5, 4, 1, 1 }; igraph_real_t eb_array2_lo[] = { 4, 5, 3+1/3.0-EPS, 6, 1.5, 2, 1, 1 }; igraph_real_t eb_array2_hi[] = { 4, 5, 3+1/3.0+EPS, 6, 1.5, 2, 1, 1 }; igraph_vector_t edges_sol1, edges_sol2, eb_sol1_lo, eb_sol1_hi, eb_sol2_lo, eb_sol2_hi; igraph_vector_view(&edges_sol1, edges_array1, sizeof(edges_array1)/sizeof(double)); igraph_vector_view(&edges_sol2, edges_array2, sizeof(edges_array2)/sizeof(double)); igraph_vector_view(&eb_sol1_lo, eb_array1_lo, sizeof(eb_array1_lo)/sizeof(double)); igraph_vector_view(&eb_sol2_lo, eb_array2_lo, sizeof(eb_array2_lo)/sizeof(double)); igraph_vector_view(&eb_sol1_hi, eb_array1_hi, sizeof(eb_array1_hi)/sizeof(double)); igraph_vector_view(&eb_sol2_hi, eb_array2_hi, sizeof(eb_array2_hi)/sizeof(double)); /* Small graph as follows: A--B--C--A, A--D--E--A, B--D, C--E */ igraph_small(&g, 0, IGRAPH_UNDIRECTED, 0, 1, 0, 2, 0, 3, 0, 4, 1, 2, 1, 3, 2, 4, 3, 4, -1); igraph_vector_view(&weights, weights_array, igraph_ecount(&g)); igraph_vector_init(&edges, 0); igraph_vector_init(&eb, 0); igraph_community_edge_betweenness(&g, &edges, &eb, 0 /*merges */, 0 /*bridges */, /*modularity=*/ 0, /*membership=*/ 0, IGRAPH_UNDIRECTED, &weights); if (!igraph_vector_all_e(&edges_sol1, &edges) && !igraph_vector_all_e(&edges_sol2, &edges)) { printf("Error, edges vector was: \n"); igraph_vector_print(&edges); exit(2); } if (!igraph_vector_between(&eb, &eb_sol1_lo, &eb_sol1_hi) && !igraph_vector_between(&eb, &eb_sol2_lo, &eb_sol2_hi)) { printf("Error, eb vector was: \n"); igraph_vector_print(&eb); exit(2); } /* Try it once again without storage space for edges */ igraph_community_edge_betweenness(&g, 0, &eb, 0 /*merges */, 0 /*bridges */, /*modularity=*/ 0, /*membership=*/ 0, IGRAPH_UNDIRECTED, &weights); if (!igraph_vector_between(&eb, &eb_sol1_lo, &eb_sol1_hi) && !igraph_vector_between(&eb, &eb_sol2_lo, &eb_sol2_hi)) { printf("Error, eb vector was: \n"); igraph_vector_print(&eb); exit(2); } igraph_vector_destroy(&eb); igraph_vector_destroy(&edges); igraph_destroy(&g); }
int main() { igraph_t g; /* Multiple edges */ igraph_small(&g, 0, IGRAPH_DIRECTED, 0,1, 0,1, 0,1, 0,1, 0,1, -1); igraph_simplify(&g, 1, 1); igraph_write_graph_edgelist(&g, stdout); igraph_destroy(&g); igraph_small(&g, 0, IGRAPH_UNDIRECTED, 1,0, 0,1, 1,0, 0,1, 0,1, -1); igraph_simplify(&g, 1, 1); if (igraph_ecount(&g) != 1) { return 1; } igraph_destroy(&g); /* Loop edges*/ igraph_small(&g, 0, IGRAPH_DIRECTED, 0,0,1,1,2,2, 1,2, -1); igraph_simplify(&g, 1, 1); igraph_write_graph_edgelist(&g, stdout); igraph_destroy(&g); igraph_small(&g, 0, IGRAPH_UNDIRECTED, 0,0,1,1,2,2, 1,2, -1); igraph_simplify(&g, 1, 1); igraph_write_graph_edgelist(&g, stdout); igraph_destroy(&g); /* Loop & multiple edges */ igraph_small(&g, 0, IGRAPH_DIRECTED, 0,0,0,0,0,0,0,0, 1,2, -1); igraph_simplify(&g, 1 /* multiple */, 0 /* loop */); igraph_write_graph_edgelist(&g, stdout); igraph_destroy(&g); igraph_small(&g, 0, IGRAPH_UNDIRECTED, 1,1,1,1,1,1,1,1, 2,3, -1); igraph_simplify(&g, 1 /* multiple */, 0 /* loop */); igraph_write_graph_edgelist(&g, stdout); igraph_destroy(&g); igraph_small(&g, 0, IGRAPH_DIRECTED, 2,2,2,2,2,2, 3,2, -1); igraph_simplify(&g, 0 /* multiple */, 1 /* loop */); igraph_write_graph_edgelist(&g, stdout); igraph_destroy(&g); igraph_small(&g, 0, IGRAPH_UNDIRECTED, 3,3,3,3, 3,4, -1); igraph_simplify(&g, 0 /* multiple */, 1 /* loop */); igraph_write_graph_edgelist(&g, stdout); igraph_destroy(&g); igraph_small(&g, 0, IGRAPH_DIRECTED, 2,2,2,2,2,2,2,2, 3,2,3,2,3,2,3,2,3,2,-1); igraph_simplify(&g, 1, 1); igraph_write_graph_edgelist(&g, stdout); igraph_destroy(&g); igraph_small(&g, 0, IGRAPH_UNDIRECTED, 2,2,2,2,2,2,2,2, 3,2,2,3,3,2,3,2,3,2,-1); igraph_simplify(&g, 1, 1); if (igraph_ecount(&g) != 1) { return 2; } igraph_destroy(&g); return 0; }
int main() { igraph_t g; igraph_real_t modularity, temperature; igraph_vector_t membership, csize; long int i; igraph_real_t cohesion, adhesion; igraph_integer_t inner_links; igraph_integer_t outer_links; igraph_small(&g, 5, IGRAPH_UNDIRECTED, 0,1,0,2,0,3,0,4, 1,2,1,3,1,4, 2,3,2,4, 3,4, 5,6,5,7,5,8,5,9, 6,7,6,8,6,9, 7,8,7,9, 8,9, 0,5, -1); igraph_vector_init(&membership, 0); igraph_vector_init(&csize, 0); igraph_community_spinglass(&g, 0, /* no weights */ &modularity, &temperature, &membership, &csize, 2, /* no of spins */ 0, /* parallel update */ 1.0, /* start temperature */ 0.01, /* stop temperature */ 0.99, /* cooling factor */ IGRAPH_SPINCOMM_UPDATE_CONFIG, 1.0, /* gamma */ IGRAPH_SPINCOMM_IMP_ORIG, /*gamma-=*/ 0); /* printf("Modularity: %f\n", modularity); */ /* printf("Temperature: %f\n", temperature); */ /* printf("Cluster sizes: "); */ /* for (i=0; i<igraph_vector_size(&csize); i++) { */ /* printf("%li ", (long int)VECTOR(csize)[i]); */ /* } */ /* printf("\n"); */ /* printf("Membership: "); */ /* for (i=0; i<igraph_vector_size(&membership); i++) { */ /* printf("%li ", (long int)VECTOR(membership)[i]); */ /* } */ /* printf("\n"); */ if (igraph_vector_size(&csize) != 2) { igraph_vector_destroy(&membership); igraph_vector_destroy(&csize); return 77; } if (VECTOR(csize)[0] != 5) { igraph_vector_destroy(&membership); igraph_vector_destroy(&csize); return 77; } /* Try to call this as well, we don't check the results currently.... */ igraph_community_spinglass_single(&g, /*weights= */ 0, /*vertex= */ 0, /*community=*/ &membership, /*cohesion= */ &cohesion, /*adhesion= */ &adhesion, /*inner_links= */ &inner_links, /*outer_links= */ &outer_links, /*spins= */ 2, /*update_rule= */ IGRAPH_SPINCOMM_UPDATE_CONFIG, /*gamma= */ 1.0); igraph_destroy(&g); igraph_vector_destroy(&membership); igraph_vector_destroy(&csize); return 0; }
int main() { igraph_t g; igraph_matrix_t merges; igraph_vector_t membership; long int i, j; igraph_bool_t split; igraph_vector_t x; igraph_real_t val; igraph_arpack_options_t options; /* Zachary Karate club */ igraph_small(&g, 0, IGRAPH_UNDIRECTED, 0, 1, 0, 2, 0, 3, 0, 4, 0, 5, 0, 6, 0, 7, 0, 8, 0, 10, 0, 11, 0, 12, 0, 13, 0, 17, 0, 19, 0, 21, 0, 31, 1, 2, 1, 3, 1, 7, 1, 13, 1, 17, 1, 19, 1, 21, 1, 30, 2, 3, 2, 7, 2, 8, 2, 9, 2, 13, 2, 27, 2, 28, 2, 32, 3, 7, 3, 12, 3, 13, 4, 6, 4, 10, 5, 6, 5, 10, 5, 16, 6, 16, 8, 30, 8, 32, 8, 33, 9, 33, 13, 33, 14, 32, 14, 33, 15, 32, 15, 33, 18, 32, 18, 33, 19, 33, 20, 32, 20, 33, 22, 32, 22, 33, 23, 25, 23, 27, 23, 29, 23, 32, 23, 33, 24, 25, 24, 27, 24, 31, 25, 31, 26, 29, 26, 33, 27, 33, 28, 31, 28, 33, 29, 32, 29, 33, 30, 32, 30, 33, 31, 32, 31, 33, 32, 33, -1); /* Make one step with all methods */ igraph_matrix_init(&merges, 0, 0); igraph_vector_init(&membership, 0); igraph_vector_init(&x, 0); igraph_arpack_options_init(&options); igraph_community_leading_eigenvector_naive(&g, &merges, &membership, 1, &options); print_matrix(&merges); print_vector(&membership); igraph_community_leading_eigenvector(&g, &merges, &membership, 1, &options); print_matrix(&merges); print_vector(&membership); igraph_vector_null(&membership); igraph_community_leading_eigenvector_step(&g, &membership, 0, &split, &x, &val, &options, 0); print_vector(&membership); print_vector(&x); printf("\n"); /* Make all the steps */ igraph_community_leading_eigenvector(&g, &merges, &membership, igraph_vcount(&g), &options); print_matrix(&merges); print_vector(&membership); /* Try to make one more step from here, should fail */ for (i=0; i<igraph_matrix_nrow(&merges)+1; i++) { igraph_community_leading_eigenvector_step(&g, &membership, i, &split, &x, &val, &options, 0); if (split) { printf("Impossible, community %li splitted.\n", i); return 1; } } igraph_vector_destroy(&x); igraph_vector_destroy(&membership); igraph_matrix_destroy(&merges); igraph_destroy(&g); return 0; }
int main() { igraph_t g; igraph_vector_ptr_t vecs; long int i; igraph_real_t weights[] = { 1, 2, 3, 4, 5, 1, 1, 1, 1, 1 }; igraph_real_t weights2[] = { 0,2,1, 0,5,2, 1,1,0, 2,2,8, 1,1,3, 1,1,4, 2,1 }; igraph_vector_t weights_vec; igraph_vs_t vs; /* Simple ring graph without weights */ igraph_ring(&g, 10, IGRAPH_UNDIRECTED, 0, 1); igraph_vector_ptr_init(&vecs, 5); for (i=0; i<igraph_vector_ptr_size(&vecs); i++) { VECTOR(vecs)[i] = calloc(1, sizeof(igraph_vector_t)); igraph_vector_init(VECTOR(vecs)[i], 0); } igraph_vs_vector_small(&vs, 1, 3, 5, 2, 1, -1); igraph_get_shortest_paths_dijkstra(&g, &vecs, 0, vs, 0, IGRAPH_OUT); for (i=0; i<igraph_vector_ptr_size(&vecs); i++) print_vector(VECTOR(vecs)[i]); /* Same ring, but with weights */ igraph_vector_view(&weights_vec, weights, sizeof(weights)/sizeof(igraph_real_t)); igraph_get_shortest_paths_dijkstra(&g, &vecs, 0, vs, &weights_vec, IGRAPH_OUT); for (i=0; i<igraph_vector_ptr_size(&vecs); i++) print_vector(VECTOR(vecs)[i]); igraph_destroy(&g); /* More complicated example */ igraph_small(&g, 10, IGRAPH_DIRECTED, 0,1, 0,2, 0,3, 1,2, 1,4, 1,5, 2,3, 2,6, 3,2, 3,6, 4,5, 4,7, 5,6, 5,8, 5,9, 7,5, 7,8, 8,9, 5,2, 2,1, -1); igraph_vector_view(&weights_vec, weights2, sizeof(weights2)/sizeof(igraph_real_t)); igraph_get_shortest_paths_dijkstra(&g, &vecs, 0, vs, &weights_vec, IGRAPH_OUT); for (i=0; i<igraph_vector_ptr_size(&vecs); i++) { print_vector(VECTOR(vecs)[i]); igraph_vector_destroy(VECTOR(vecs)[i]); free(VECTOR(vecs)[i]); } igraph_vector_ptr_destroy(&vecs); igraph_vs_destroy(&vs); igraph_destroy(&g); if (!IGRAPH_FINALLY_STACK_EMPTY) return 1; return 0; }
int main() { igraph_t g; igraph_vector_t weights; igraph_rng_seed(igraph_rng_default(), 42); /* Two triangles connected by one edge */ printf("# Two triangles connected by one edge\n"); igraph_small(&g, 0, IGRAPH_UNDIRECTED, 0, 1, 1, 2, 2, 0, 3, 4, 4, 5, 5, 3, 0, 5, -1); infomap_test(&g); igraph_destroy(&g); //return 0; /* Two 4-cliques with one commun vertex (vertex 3) */ printf("# Two 4-cliques (0123 and 4567) connected by two edges (0-4 and 1-5)\n"); igraph_small(&g, 0, IGRAPH_UNDIRECTED, 0, 1, 0, 2, 0, 3, 1, 2, 1, 3, 2, 3, // 4-clique 0,1,2,3 7, 4, 7, 5, 7, 6, 4, 5, 4, 6, 5, 6, // 4-clique 4,5,6,7 0, 4, 1, 5, //8, 0, 8, 4, -1); infomap_test(&g); printf("# Two 4-cliques (0123 and 4567) connected by two edges (0-4 and 1-5)\n"); igraph_add_edge(&g, 0, 4); igraph_add_edge(&g, 1, 5); infomap_test(&g); igraph_destroy(&g); /* Zachary Karate club -- this is just a quick smoke test */ printf("# Zachary Karate club\n"); igraph_small(&g, 0, IGRAPH_UNDIRECTED, 0, 1, 0, 2, 0, 3, 0, 4, 0, 5, //0, 5, 0, 5, 0, 5, 0, 6, 0, 7, 0, 8, 0, 10, 0, 11, 0, 12, 0, 13, 0, 17, 0, 19, 0, 21, 0, 31, 1, 2, 1, 3, 1, 7, 1, 13, 1, 17, 1, 19, 1, 21, 1, 30, 2, 3, 2, 7, 2, 8, 2, 9, 2, 13, 2, 27, 2, 28, 2, 32, 3, 7, 3, 12, 3, 13, 4, 6, 4, 10, 5, 6, 5, 10, 5, 16, 6, 16, 8, 30, 8, 32, 8, 33, 9, 33, 13, 33, 14, 32, 14, 33, 15, 32, 15, 33, 18, 32, 18, 33, 19, 33, 20, 32, 20, 33, 22, 32, 22, 33, 23, 25, 23, 27, 23, 29, 23, 32, 23, 33, 24, 25, 24, 27, 24, 31, 25, 31, 26, 29, 26, 33, 27, 33, 28, 31, 28, 33, 29, 32, 29, 33, 30, 32, 30, 33, 31, 32, 31, 33, 32, 33, -1); infomap_test(&g); igraph_destroy(&g); /* Flow.net that come in infomap_dir.tgz */ printf("# Flow (from infomap_dir.tgz)\n"); igraph_small(&g, 0, IGRAPH_DIRECTED, 0, 1, 1, 2, 2, 3, 3, 0, 1, 4, 4, 5, 5, 6, 6, 7, 7, 4, 5, 8, 8, 9, 9, 10, 10, 11, 11, 8, 9, 12, 12, 13, 13, 14, 14, 15, 15, 12, 13, 0, -1); infomap_test(&g); igraph_destroy(&g); /* MultiphysChemBioEco40W_weighted_dir.net */ printf("# MultiphysChemBioEco40W_weighted_dir.net (from infomap_dir.tgz)\n"); igraph_small(&g, 0, IGRAPH_DIRECTED, 1, 0, 2, 0, 3, 0, 4, 0, 5, 0, 6, 0, 7, 0, 8, 0, 9, 0, 16, 0, 18, 0, 0, 1, 2, 1, 3, 1, 5, 1, 6, 1, 7, 1, 9, 1, 10, 1, 16, 1, 18, 1, 0, 2, 3, 2, 4, 2, 5, 2, 6, 2, 7, 2, 0, 3, 1, 3, 2, 3, 4, 3, 5, 3, 6, 3, 7, 3, 8, 3, 9, 3, 10, 3, 11, 3, 13, 3, 14, 3, 16, 3, 17, 3, 18, 3, 19, 3, 26, 3, 30, 3, 1, 4, 3, 4, 5, 4, 6, 4, 13, 4, 18, 4, 0, 5, 1, 5, 2, 5, 3, 5, 6, 5, 7, 5, 9, 5, 1, 6, 3, 6, 7, 6, 9, 6, 16, 6, 0, 7, 1, 7, 2, 7, 3, 7, 5, 7, 6, 7, 9, 7, 3, 8, 5, 8, 3, 9, 7, 9, 12, 10, 13, 10, 14, 10, 15, 10, 16, 10, 17, 10, 18, 10, 19, 10, 21, 10, 3, 11, 18, 11, 10, 12, 14, 12, 16, 12, 17, 12, 18, 12, 3, 13, 10, 13, 14, 13, 16, 13, 10, 14, 12, 14, 13, 14, 15, 14, 16, 14, 17, 14, 18, 14, 10, 15, 14, 15, 18, 15, 0, 16, 2, 16, 3, 16, 6, 16, 10, 16, 12, 16, 13, 16, 14, 16, 17, 16, 18, 16, 10, 17, 12, 17, 14, 17, 18, 17, 3, 18, 10, 18, 12, 18, 14, 18, 15, 18, 16, 18, 17, 18, 19, 18, 21, 18, 11, 19, 16, 19, 17, 19, 16, 20, 18, 20, 21, 20, 22, 20, 23, 20, 24, 20, 25, 20, 26, 20, 27, 20, 28, 20, 29, 20, 3, 21, 14, 21, 18, 21, 20, 21, 22, 21, 23, 21, 24, 21, 25, 21, 26, 21, 27, 21, 28, 21, 29, 21, 35, 21, 36, 21, 38, 21, 18, 22, 20, 22, 21, 22, 23, 22, 24, 22, 25, 22, 26, 22, 27, 22, 29, 22, 3, 23, 20, 23, 21, 23, 22, 23, 24, 23, 25, 23, 26, 23, 27, 23, 28, 23, 29, 23, 35, 23, 38, 23, 39, 23, 20, 24, 21, 24, 23, 24, 25, 24, 26, 24, 27, 24, 28, 24, 29, 24, 9, 25, 20, 25, 21, 25, 22, 25, 23, 25, 24, 25, 26, 25, 27, 25, 28, 25, 29, 25, 18, 26, 20, 26, 21, 26, 22, 26, 23, 26, 25, 26, 27, 26, 28, 26, 29, 26, 30, 26, 32, 26, 35, 26, 36, 26, 38, 26, 39, 26, 3, 27, 14, 27, 20, 27, 21, 27, 22, 27, 23, 27, 24, 27, 25, 27, 26, 27, 28, 27, 29, 27, 38, 27, 3, 28, 18, 28, 20, 28, 21, 28, 23, 28, 24, 28, 25, 28, 26, 28, 27, 28, 29, 28, 35, 28, 14, 29, 16, 29, 18, 29, 20, 29, 21, 29, 22, 29, 23, 29, 24, 29, 25, 29, 26, 29, 27, 29, 28, 29, 31, 30, 32, 30, 33, 30, 34, 30, 35, 30, 36, 30, 38, 30, 39, 30, 30, 31, 32, 31, 34, 31, 36, 31, 30, 32, 34, 32, 35, 32, 36, 32, 30, 33, 32, 33, 34, 33, 35, 33, 36, 33, 38, 33, 30, 34, 31, 34, 32, 34, 33, 34, 35, 34, 36, 34, 38, 34, 39, 34, 26, 35, 30, 35, 32, 35, 33, 35, 34, 35, 36, 35, 38, 35, 39, 35, 30, 36, 34, 36, 35, 36, 38, 36, 39, 36, 34, 37, 26, 38, 30, 38, 32, 38, 33, 38, 34, 38, 35, 38, 36, 38, 39, 38, 26, 39, 30, 39, 33, 39, 34, 39, 35, 39, 36, 39, 38, 39, -1); igraph_vector_init_real(&weights, 306, 5.0, 3.0, 130.0, 4.0, 15.0, 9.0, 7.0, 1.0, 1.0, 3.0, 1.0, 1.0, 1.0, 34.0, 38.0, 2.0, 23.0, 1.0, 1.0, 3.0, 2.0, 2.0, 16.0, 1.0, 3.0, 1.0, 3.0, 63.0, 92.0, 72.0, 25.0, 447.0, 121.0, 65.0, 4.0, 16.0, 35.0, 1.0, 19.0, 1.0, 78.0, 1.0, 45.0, 1.0, 3.0, 1.0, 1.0, 25.0, 1.0, 3.0, 1.0, 1.0, 3.0, 36.0, 19.0, 136.0, 41.0, 96.0, 1.0, 7.0, 26.0, 1.0, 2.0, 2.0, 3.0, 2.0, 2.0, 23.0, 52.0, 4.0, 1.0, 2.0, 1.0, 3.0, 1.0, 11.0, 2.0, 17.0, 1.0, 5.0, 18.0, 86.0, 5.0, 1.0, 1.0, 1.0, 6.0, 1.0, 2.0, 2.0, 20.0, 4.0, 5.0, 1.0, 5.0, 12.0, 4.0, 1.0, 1.0, 4.0, 9.0, 40.0, 2.0, 1.0, 4.0, 1.0, 1.0, 48.0, 2.0, 18.0, 1.0, 7.0, 2.0, 2.0, 53.0, 25.0, 9.0, 1.0, 23.0, 8.0, 62.0, 29.0, 35.0, 4.0, 34.0, 35.0, 3.0, 1.0, 24.0, 1.0, 6.0, 2.0, 2.0, 22.0, 7.0, 2.0, 5.0, 14.0, 3.0, 28.0, 14.0, 20.0, 3.0, 1.0, 5.0, 77.0, 20.0, 25.0, 35.0, 55.0, 35.0, 115.0, 68.0, 105.0, 2.0, 2.0, 2.0, 4.0, 2.0, 17.0, 12.0, 3.0, 3.0, 11.0, 10.0, 7.0, 2.0, 12.0, 31.0, 11.0, 5.0, 11.0, 65.0, 39.0, 17.0, 26.0, 3.0, 4.0, 2.0, 3.0, 6.0, 4.0, 8.0, 1.0, 7.0, 7.0, 6.0, 1.0, 39.0, 42.0, 9.0, 6.0, 9.0, 5.0, 45.0, 43.0, 26.0, 1.0, 2.0, 6.0, 2.0, 15.0, 3.0, 9.0, 2.0, 1.0, 1.0, 1.0, 4.0, 2.0, 9.0, 2.0, 1.0, 2.0, 28.0, 80.0, 10.0, 18.0, 13.0, 17.0, 28.0, 40.0, 76.0, 1.0, 2.0, 1.0, 11.0, 37.0, 5.0, 11.0, 14.0, 4.0, 14.0, 10.0, 1.0, 1.0, 1.0, 1.0, 41.0, 121.0, 6.0, 21.0, 12.0, 30.0, 6.0, 141.0, 43.0, 2.0, 12.0, 6.0, 35.0, 10.0, 7.0, 2.0, 12.0, 6.0, 2.0, 11.0, 1.0, 7.0, 6.0, 5.0, 3.0, 1.0, 2.0, 1.0, 1.0, 1.0, 1.0, 67.0, 9.0, 9.0, 11.0, 10.0, 21.0, 7.0, 12.0, 9.0, 16.0, 7.0, 4.0, 11.0, 17.0, 37.0, 32.0, 9.0, 2.0, 2.0, 5.0, 4.0, 2.0, 7.0, 3.0, 3.0, 5.0, 8.0, 14.0, 3.0, 38.0, 3.0, 9.0, 2.0, 8.0, 21.0, 18.0, 58.0); infomap_weighted_test(&g, &weights); igraph_vector_destroy(&weights); igraph_destroy(&g); /* Two triangles connected by one edge */ printf("# Wiktionary english verbs (synonymy 2008)\n"); FILE *wikt = fopen("wikti_en_V_syn.elist", "r"); igraph_read_graph_edgelist(&g, wikt, 0, 0); fclose(wikt); gsumary(&g); infomap_test(&g); igraph_destroy(&g); #ifdef __APPLE__ return 0; #else return 77; #endif }