4
Copyright (C) 2007 Gabor Csardi <csardi@rmki.kfki.hu>
5
MTA RMKI, Konkoly-Thege Miklos st. 29-33, Budapest 1121, Hungary
7
This program is free software; you can redistribute it and/or modify
8
it under the terms of the GNU General Public License as published by
9
the Free Software Foundation; either version 2 of the License, or
10
(at your option) any later version.
12
This program is distributed in the hope that it will be useful,
13
but WITHOUT ANY WARRANTY; without even the implied warranty of
14
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
GNU General Public License for more details.
17
You should have received a copy of the GNU General Public License
18
along with this program; if not, write to the Free Software
19
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
38
/* ------------------------------------------------------------------------ */
39
/* Conversion & other common functions first */
40
/* ------------------------------------------------------------------------ */
43
int shell_igraph_usage(int argc, char **argv) {
44
printf("Command line interface to igraph\n");
48
int shell_skip_whitespace(FILE *fin) {
54
if (c!=EOF) { ungetc(c, fin); }
58
FILE *shell_open_file(const char *where, const char *mode) {
59
static const char *input="input";
60
static const char *output="output";
63
if (!strcmp(where, "-")) {
64
if (!strcmp(mode, "r")) {
66
} else if (!strcmp(mode, "w")) {
73
fprintf(stderr, "Cannot open %s file: `%s'\n",
74
!strcmp(mode, "r") ? input : output, where);
80
int shell_read_graph(igraph_t *graph, const char *where) {
81
FILE *fin=shell_open_file(where, "r");
82
igraph_read_graph_graphml(graph, fin, 0);
87
int shell_write_graph(const igraph_t *graph, const char *where) {
88
FILE *fout=shell_open_file(where, "w");
89
igraph_write_graph_graphml(graph, fout);
94
int shell_read_vector(igraph_vector_t *v, const char *where) {
95
FILE *fin=shell_open_file(where, "r");
98
igraph_vector_init(v, 0);
100
ret=fscanf(fin, "%lf", &n);
102
igraph_vector_push_back(v, n);
107
fprintf(stderr, "Error reading vector from file: `%s'\n", where);
114
int shell_write_a_vector(const igraph_vector_t *v, FILE *fout, const char *where) {
116
long int i, n=igraph_vector_size(v);
117
if (n>0) { ret=fprintf(fout, "%g", VECTOR(*v)[0]); }
119
fprintf(stderr, "Cannot write vector to `%s'\n", where);
123
for (i=1; i<n; i++) {
124
ret=fprintf(fout, " %g", VECTOR(*v)[i]);
126
fprintf(stderr, "Cannot write vector to `%s'\n", where);
135
int shell_write_vector(const igraph_vector_t *v, const char *where) {
136
FILE *fout=shell_open_file(where, "w");
137
shell_write_a_vector(v, fout, where);
142
int shell_read_a_matrix(igraph_matrix_t *m, FILE *fin, const char *where) {
143
long int ncol, nrow, i, j;
146
if (2 != fscanf(fin, "%li %li", &nrow, &ncol)) {
147
fprintf(stderr, "Error reading matrix from file '%s'\n", where);
151
igraph_matrix_init(m,nrow,ncol);
152
for (i=0; i<nrow; i++) {
153
for (j=0; j<ncol; j++) {
154
ret=fscanf(fin, "%lf", &n);
156
fprintf(stderr, "Error reading matrix from file '%s'\n", where);
166
int shell_read_matrix(igraph_matrix_t *m, const char *where) {
167
FILE *fin=shell_open_file(where, "r");
168
shell_read_a_matrix(m, fin, where);
173
int shell_write_matrix(const igraph_matrix_t *m, const char *where) {
174
FILE *fout=shell_open_file(where, "w");
175
long int nrow=igraph_matrix_nrow(m);
176
long int ncol=igraph_matrix_ncol(m);
179
if (0>fprintf(fout, "%li %li\n", nrow, ncol)) {
180
fprintf(stderr, "Error writing matrix to file '%s'.\n", where);
185
for (i=0; i<nrow; i++) {
186
for (j=0; j<ncol; j++) {
187
if (j!=0) { fprintf(fout, " "); }
188
if (0>fprintf(fout, "%g", MATRIX(*m, i, j))) {
189
fprintf(stderr, "Error writing matrix to file '%s'.\n", where);
201
int shell_read_integer(igraph_integer_t *n, const char *where) {
203
int ret=sscanf(where, "%li", &nn);
204
if (ret == EOF || ret == 0) {
205
fprintf(stderr, "Error, cannot interpret '%s' as integer\n", where);
212
int shell_write_integer(igraph_integer_t n, const char *where) {
213
FILE *fout=shell_open_file(where, "w");
214
int ret=fprintf(fout, "%li\n", (long int)n);
216
fprintf(stderr, "Cannot write integer to '%s'\n", where);
223
int shell_read_boolean(igraph_bool_t *b, const char *where) {
224
if (strlen(where)==0 ||
235
int shell_write_boolean(igraph_bool_t b, const char *where) {
236
int bb= b==0 ? 0 : 1;
237
FILE *fout=shell_open_file(where, "w");
238
int ret=fprintf(fout, "%i\n", bb);
240
fprintf(stderr, "Cannot write integer to '%s'\n", where);
247
int shell_read_real(igraph_real_t *b, const char *where) {
248
int ret=sscanf(where, "%lf", b);
249
if (ret == EOF || ret == 0) {
250
fprintf(stderr, "Error, cannot interpret '%s' as real\n", where);
256
int shell_write_real(igraph_real_t b, const char *where) {
257
FILE *fout=shell_open_file(where, "w");
258
int ret=fprintf(fout, "%g\n", (double)b);
260
fprintf(stderr, "Cannot write real to `%s'\n", where);
267
int shell_read_enum(void* value, const char *where, ...) {
268
int result=-1, *p=value;
270
va_start(args, where);
273
char *name=va_arg(args, char*);
276
code=va_arg(args, int);
277
if (!strcmp(optarg, name)) {
287
fprintf(stderr, "Cannot interpret argument: '%s'.\n", where);
296
int shell_read_int(int *value, const char *where) {
297
long int li=strtol(where, 0, 10);
298
if (errno || li<INT_MIN || li>INT_MAX) {
299
fprintf(stderr, "Integer too small/big: '%s'.\n", where);
305
int shell_read_longint(long int *value, const char *where) {
306
long int li=strtol(where, 0, 10);
308
fprintf(stderr, "Long integer too small/big: '%s'.\n", where);
314
int shell_read_file(FILE **file, const char *where, const char *mode) {
315
*file=fopen(where, mode);
317
fprintf(stderr, "Cannot open file '%s'\n", where);
322
int shell_read_matrixlist(igraph_vector_ptr_t *list, const char *where) {
323
FILE *fin=shell_open_file(where, "r");
324
igraph_vector_ptr_init(list, 0);
325
shell_skip_whitespace(fin);
327
igraph_matrix_t *m=malloc(sizeof(igraph_matrix_t));
328
shell_read_a_matrix(m, fin, where);
329
igraph_vector_ptr_push_back(list, m);
330
shell_skip_whitespace(fin);
336
int shell_read_graphlist(igraph_vector_ptr_t *list, const char *where) {
337
FILE *fin=shell_open_file(where, "r");
338
igraph_vector_ptr_init(list, 0);
339
shell_skip_whitespace(fin);
341
igraph_t *g=malloc(sizeof(igraph_t));
342
igraph_read_graph_graphml(g, fin, 0);
343
igraph_vector_ptr_push_back(list, g);
344
shell_skip_whitespace(fin);
350
int shell_read_strvector(igraph_strvector_t *str, const char *where) {
351
FILE *fin=shell_open_file(where, "r");
352
char *buffer=calloc(1000, sizeof(char));
355
igraph_strvector_init(str, 0);
357
getline(&buffer, &size, fin);
358
igraph_strvector_add(str, buffer);
372
int shell_write_vectorlist(igraph_vector_ptr_t *v, const char *where) {
373
FILE *fout=shell_open_file(where, "w");
374
long int i, n=igraph_vector_ptr_size(v);
375
for (i=0; i<n; i++) {
376
shell_write_a_vector(VECTOR(*v)[i], fout, where);
382
int shell_write_vector_bool(igraph_vector_bool_t *v, const char *where) {
383
FILE *fout=shell_open_file(where, "w");
385
long int i, n=igraph_vector_bool_size(v);
386
if (n>0) { ret=fprintf(fout, "%i", VECTOR(*v)[0]==0 ? 0 : 1); }
388
fprintf(stderr, "Cannot write vector to `%s'\n", where);
392
for (i=1; i<n; i++) {
393
ret=fprintf(fout, " %i", VECTOR(*v)[i]==0 ? 0 : 1);
395
fprintf(stderr, "Cannot write vector to `%s'\n", where);
405
int shell_write_graphlist(igraph_vector_ptr_t *v, const char *where) {
406
FILE *fout=shell_open_file(where, "w");
407
long int i, n=igraph_vector_ptr_size(v);
408
for (i=0; i<n; i++) {
409
igraph_write_graph_graphml(VECTOR(*v)[i], fout);
415
int shell_free_graphlist(igraph_vector_ptr_t *v) {
416
long int i, n=igraph_vector_ptr_size(v);
417
for (i=0; i<n; i++) {
418
igraph_destroy(VECTOR(*v)[i]);
425
int shell_free_matrixlist(igraph_vector_ptr_t *v) {
426
long int i, n=igraph_vector_ptr_size(v);
427
for (i=0; i<n; i++) {
428
igraph_matrix_destroy(VECTOR(*v)[i]);
435
int shell_free_vectorlist(igraph_vector_ptr_t *v) {
436
long int i, n=igraph_vector_ptr_size(v);
437
for (i=0; i<n; i++) {
438
igraph_vector_destroy(VECTOR(*v)[i]);
445
/* ------------------------------------------------------------------------ */
446
/* Stimulus generated interface next */
447
/* ------------------------------------------------------------------------ */
450
/* Function prototypes first */
452
int shell_igraph_empty(int argc, char **argv);
453
int shell_igraph_add_edges(int argc, char **argv);
454
int shell_igraph_add_vertices(int argc, char **argv);
455
int shell_igraph_delete_edges(int argc, char **argv);
456
int shell_igraph_delete_vertices(int argc, char **argv);
457
int shell_igraph_vcount(int argc, char **argv);
458
int shell_igraph_ecount(int argc, char **argv);
459
int shell_igraph_neighbors(int argc, char **argv);
460
int shell_igraph_is_directed(int argc, char **argv);
461
int shell_igraph_degree(int argc, char **argv);
462
int shell_igraph_edge(int argc, char **argv);
463
int shell_igraph_edges(int argc, char **argv);
464
int shell_igraph_get_eid(int argc, char **argv);
465
int shell_igraph_get_eids(int argc, char **argv);
466
int shell_igraph_adjacent(int argc, char **argv);
467
int shell_igraph_create(int argc, char **argv);
468
int shell_igraph_adjacency(int argc, char **argv);
469
int shell_igraph_star(int argc, char **argv);
470
int shell_igraph_lattice(int argc, char **argv);
471
int shell_igraph_ring(int argc, char **argv);
472
int shell_igraph_tree(int argc, char **argv);
473
int shell_igraph_full(int argc, char **argv);
474
int shell_igraph_full_citation(int argc, char **argv);
475
int shell_igraph_atlas(int argc, char **argv);
476
int shell_igraph_extended_chordal_ring(int argc, char **argv);
477
int shell_igraph_connect_neighborhood(int argc, char **argv);
478
int shell_igraph_linegraph(int argc, char **argv);
479
int shell_igraph_de_bruijn(int argc, char **argv);
480
int shell_igraph_kautz(int argc, char **argv);
481
int shell_igraph_famous(int argc, char **argv);
482
int shell_igraph_lcf_vector(int argc, char **argv);
483
int shell_igraph_adjlist(int argc, char **argv);
484
int shell_igraph_full_bipartite(int argc, char **argv);
485
int shell_igraph_barabasi_game(int argc, char **argv);
486
int shell_igraph_nonlinear_barabasi_game(int argc, char **argv);
487
int shell_igraph_erdos_renyi_game_gnp(int argc, char **argv);
488
int shell_igraph_erdos_renyi_game_gnm(int argc, char **argv);
489
int shell_igraph_degree_sequence_game(int argc, char **argv);
490
int shell_igraph_growing_random_game(int argc, char **argv);
491
int shell_igraph_barabasi_aging_game(int argc, char **argv);
492
int shell_igraph_recent_degree_game(int argc, char **argv);
493
int shell_igraph_recent_degree_aging_game(int argc, char **argv);
494
int shell_igraph_callaway_traits_game(int argc, char **argv);
495
int shell_igraph_establishment_game(int argc, char **argv);
496
int shell_igraph_grg_game(int argc, char **argv);
497
int shell_igraph_preference_game(int argc, char **argv);
498
int shell_igraph_asymmetric_preference_game(int argc, char **argv);
499
int shell_igraph_rewire_edges(int argc, char **argv);
500
int shell_igraph_watts_strogatz_game(int argc, char **argv);
501
int shell_igraph_lastcit_game(int argc, char **argv);
502
int shell_igraph_cited_type_game(int argc, char **argv);
503
int shell_igraph_citing_cited_type_game(int argc, char **argv);
504
int shell_igraph_forest_fire_game(int argc, char **argv);
505
int shell_igraph_are_connected(int argc, char **argv);
506
int shell_igraph_diameter(int argc, char **argv);
507
int shell_igraph_diameter_dijkstra(int argc, char **argv);
508
int shell_igraph_minimum_spanning_tree_unweighted(int argc, char **argv);
509
int shell_igraph_minimum_spanning_tree_prim(int argc, char **argv);
510
int shell_igraph_closeness(int argc, char **argv);
511
int shell_igraph_closeness_estimate(int argc, char **argv);
512
int shell_igraph_shortest_paths(int argc, char **argv);
513
int shell_igraph_get_shortest_paths(int argc, char **argv);
514
int shell_igraph_get_all_shortest_paths(int argc, char **argv);
515
int shell_igraph_shortest_paths_dijkstra(int argc, char **argv);
516
int shell_igraph_shortest_paths_bellman_ford(int argc, char **argv);
517
int shell_igraph_subcomponent(int argc, char **argv);
518
int shell_igraph_betweenness(int argc, char **argv);
519
int shell_igraph_betweenness_estimate(int argc, char **argv);
520
int shell_igraph_edge_betweenness(int argc, char **argv);
521
int shell_igraph_edge_betweenness_estimate(int argc, char **argv);
522
int shell_igraph_pagerank_old(int argc, char **argv);
523
int shell_igraph_pagerank(int argc, char **argv);
524
int shell_igraph_rewire(int argc, char **argv);
525
int shell_igraph_subgraph(int argc, char **argv);
526
int shell_igraph_average_path_length(int argc, char **argv);
527
int shell_igraph_path_length_hist(int argc, char **argv);
528
int shell_igraph_simplify(int argc, char **argv);
529
int shell_igraph_transitivity_undirected(int argc, char **argv);
530
int shell_igraph_transitivity_local_undirected(int argc, char **argv);
531
int shell_igraph_transitivity_avglocal_undirected(int argc, char **argv);
532
int shell_igraph_reciprocity(int argc, char **argv);
533
int shell_igraph_constraint(int argc, char **argv);
534
int shell_igraph_maxdegree(int argc, char **argv);
535
int shell_igraph_density(int argc, char **argv);
536
int shell_igraph_neighborhood_size(int argc, char **argv);
537
int shell_igraph_neighborhood(int argc, char **argv);
538
int shell_igraph_neighborhood_graphs(int argc, char **argv);
539
int shell_igraph_topological_sorting(int argc, char **argv);
540
int shell_igraph_is_loop(int argc, char **argv);
541
int shell_igraph_is_simple(int argc, char **argv);
542
int shell_igraph_is_multiple(int argc, char **argv);
543
int shell_igraph_count_multiple(int argc, char **argv);
544
int shell_igraph_girth(int argc, char **argv);
545
int shell_igraph_add_edge(int argc, char **argv);
546
int shell_igraph_eigenvector_centrality(int argc, char **argv);
547
int shell_igraph_hub_score(int argc, char **argv);
548
int shell_igraph_authority_score(int argc, char **argv);
549
int shell_igraph_arpack_rssolve(int argc, char **argv);
550
int shell_igraph_arpack_rnsolve(int argc, char **argv);
551
int shell_igraph_arpack_unpack_complex(int argc, char **argv);
552
int shell_igraph_unfold_tree(int argc, char **argv);
553
int shell_igraph_laplacian(int argc, char **argv);
554
int shell_igraph_is_mutual(int argc, char **argv);
555
int shell_igraph_avg_nearest_neighbor_degree(int argc, char **argv);
556
int shell_igraph_strength(int argc, char **argv);
557
int shell_igraph_bipartite_projection_size(int argc, char **argv);
558
int shell_igraph_bipartite_projection(int argc, char **argv);
559
int shell_igraph_create_bipartite(int argc, char **argv);
560
int shell_igraph_incidence(int argc, char **argv);
561
int shell_igraph_get_incidence(int argc, char **argv);
562
int shell_igraph_is_bipartite(int argc, char **argv);
563
int shell_igraph_clusters(int argc, char **argv);
564
int shell_igraph_is_connected(int argc, char **argv);
565
int shell_igraph_decompose(int argc, char **argv);
566
int shell_igraph_articulation_points(int argc, char **argv);
567
int shell_igraph_biconnected_components(int argc, char **argv);
568
int shell_igraph_cliques(int argc, char **argv);
569
int shell_igraph_largest_cliques(int argc, char **argv);
570
int shell_igraph_maximal_cliques(int argc, char **argv);
571
int shell_igraph_clique_number(int argc, char **argv);
572
int shell_igraph_independent_vertex_sets(int argc, char **argv);
573
int shell_igraph_largest_independent_vertex_sets(int argc, char **argv);
574
int shell_igraph_maximal_independent_vertex_sets(int argc, char **argv);
575
int shell_igraph_independence_number(int argc, char **argv);
576
int shell_igraph_layout_random(int argc, char **argv);
577
int shell_igraph_layout_circle(int argc, char **argv);
578
int shell_igraph_layout_fruchterman_reingold(int argc, char **argv);
579
int shell_igraph_layout_grid_fruchterman_reingold(int argc, char **argv);
580
int shell_igraph_layout_kamada_kawai(int argc, char **argv);
581
int shell_igraph_layout_lgl(int argc, char **argv);
582
int shell_igraph_layout_reingold_tilford(int argc, char **argv);
583
int shell_igraph_layout_reingold_tilford_circular(int argc, char **argv);
584
int shell_igraph_layout_random_3d(int argc, char **argv);
585
int shell_igraph_layout_sphere(int argc, char **argv);
586
int shell_igraph_layout_fruchterman_reingold_3d(int argc, char **argv);
587
int shell_igraph_layout_kamada_kawai_3d(int argc, char **argv);
588
int shell_igraph_layout_graphopt(int argc, char **argv);
589
int shell_igraph_layout_drl(int argc, char **argv);
590
int shell_igraph_layout_drl_3d(int argc, char **argv);
591
int shell_igraph_layout_merge_dla(int argc, char **argv);
592
int shell_igraph_cocitation(int argc, char **argv);
593
int shell_igraph_bibcoupling(int argc, char **argv);
594
int shell_igraph_similarity_jaccard(int argc, char **argv);
595
int shell_igraph_similarity_dice(int argc, char **argv);
596
int shell_igraph_similarity_inverse_log_weighted(int argc, char **argv);
597
int shell_igraph_community_spinglass(int argc, char **argv);
598
int shell_igraph_community_spinglass_single(int argc, char **argv);
599
int shell_igraph_community_walktrap(int argc, char **argv);
600
int shell_igraph_community_edge_betweenness(int argc, char **argv);
601
int shell_igraph_community_eb_get_merges(int argc, char **argv);
602
int shell_igraph_community_fastgreedy(int argc, char **argv);
603
int shell_igraph_community_to_membership(int argc, char **argv);
604
int shell_igraph_le_community_to_membership(int argc, char **argv);
605
int shell_igraph_modularity(int argc, char **argv);
606
int shell_igraph_community_leading_eigenvector(int argc, char **argv);
607
int shell_igraph_community_leading_eigenvector_naive(int argc, char **argv);
608
int shell_igraph_community_leading_eigenvector_step(int argc, char **argv);
609
int shell_igraph_community_label_propagation(int argc, char **argv);
610
int shell_igraph_get_adjacency(int argc, char **argv);
611
int shell_igraph_get_edgelist(int argc, char **argv);
612
int shell_igraph_to_directed(int argc, char **argv);
613
int shell_igraph_to_undirected(int argc, char **argv);
614
int shell_igraph_read_graph_edgelist(int argc, char **argv);
615
int shell_igraph_read_graph_ncol(int argc, char **argv);
616
int shell_igraph_read_graph_lgl(int argc, char **argv);
617
int shell_igraph_read_graph_pajek(int argc, char **argv);
618
int shell_igraph_read_graph_graphml(int argc, char **argv);
619
int shell_igraph_read_graph_dimacs(int argc, char **argv);
620
int shell_igraph_read_graph_graphdb(int argc, char **argv);
621
int shell_igraph_read_graph_gml(int argc, char **argv);
622
int shell_igraph_write_graph_edgelist(int argc, char **argv);
623
int shell_igraph_write_graph_ncol(int argc, char **argv);
624
int shell_igraph_write_graph_lgl(int argc, char **argv);
625
int shell_igraph_write_graph_graphml(int argc, char **argv);
626
int shell_igraph_write_graph_pajek(int argc, char **argv);
627
int shell_igraph_write_graph_dimacs(int argc, char **argv);
628
int shell_igraph_write_graph_gml(int argc, char **argv);
629
int shell_igraph_write_graph_dot(int argc, char **argv);
630
int shell_igraph_motifs_randesu(int argc, char **argv);
631
int shell_igraph_motifs_randesu_estimate(int argc, char **argv);
632
int shell_igraph_motifs_randesu_no(int argc, char **argv);
633
int shell_igraph_dyad_census(int argc, char **argv);
634
int shell_igraph_triad_census(int argc, char **argv);
635
int shell_igraph_disjoint_union(int argc, char **argv);
636
int shell_igraph_disjoint_union_many(int argc, char **argv);
637
int shell_igraph_union(int argc, char **argv);
638
int shell_igraph_union_many(int argc, char **argv);
639
int shell_igraph_intersection(int argc, char **argv);
640
int shell_igraph_intersection_many(int argc, char **argv);
641
int shell_igraph_difference(int argc, char **argv);
642
int shell_igraph_complementer(int argc, char **argv);
643
int shell_igraph_compose(int argc, char **argv);
644
int shell_igraph_maxflow_value(int argc, char **argv);
645
int shell_igraph_mincut_value(int argc, char **argv);
646
int shell_igraph_st_mincut_value(int argc, char **argv);
647
int shell_igraph_mincut(int argc, char **argv);
648
int shell_igraph_st_vertex_connectivity(int argc, char **argv);
649
int shell_igraph_vertex_connectivity(int argc, char **argv);
650
int shell_igraph_st_edge_connectivity(int argc, char **argv);
651
int shell_igraph_edge_connectivity(int argc, char **argv);
652
int shell_igraph_edge_disjoint_paths(int argc, char **argv);
653
int shell_igraph_vertex_disjoint_paths(int argc, char **argv);
654
int shell_igraph_adhesion(int argc, char **argv);
655
int shell_igraph_cohesion(int argc, char **argv);
656
int shell_igraph_coreness(int argc, char **argv);
657
int shell_igraph_isoclass(int argc, char **argv);
658
int shell_igraph_isomorphic(int argc, char **argv);
659
int shell_igraph_isoclass_subgraph(int argc, char **argv);
660
int shell_igraph_isoclass_create(int argc, char **argv);
661
int shell_igraph_isomorphic_vf2(int argc, char **argv);
662
int shell_igraph_count_isomorphisms_vf2(int argc, char **argv);
663
int shell_igraph_get_isomorphisms_vf2(int argc, char **argv);
664
int shell_igraph_subisomorphic_vf2(int argc, char **argv);
665
int shell_igraph_count_subisomorphisms_vf2(int argc, char **argv);
666
int shell_igraph_get_subisomorphisms_vf2(int argc, char **argv);
667
int shell_igraph_isomorphic_34(int argc, char **argv);
668
int shell_igraph_canonical_permutation(int argc, char **argv);
669
int shell_igraph_permute_vertices(int argc, char **argv);
670
int shell_igraph_isomorphic_bliss(int argc, char **argv);
671
int shell_igraph_automorphisms(int argc, char **argv);
672
int shell_igraph_running_mean(int argc, char **argv);
673
int shell_igraph_random_sample(int argc, char **argv);
674
int shell_igraph_convex_hull(int argc, char **argv);
675
int shell_igraph_revolver_ml_d(int argc, char **argv);
676
int shell_igraph_revolver_probs_d(int argc, char **argv);
677
int shell_igraph_revolver_ml_de(int argc, char **argv);
678
int shell_igraph_revolver_probs_de(int argc, char **argv);
679
int shell_igraph_revolver_ml_ade(int argc, char **argv);
680
int shell_igraph_revolver_probs_ade(int argc, char **argv);
681
int shell_igraph_revolver_ml_f(int argc, char **argv);
682
int shell_igraph_revolver_ml_df(int argc, char **argv);
683
int shell_igraph_revolver_ml_l(int argc, char **argv);
684
int shell_igraph_revolver_ml_ad(int argc, char **argv);
685
int shell_igraph_revolver_probs_ad(int argc, char **argv);
686
int shell_igraph_revolver_ml_D_alpha(int argc, char **argv);
687
int shell_igraph_revolver_ml_D_alpha_a(int argc, char **argv);
688
int shell_igraph_revolver_ml_DE_alpha_a(int argc, char **argv);
689
int shell_igraph_revolver_ml_AD_alpha_a_beta(int argc, char **argv);
690
int shell_igraph_revolver_ml_AD_dpareto(int argc, char **argv);
691
int shell_igraph_revolver_ml_AD_dpareto_eval(int argc, char **argv);
692
int shell_igraph_revolver_ml_ADE_alpha_a_beta(int argc, char **argv);
693
int shell_igraph_revolver_ml_ADE_dpareto(int argc, char **argv);
694
int shell_igraph_revolver_ml_ADE_dpareto_eval(int argc, char **argv);
695
int shell_igraph_revolver_ml_ADE_dpareto_evalf(int argc, char **argv);
696
int shell_igraph_revolver_probs_ADE_dpareto(int argc, char **argv);
697
int shell_igraph_convergence_degree(int argc, char **argv);
699
/* The main function */
701
int main(int argc, char **argv) {
703
const char *base=basename(argv[0]);
705
if (!strcasecmp(base, "igraph_empty")) {
706
return shell_igraph_empty(argc, argv);
707
} else if (!strcasecmp(base, "igraph_add_edges")) {
708
return shell_igraph_add_edges(argc, argv);
709
} else if (!strcasecmp(base, "igraph_add_vertices")) {
710
return shell_igraph_add_vertices(argc, argv);
711
} else if (!strcasecmp(base, "igraph_delete_edges")) {
712
return shell_igraph_delete_edges(argc, argv);
713
} else if (!strcasecmp(base, "igraph_delete_vertices")) {
714
return shell_igraph_delete_vertices(argc, argv);
715
} else if (!strcasecmp(base, "igraph_vcount")) {
716
return shell_igraph_vcount(argc, argv);
717
} else if (!strcasecmp(base, "igraph_ecount")) {
718
return shell_igraph_ecount(argc, argv);
719
} else if (!strcasecmp(base, "igraph_neighbors")) {
720
return shell_igraph_neighbors(argc, argv);
721
} else if (!strcasecmp(base, "igraph_is_directed")) {
722
return shell_igraph_is_directed(argc, argv);
723
} else if (!strcasecmp(base, "igraph_degree")) {
724
return shell_igraph_degree(argc, argv);
725
} else if (!strcasecmp(base, "igraph_edge")) {
726
return shell_igraph_edge(argc, argv);
727
} else if (!strcasecmp(base, "igraph_edges")) {
728
return shell_igraph_edges(argc, argv);
729
} else if (!strcasecmp(base, "igraph_get_eid")) {
730
return shell_igraph_get_eid(argc, argv);
731
} else if (!strcasecmp(base, "igraph_get_eids")) {
732
return shell_igraph_get_eids(argc, argv);
733
} else if (!strcasecmp(base, "igraph_adjacent")) {
734
return shell_igraph_adjacent(argc, argv);
735
} else if (!strcasecmp(base, "igraph_create")) {
736
return shell_igraph_create(argc, argv);
737
} else if (!strcasecmp(base, "igraph_adjacency")) {
738
return shell_igraph_adjacency(argc, argv);
739
} else if (!strcasecmp(base, "igraph_star")) {
740
return shell_igraph_star(argc, argv);
741
} else if (!strcasecmp(base, "igraph_lattice")) {
742
return shell_igraph_lattice(argc, argv);
743
} else if (!strcasecmp(base, "igraph_ring")) {
744
return shell_igraph_ring(argc, argv);
745
} else if (!strcasecmp(base, "igraph_tree")) {
746
return shell_igraph_tree(argc, argv);
747
} else if (!strcasecmp(base, "igraph_full")) {
748
return shell_igraph_full(argc, argv);
749
} else if (!strcasecmp(base, "igraph_full_citation")) {
750
return shell_igraph_full_citation(argc, argv);
751
} else if (!strcasecmp(base, "igraph_atlas")) {
752
return shell_igraph_atlas(argc, argv);
753
} else if (!strcasecmp(base, "igraph_extended_chordal_ring")) {
754
return shell_igraph_extended_chordal_ring(argc, argv);
755
} else if (!strcasecmp(base, "igraph_connect_neighborhood")) {
756
return shell_igraph_connect_neighborhood(argc, argv);
757
} else if (!strcasecmp(base, "igraph_linegraph")) {
758
return shell_igraph_linegraph(argc, argv);
759
} else if (!strcasecmp(base, "igraph_de_bruijn")) {
760
return shell_igraph_de_bruijn(argc, argv);
761
} else if (!strcasecmp(base, "igraph_kautz")) {
762
return shell_igraph_kautz(argc, argv);
763
} else if (!strcasecmp(base, "igraph_famous")) {
764
return shell_igraph_famous(argc, argv);
765
} else if (!strcasecmp(base, "igraph_lcf_vector")) {
766
return shell_igraph_lcf_vector(argc, argv);
767
} else if (!strcasecmp(base, "igraph_adjlist")) {
768
return shell_igraph_adjlist(argc, argv);
769
} else if (!strcasecmp(base, "igraph_full_bipartite")) {
770
return shell_igraph_full_bipartite(argc, argv);
771
} else if (!strcasecmp(base, "igraph_barabasi_game")) {
772
return shell_igraph_barabasi_game(argc, argv);
773
} else if (!strcasecmp(base, "igraph_nonlinear_barabasi_game")) {
774
return shell_igraph_nonlinear_barabasi_game(argc, argv);
775
} else if (!strcasecmp(base, "igraph_erdos_renyi_game_gnp")) {
776
return shell_igraph_erdos_renyi_game_gnp(argc, argv);
777
} else if (!strcasecmp(base, "igraph_erdos_renyi_game_gnm")) {
778
return shell_igraph_erdos_renyi_game_gnm(argc, argv);
779
} else if (!strcasecmp(base, "igraph_degree_sequence_game")) {
780
return shell_igraph_degree_sequence_game(argc, argv);
781
} else if (!strcasecmp(base, "igraph_growing_random_game")) {
782
return shell_igraph_growing_random_game(argc, argv);
783
} else if (!strcasecmp(base, "igraph_barabasi_aging_game")) {
784
return shell_igraph_barabasi_aging_game(argc, argv);
785
} else if (!strcasecmp(base, "igraph_recent_degree_game")) {
786
return shell_igraph_recent_degree_game(argc, argv);
787
} else if (!strcasecmp(base, "igraph_recent_degree_aging_game")) {
788
return shell_igraph_recent_degree_aging_game(argc, argv);
789
} else if (!strcasecmp(base, "igraph_callaway_traits_game")) {
790
return shell_igraph_callaway_traits_game(argc, argv);
791
} else if (!strcasecmp(base, "igraph_establishment_game")) {
792
return shell_igraph_establishment_game(argc, argv);
793
} else if (!strcasecmp(base, "igraph_grg_game")) {
794
return shell_igraph_grg_game(argc, argv);
795
} else if (!strcasecmp(base, "igraph_preference_game")) {
796
return shell_igraph_preference_game(argc, argv);
797
} else if (!strcasecmp(base, "igraph_asymmetric_preference_game")) {
798
return shell_igraph_asymmetric_preference_game(argc, argv);
799
} else if (!strcasecmp(base, "igraph_rewire_edges")) {
800
return shell_igraph_rewire_edges(argc, argv);
801
} else if (!strcasecmp(base, "igraph_watts_strogatz_game")) {
802
return shell_igraph_watts_strogatz_game(argc, argv);
803
} else if (!strcasecmp(base, "igraph_lastcit_game")) {
804
return shell_igraph_lastcit_game(argc, argv);
805
} else if (!strcasecmp(base, "igraph_cited_type_game")) {
806
return shell_igraph_cited_type_game(argc, argv);
807
} else if (!strcasecmp(base, "igraph_citing_cited_type_game")) {
808
return shell_igraph_citing_cited_type_game(argc, argv);
809
} else if (!strcasecmp(base, "igraph_forest_fire_game")) {
810
return shell_igraph_forest_fire_game(argc, argv);
811
} else if (!strcasecmp(base, "igraph_are_connected")) {
812
return shell_igraph_are_connected(argc, argv);
813
} else if (!strcasecmp(base, "igraph_diameter")) {
814
return shell_igraph_diameter(argc, argv);
815
} else if (!strcasecmp(base, "igraph_diameter_dijkstra")) {
816
return shell_igraph_diameter_dijkstra(argc, argv);
817
} else if (!strcasecmp(base, "igraph_minimum_spanning_tree_unweighted")) {
818
return shell_igraph_minimum_spanning_tree_unweighted(argc, argv);
819
} else if (!strcasecmp(base, "igraph_minimum_spanning_tree_prim")) {
820
return shell_igraph_minimum_spanning_tree_prim(argc, argv);
821
} else if (!strcasecmp(base, "igraph_closeness")) {
822
return shell_igraph_closeness(argc, argv);
823
} else if (!strcasecmp(base, "igraph_closeness_estimate")) {
824
return shell_igraph_closeness_estimate(argc, argv);
825
} else if (!strcasecmp(base, "igraph_shortest_paths")) {
826
return shell_igraph_shortest_paths(argc, argv);
827
} else if (!strcasecmp(base, "igraph_get_shortest_paths")) {
828
return shell_igraph_get_shortest_paths(argc, argv);
829
} else if (!strcasecmp(base, "igraph_get_all_shortest_paths")) {
830
return shell_igraph_get_all_shortest_paths(argc, argv);
831
} else if (!strcasecmp(base, "igraph_shortest_paths_dijkstra")) {
832
return shell_igraph_shortest_paths_dijkstra(argc, argv);
833
} else if (!strcasecmp(base, "igraph_shortest_paths_bellman_ford")) {
834
return shell_igraph_shortest_paths_bellman_ford(argc, argv);
835
} else if (!strcasecmp(base, "igraph_subcomponent")) {
836
return shell_igraph_subcomponent(argc, argv);
837
} else if (!strcasecmp(base, "igraph_betweenness")) {
838
return shell_igraph_betweenness(argc, argv);
839
} else if (!strcasecmp(base, "igraph_betweenness_estimate")) {
840
return shell_igraph_betweenness_estimate(argc, argv);
841
} else if (!strcasecmp(base, "igraph_edge_betweenness")) {
842
return shell_igraph_edge_betweenness(argc, argv);
843
} else if (!strcasecmp(base, "igraph_edge_betweenness_estimate")) {
844
return shell_igraph_edge_betweenness_estimate(argc, argv);
845
} else if (!strcasecmp(base, "igraph_pagerank_old")) {
846
return shell_igraph_pagerank_old(argc, argv);
847
} else if (!strcasecmp(base, "igraph_pagerank")) {
848
return shell_igraph_pagerank(argc, argv);
849
} else if (!strcasecmp(base, "igraph_rewire")) {
850
return shell_igraph_rewire(argc, argv);
851
} else if (!strcasecmp(base, "igraph_subgraph")) {
852
return shell_igraph_subgraph(argc, argv);
853
} else if (!strcasecmp(base, "igraph_average_path_length")) {
854
return shell_igraph_average_path_length(argc, argv);
855
} else if (!strcasecmp(base, "igraph_path_length_hist")) {
856
return shell_igraph_path_length_hist(argc, argv);
857
} else if (!strcasecmp(base, "igraph_simplify")) {
858
return shell_igraph_simplify(argc, argv);
859
} else if (!strcasecmp(base, "igraph_transitivity_undirected")) {
860
return shell_igraph_transitivity_undirected(argc, argv);
861
} else if (!strcasecmp(base, "igraph_transitivity_local_undirected")) {
862
return shell_igraph_transitivity_local_undirected(argc, argv);
863
} else if (!strcasecmp(base, "igraph_transitivity_avglocal_undirected")) {
864
return shell_igraph_transitivity_avglocal_undirected(argc, argv);
865
} else if (!strcasecmp(base, "igraph_reciprocity")) {
866
return shell_igraph_reciprocity(argc, argv);
867
} else if (!strcasecmp(base, "igraph_constraint")) {
868
return shell_igraph_constraint(argc, argv);
869
} else if (!strcasecmp(base, "igraph_maxdegree")) {
870
return shell_igraph_maxdegree(argc, argv);
871
} else if (!strcasecmp(base, "igraph_density")) {
872
return shell_igraph_density(argc, argv);
873
} else if (!strcasecmp(base, "igraph_neighborhood_size")) {
874
return shell_igraph_neighborhood_size(argc, argv);
875
} else if (!strcasecmp(base, "igraph_neighborhood")) {
876
return shell_igraph_neighborhood(argc, argv);
877
} else if (!strcasecmp(base, "igraph_neighborhood_graphs")) {
878
return shell_igraph_neighborhood_graphs(argc, argv);
879
} else if (!strcasecmp(base, "igraph_topological_sorting")) {
880
return shell_igraph_topological_sorting(argc, argv);
881
} else if (!strcasecmp(base, "igraph_is_loop")) {
882
return shell_igraph_is_loop(argc, argv);
883
} else if (!strcasecmp(base, "igraph_is_simple")) {
884
return shell_igraph_is_simple(argc, argv);
885
} else if (!strcasecmp(base, "igraph_is_multiple")) {
886
return shell_igraph_is_multiple(argc, argv);
887
} else if (!strcasecmp(base, "igraph_count_multiple")) {
888
return shell_igraph_count_multiple(argc, argv);
889
} else if (!strcasecmp(base, "igraph_girth")) {
890
return shell_igraph_girth(argc, argv);
891
} else if (!strcasecmp(base, "igraph_add_edge")) {
892
return shell_igraph_add_edge(argc, argv);
893
} else if (!strcasecmp(base, "igraph_eigenvector_centrality")) {
894
return shell_igraph_eigenvector_centrality(argc, argv);
895
} else if (!strcasecmp(base, "igraph_hub_score")) {
896
return shell_igraph_hub_score(argc, argv);
897
} else if (!strcasecmp(base, "igraph_authority_score")) {
898
return shell_igraph_authority_score(argc, argv);
899
} else if (!strcasecmp(base, "igraph_arpack_rssolve")) {
900
return shell_igraph_arpack_rssolve(argc, argv);
901
} else if (!strcasecmp(base, "igraph_arpack_rnsolve")) {
902
return shell_igraph_arpack_rnsolve(argc, argv);
903
} else if (!strcasecmp(base, "igraph_arpack_unpack_complex")) {
904
return shell_igraph_arpack_unpack_complex(argc, argv);
905
} else if (!strcasecmp(base, "igraph_unfold_tree")) {
906
return shell_igraph_unfold_tree(argc, argv);
907
} else if (!strcasecmp(base, "igraph_laplacian")) {
908
return shell_igraph_laplacian(argc, argv);
909
} else if (!strcasecmp(base, "igraph_is_mutual")) {
910
return shell_igraph_is_mutual(argc, argv);
911
} else if (!strcasecmp(base, "igraph_avg_nearest_neighbor_degree")) {
912
return shell_igraph_avg_nearest_neighbor_degree(argc, argv);
913
} else if (!strcasecmp(base, "igraph_strength")) {
914
return shell_igraph_strength(argc, argv);
915
} else if (!strcasecmp(base, "igraph_bipartite_projection_size")) {
916
return shell_igraph_bipartite_projection_size(argc, argv);
917
} else if (!strcasecmp(base, "igraph_bipartite_projection")) {
918
return shell_igraph_bipartite_projection(argc, argv);
919
} else if (!strcasecmp(base, "igraph_create_bipartite")) {
920
return shell_igraph_create_bipartite(argc, argv);
921
} else if (!strcasecmp(base, "igraph_incidence")) {
922
return shell_igraph_incidence(argc, argv);
923
} else if (!strcasecmp(base, "igraph_get_incidence")) {
924
return shell_igraph_get_incidence(argc, argv);
925
} else if (!strcasecmp(base, "igraph_is_bipartite")) {
926
return shell_igraph_is_bipartite(argc, argv);
927
} else if (!strcasecmp(base, "igraph_clusters")) {
928
return shell_igraph_clusters(argc, argv);
929
} else if (!strcasecmp(base, "igraph_is_connected")) {
930
return shell_igraph_is_connected(argc, argv);
931
} else if (!strcasecmp(base, "igraph_decompose")) {
932
return shell_igraph_decompose(argc, argv);
933
} else if (!strcasecmp(base, "igraph_articulation_points")) {
934
return shell_igraph_articulation_points(argc, argv);
935
} else if (!strcasecmp(base, "igraph_biconnected_components")) {
936
return shell_igraph_biconnected_components(argc, argv);
937
} else if (!strcasecmp(base, "igraph_cliques")) {
938
return shell_igraph_cliques(argc, argv);
939
} else if (!strcasecmp(base, "igraph_largest_cliques")) {
940
return shell_igraph_largest_cliques(argc, argv);
941
} else if (!strcasecmp(base, "igraph_maximal_cliques")) {
942
return shell_igraph_maximal_cliques(argc, argv);
943
} else if (!strcasecmp(base, "igraph_clique_number")) {
944
return shell_igraph_clique_number(argc, argv);
945
} else if (!strcasecmp(base, "igraph_independent_vertex_sets")) {
946
return shell_igraph_independent_vertex_sets(argc, argv);
947
} else if (!strcasecmp(base, "igraph_largest_independent_vertex_sets")) {
948
return shell_igraph_largest_independent_vertex_sets(argc, argv);
949
} else if (!strcasecmp(base, "igraph_maximal_independent_vertex_sets")) {
950
return shell_igraph_maximal_independent_vertex_sets(argc, argv);
951
} else if (!strcasecmp(base, "igraph_independence_number")) {
952
return shell_igraph_independence_number(argc, argv);
953
} else if (!strcasecmp(base, "igraph_layout_random")) {
954
return shell_igraph_layout_random(argc, argv);
955
} else if (!strcasecmp(base, "igraph_layout_circle")) {
956
return shell_igraph_layout_circle(argc, argv);
957
} else if (!strcasecmp(base, "igraph_layout_fruchterman_reingold")) {
958
return shell_igraph_layout_fruchterman_reingold(argc, argv);
959
} else if (!strcasecmp(base, "igraph_layout_grid_fruchterman_reingold")) {
960
return shell_igraph_layout_grid_fruchterman_reingold(argc, argv);
961
} else if (!strcasecmp(base, "igraph_layout_kamada_kawai")) {
962
return shell_igraph_layout_kamada_kawai(argc, argv);
963
} else if (!strcasecmp(base, "igraph_layout_lgl")) {
964
return shell_igraph_layout_lgl(argc, argv);
965
} else if (!strcasecmp(base, "igraph_layout_reingold_tilford")) {
966
return shell_igraph_layout_reingold_tilford(argc, argv);
967
} else if (!strcasecmp(base, "igraph_layout_reingold_tilford_circular")) {
968
return shell_igraph_layout_reingold_tilford_circular(argc, argv);
969
} else if (!strcasecmp(base, "igraph_layout_random_3d")) {
970
return shell_igraph_layout_random_3d(argc, argv);
971
} else if (!strcasecmp(base, "igraph_layout_sphere")) {
972
return shell_igraph_layout_sphere(argc, argv);
973
} else if (!strcasecmp(base, "igraph_layout_fruchterman_reingold_3d")) {
974
return shell_igraph_layout_fruchterman_reingold_3d(argc, argv);
975
} else if (!strcasecmp(base, "igraph_layout_kamada_kawai_3d")) {
976
return shell_igraph_layout_kamada_kawai_3d(argc, argv);
977
} else if (!strcasecmp(base, "igraph_layout_graphopt")) {
978
return shell_igraph_layout_graphopt(argc, argv);
979
} else if (!strcasecmp(base, "igraph_layout_drl")) {
980
return shell_igraph_layout_drl(argc, argv);
981
} else if (!strcasecmp(base, "igraph_layout_drl_3d")) {
982
return shell_igraph_layout_drl_3d(argc, argv);
983
} else if (!strcasecmp(base, "igraph_layout_merge_dla")) {
984
return shell_igraph_layout_merge_dla(argc, argv);
985
} else if (!strcasecmp(base, "igraph_cocitation")) {
986
return shell_igraph_cocitation(argc, argv);
987
} else if (!strcasecmp(base, "igraph_bibcoupling")) {
988
return shell_igraph_bibcoupling(argc, argv);
989
} else if (!strcasecmp(base, "igraph_similarity_jaccard")) {
990
return shell_igraph_similarity_jaccard(argc, argv);
991
} else if (!strcasecmp(base, "igraph_similarity_dice")) {
992
return shell_igraph_similarity_dice(argc, argv);
993
} else if (!strcasecmp(base, "igraph_similarity_inverse_log_weighted")) {
994
return shell_igraph_similarity_inverse_log_weighted(argc, argv);
995
} else if (!strcasecmp(base, "igraph_community_spinglass")) {
996
return shell_igraph_community_spinglass(argc, argv);
997
} else if (!strcasecmp(base, "igraph_community_spinglass_single")) {
998
return shell_igraph_community_spinglass_single(argc, argv);
999
} else if (!strcasecmp(base, "igraph_community_walktrap")) {
1000
return shell_igraph_community_walktrap(argc, argv);
1001
} else if (!strcasecmp(base, "igraph_community_edge_betweenness")) {
1002
return shell_igraph_community_edge_betweenness(argc, argv);
1003
} else if (!strcasecmp(base, "igraph_community_eb_get_merges")) {
1004
return shell_igraph_community_eb_get_merges(argc, argv);
1005
} else if (!strcasecmp(base, "igraph_community_fastgreedy")) {
1006
return shell_igraph_community_fastgreedy(argc, argv);
1007
} else if (!strcasecmp(base, "igraph_community_to_membership")) {
1008
return shell_igraph_community_to_membership(argc, argv);
1009
} else if (!strcasecmp(base, "igraph_le_community_to_membership")) {
1010
return shell_igraph_le_community_to_membership(argc, argv);
1011
} else if (!strcasecmp(base, "igraph_modularity")) {
1012
return shell_igraph_modularity(argc, argv);
1013
} else if (!strcasecmp(base, "igraph_community_leading_eigenvector")) {
1014
return shell_igraph_community_leading_eigenvector(argc, argv);
1015
} else if (!strcasecmp(base, "igraph_community_leading_eigenvector_naive")) {
1016
return shell_igraph_community_leading_eigenvector_naive(argc, argv);
1017
} else if (!strcasecmp(base, "igraph_community_leading_eigenvector_step")) {
1018
return shell_igraph_community_leading_eigenvector_step(argc, argv);
1019
} else if (!strcasecmp(base, "igraph_community_label_propagation")) {
1020
return shell_igraph_community_label_propagation(argc, argv);
1021
} else if (!strcasecmp(base, "igraph_get_adjacency")) {
1022
return shell_igraph_get_adjacency(argc, argv);
1023
} else if (!strcasecmp(base, "igraph_get_edgelist")) {
1024
return shell_igraph_get_edgelist(argc, argv);
1025
} else if (!strcasecmp(base, "igraph_to_directed")) {
1026
return shell_igraph_to_directed(argc, argv);
1027
} else if (!strcasecmp(base, "igraph_to_undirected")) {
1028
return shell_igraph_to_undirected(argc, argv);
1029
} else if (!strcasecmp(base, "igraph_read_graph_edgelist")) {
1030
return shell_igraph_read_graph_edgelist(argc, argv);
1031
} else if (!strcasecmp(base, "igraph_read_graph_ncol")) {
1032
return shell_igraph_read_graph_ncol(argc, argv);
1033
} else if (!strcasecmp(base, "igraph_read_graph_lgl")) {
1034
return shell_igraph_read_graph_lgl(argc, argv);
1035
} else if (!strcasecmp(base, "igraph_read_graph_pajek")) {
1036
return shell_igraph_read_graph_pajek(argc, argv);
1037
} else if (!strcasecmp(base, "igraph_read_graph_graphml")) {
1038
return shell_igraph_read_graph_graphml(argc, argv);
1039
} else if (!strcasecmp(base, "igraph_read_graph_dimacs")) {
1040
return shell_igraph_read_graph_dimacs(argc, argv);
1041
} else if (!strcasecmp(base, "igraph_read_graph_graphdb")) {
1042
return shell_igraph_read_graph_graphdb(argc, argv);
1043
} else if (!strcasecmp(base, "igraph_read_graph_gml")) {
1044
return shell_igraph_read_graph_gml(argc, argv);
1045
} else if (!strcasecmp(base, "igraph_write_graph_edgelist")) {
1046
return shell_igraph_write_graph_edgelist(argc, argv);
1047
} else if (!strcasecmp(base, "igraph_write_graph_ncol")) {
1048
return shell_igraph_write_graph_ncol(argc, argv);
1049
} else if (!strcasecmp(base, "igraph_write_graph_lgl")) {
1050
return shell_igraph_write_graph_lgl(argc, argv);
1051
} else if (!strcasecmp(base, "igraph_write_graph_graphml")) {
1052
return shell_igraph_write_graph_graphml(argc, argv);
1053
} else if (!strcasecmp(base, "igraph_write_graph_pajek")) {
1054
return shell_igraph_write_graph_pajek(argc, argv);
1055
} else if (!strcasecmp(base, "igraph_write_graph_dimacs")) {
1056
return shell_igraph_write_graph_dimacs(argc, argv);
1057
} else if (!strcasecmp(base, "igraph_write_graph_gml")) {
1058
return shell_igraph_write_graph_gml(argc, argv);
1059
} else if (!strcasecmp(base, "igraph_write_graph_dot")) {
1060
return shell_igraph_write_graph_dot(argc, argv);
1061
} else if (!strcasecmp(base, "igraph_motifs_randesu")) {
1062
return shell_igraph_motifs_randesu(argc, argv);
1063
} else if (!strcasecmp(base, "igraph_motifs_randesu_estimate")) {
1064
return shell_igraph_motifs_randesu_estimate(argc, argv);
1065
} else if (!strcasecmp(base, "igraph_motifs_randesu_no")) {
1066
return shell_igraph_motifs_randesu_no(argc, argv);
1067
} else if (!strcasecmp(base, "igraph_dyad_census")) {
1068
return shell_igraph_dyad_census(argc, argv);
1069
} else if (!strcasecmp(base, "igraph_triad_census")) {
1070
return shell_igraph_triad_census(argc, argv);
1071
} else if (!strcasecmp(base, "igraph_disjoint_union")) {
1072
return shell_igraph_disjoint_union(argc, argv);
1073
} else if (!strcasecmp(base, "igraph_disjoint_union_many")) {
1074
return shell_igraph_disjoint_union_many(argc, argv);
1075
} else if (!strcasecmp(base, "igraph_union")) {
1076
return shell_igraph_union(argc, argv);
1077
} else if (!strcasecmp(base, "igraph_union_many")) {
1078
return shell_igraph_union_many(argc, argv);
1079
} else if (!strcasecmp(base, "igraph_intersection")) {
1080
return shell_igraph_intersection(argc, argv);
1081
} else if (!strcasecmp(base, "igraph_intersection_many")) {
1082
return shell_igraph_intersection_many(argc, argv);
1083
} else if (!strcasecmp(base, "igraph_difference")) {
1084
return shell_igraph_difference(argc, argv);
1085
} else if (!strcasecmp(base, "igraph_complementer")) {
1086
return shell_igraph_complementer(argc, argv);
1087
} else if (!strcasecmp(base, "igraph_compose")) {
1088
return shell_igraph_compose(argc, argv);
1089
} else if (!strcasecmp(base, "igraph_maxflow_value")) {
1090
return shell_igraph_maxflow_value(argc, argv);
1091
} else if (!strcasecmp(base, "igraph_mincut_value")) {
1092
return shell_igraph_mincut_value(argc, argv);
1093
} else if (!strcasecmp(base, "igraph_st_mincut_value")) {
1094
return shell_igraph_st_mincut_value(argc, argv);
1095
} else if (!strcasecmp(base, "igraph_mincut")) {
1096
return shell_igraph_mincut(argc, argv);
1097
} else if (!strcasecmp(base, "igraph_st_vertex_connectivity")) {
1098
return shell_igraph_st_vertex_connectivity(argc, argv);
1099
} else if (!strcasecmp(base, "igraph_vertex_connectivity")) {
1100
return shell_igraph_vertex_connectivity(argc, argv);
1101
} else if (!strcasecmp(base, "igraph_st_edge_connectivity")) {
1102
return shell_igraph_st_edge_connectivity(argc, argv);
1103
} else if (!strcasecmp(base, "igraph_edge_connectivity")) {
1104
return shell_igraph_edge_connectivity(argc, argv);
1105
} else if (!strcasecmp(base, "igraph_edge_disjoint_paths")) {
1106
return shell_igraph_edge_disjoint_paths(argc, argv);
1107
} else if (!strcasecmp(base, "igraph_vertex_disjoint_paths")) {
1108
return shell_igraph_vertex_disjoint_paths(argc, argv);
1109
} else if (!strcasecmp(base, "igraph_adhesion")) {
1110
return shell_igraph_adhesion(argc, argv);
1111
} else if (!strcasecmp(base, "igraph_cohesion")) {
1112
return shell_igraph_cohesion(argc, argv);
1113
} else if (!strcasecmp(base, "igraph_coreness")) {
1114
return shell_igraph_coreness(argc, argv);
1115
} else if (!strcasecmp(base, "igraph_isoclass")) {
1116
return shell_igraph_isoclass(argc, argv);
1117
} else if (!strcasecmp(base, "igraph_isomorphic")) {
1118
return shell_igraph_isomorphic(argc, argv);
1119
} else if (!strcasecmp(base, "igraph_isoclass_subgraph")) {
1120
return shell_igraph_isoclass_subgraph(argc, argv);
1121
} else if (!strcasecmp(base, "igraph_isoclass_create")) {
1122
return shell_igraph_isoclass_create(argc, argv);
1123
} else if (!strcasecmp(base, "igraph_isomorphic_vf2")) {
1124
return shell_igraph_isomorphic_vf2(argc, argv);
1125
} else if (!strcasecmp(base, "igraph_count_isomorphisms_vf2")) {
1126
return shell_igraph_count_isomorphisms_vf2(argc, argv);
1127
} else if (!strcasecmp(base, "igraph_get_isomorphisms_vf2")) {
1128
return shell_igraph_get_isomorphisms_vf2(argc, argv);
1129
} else if (!strcasecmp(base, "igraph_subisomorphic_vf2")) {
1130
return shell_igraph_subisomorphic_vf2(argc, argv);
1131
} else if (!strcasecmp(base, "igraph_count_subisomorphisms_vf2")) {
1132
return shell_igraph_count_subisomorphisms_vf2(argc, argv);
1133
} else if (!strcasecmp(base, "igraph_get_subisomorphisms_vf2")) {
1134
return shell_igraph_get_subisomorphisms_vf2(argc, argv);
1135
} else if (!strcasecmp(base, "igraph_isomorphic_34")) {
1136
return shell_igraph_isomorphic_34(argc, argv);
1137
} else if (!strcasecmp(base, "igraph_canonical_permutation")) {
1138
return shell_igraph_canonical_permutation(argc, argv);
1139
} else if (!strcasecmp(base, "igraph_permute_vertices")) {
1140
return shell_igraph_permute_vertices(argc, argv);
1141
} else if (!strcasecmp(base, "igraph_isomorphic_bliss")) {
1142
return shell_igraph_isomorphic_bliss(argc, argv);
1143
} else if (!strcasecmp(base, "igraph_automorphisms")) {
1144
return shell_igraph_automorphisms(argc, argv);
1145
} else if (!strcasecmp(base, "igraph_running_mean")) {
1146
return shell_igraph_running_mean(argc, argv);
1147
} else if (!strcasecmp(base, "igraph_random_sample")) {
1148
return shell_igraph_random_sample(argc, argv);
1149
} else if (!strcasecmp(base, "igraph_convex_hull")) {
1150
return shell_igraph_convex_hull(argc, argv);
1151
} else if (!strcasecmp(base, "igraph_revolver_ml_d")) {
1152
return shell_igraph_revolver_ml_d(argc, argv);
1153
} else if (!strcasecmp(base, "igraph_revolver_probs_d")) {
1154
return shell_igraph_revolver_probs_d(argc, argv);
1155
} else if (!strcasecmp(base, "igraph_revolver_ml_de")) {
1156
return shell_igraph_revolver_ml_de(argc, argv);
1157
} else if (!strcasecmp(base, "igraph_revolver_probs_de")) {
1158
return shell_igraph_revolver_probs_de(argc, argv);
1159
} else if (!strcasecmp(base, "igraph_revolver_ml_ade")) {
1160
return shell_igraph_revolver_ml_ade(argc, argv);
1161
} else if (!strcasecmp(base, "igraph_revolver_probs_ade")) {
1162
return shell_igraph_revolver_probs_ade(argc, argv);
1163
} else if (!strcasecmp(base, "igraph_revolver_ml_f")) {
1164
return shell_igraph_revolver_ml_f(argc, argv);
1165
} else if (!strcasecmp(base, "igraph_revolver_ml_df")) {
1166
return shell_igraph_revolver_ml_df(argc, argv);
1167
} else if (!strcasecmp(base, "igraph_revolver_ml_l")) {
1168
return shell_igraph_revolver_ml_l(argc, argv);
1169
} else if (!strcasecmp(base, "igraph_revolver_ml_ad")) {
1170
return shell_igraph_revolver_ml_ad(argc, argv);
1171
} else if (!strcasecmp(base, "igraph_revolver_probs_ad")) {
1172
return shell_igraph_revolver_probs_ad(argc, argv);
1173
} else if (!strcasecmp(base, "igraph_revolver_ml_D_alpha")) {
1174
return shell_igraph_revolver_ml_D_alpha(argc, argv);
1175
} else if (!strcasecmp(base, "igraph_revolver_ml_D_alpha_a")) {
1176
return shell_igraph_revolver_ml_D_alpha_a(argc, argv);
1177
} else if (!strcasecmp(base, "igraph_revolver_ml_DE_alpha_a")) {
1178
return shell_igraph_revolver_ml_DE_alpha_a(argc, argv);
1179
} else if (!strcasecmp(base, "igraph_revolver_ml_AD_alpha_a_beta")) {
1180
return shell_igraph_revolver_ml_AD_alpha_a_beta(argc, argv);
1181
} else if (!strcasecmp(base, "igraph_revolver_ml_AD_dpareto")) {
1182
return shell_igraph_revolver_ml_AD_dpareto(argc, argv);
1183
} else if (!strcasecmp(base, "igraph_revolver_ml_AD_dpareto_eval")) {
1184
return shell_igraph_revolver_ml_AD_dpareto_eval(argc, argv);
1185
} else if (!strcasecmp(base, "igraph_revolver_ml_ADE_alpha_a_beta")) {
1186
return shell_igraph_revolver_ml_ADE_alpha_a_beta(argc, argv);
1187
} else if (!strcasecmp(base, "igraph_revolver_ml_ADE_dpareto")) {
1188
return shell_igraph_revolver_ml_ADE_dpareto(argc, argv);
1189
} else if (!strcasecmp(base, "igraph_revolver_ml_ADE_dpareto_eval")) {
1190
return shell_igraph_revolver_ml_ADE_dpareto_eval(argc, argv);
1191
} else if (!strcasecmp(base, "igraph_revolver_ml_ADE_dpareto_evalf")) {
1192
return shell_igraph_revolver_ml_ADE_dpareto_evalf(argc, argv);
1193
} else if (!strcasecmp(base, "igraph_revolver_probs_ADE_dpareto")) {
1194
return shell_igraph_revolver_probs_ADE_dpareto(argc, argv);
1195
} else if (!strcasecmp(base, "igraph_convergence_degree")) {
1196
return shell_igraph_convergence_degree(argc, argv);
1198
printf("Unknown function, exiting\n");
1201
shell_igraph_usage(argc, argv);
1206
/* The functions themselves at last */
1208
/*-------------------------------------------/
1210
/-------------------------------------------*/
1211
void shell_igraph_empty_usage(char **argv) {
1212
printf("%s --graph=<graph> --n=<n> --directed=<directed>\n", basename(argv[0]));
1216
int shell_igraph_empty(int argc, char **argv) {
1219
igraph_integer_t n=0;
1220
igraph_bool_t directed=1;
1221
char* shell_arg_graph=0;
1227
struct option shell_options[]= { { "graph",required_argument,0,0 },
1228
{ "n",required_argument,0,1 },
1229
{ "directed",required_argument,0,2 },
1230
{ "help",no_argument,0,3 },
1234
/* 0 - not seen, 1 - seen as argument, 2 - seen as default */
1235
memset(shell_seen, 0, 3*sizeof(int));
1239
/* Parse arguments and read input */
1240
while (getopt_long(argc, argv, "", shell_options, &shell_index) != -1) {
1242
if (shell_index==-1) {
1246
if (shell_seen[shell_index]==1) {
1247
fprintf(stderr, "Error, `--%s' argument given twice.\n",
1248
shell_options[shell_index].name);
1251
shell_seen[shell_index]=1;
1253
switch (shell_index) {
1255
shell_arg_graph=strdup(optarg);
1258
shell_read_integer(&n, optarg);
1260
case 2: /* directed */
1261
shell_read_boolean(&directed, optarg);
1264
shell_igraph_empty_usage(argv);
1273
/* Check that we have all arguments */
1274
for (shell_index=0; shell_index<3; shell_index++) {
1275
if (!shell_seen[shell_index]) {
1276
fprintf(stderr, "Error, argument missing: `--%s'.\n",
1277
shell_options[shell_index].name);
1282
/* Do the operation */
1283
shell_result=igraph_empty(&graph, n, directed);
1285
/* Write the result */
1286
shell_write_graph(&graph, shell_arg_graph);
1287
igraph_destroy(&graph);
1292
/*-------------------------------------------/
1293
/ igraph_add_edges /
1294
/-------------------------------------------*/
1295
void shell_igraph_add_edges_usage(char **argv) {
1296
printf("%s --graph=<graph> --graph-out=<graph-out> --edges=<edges>\n", basename(argv[0]));
1300
int shell_igraph_add_edges(int argc, char **argv) {
1303
igraph_vector_t edges;
1305
char* shell_arg_graph=0;
1311
struct option shell_options[]= { { "graph",required_argument,0,0 },
1312
{ "graph-out",required_argument,0,1 },
1313
{ "edges",required_argument,0,2 },
1314
{ "help",no_argument,0,3 },
1318
/* 0 - not seen, 1 - seen as argument, 2 - seen as default */
1319
memset(shell_seen, 0, 3*sizeof(int));
1322
/* Parse arguments and read input */
1323
while (getopt_long(argc, argv, "", shell_options, &shell_index) != -1) {
1325
if (shell_index==-1) {
1329
if (shell_seen[shell_index]==1) {
1330
fprintf(stderr, "Error, `--%s' argument given twice.\n",
1331
shell_options[shell_index].name);
1334
shell_seen[shell_index]=1;
1336
switch (shell_index) {
1338
shell_read_graph(&graph, optarg);
1340
case 1: /* graph-out */
1341
shell_arg_graph=strdup(optarg);
1344
shell_read_vector(&edges, optarg);
1347
shell_igraph_add_edges_usage(argv);
1356
/* Check that we have all arguments */
1357
for (shell_index=0; shell_index<3; shell_index++) {
1358
if (!shell_seen[shell_index]) {
1359
fprintf(stderr, "Error, argument missing: `--%s'.\n",
1360
shell_options[shell_index].name);
1365
/* Do the operation */
1366
shell_result=igraph_add_edges(&graph, &edges, 0);
1368
/* Write the result */
1369
igraph_destroy(&graph);
1370
shell_write_graph(&graph, shell_arg_graph);
1371
igraph_destroy(&graph);
1372
igraph_vector_destroy(&edges);
1377
/*-------------------------------------------/
1378
/ igraph_add_vertices /
1379
/-------------------------------------------*/
1380
void shell_igraph_add_vertices_usage(char **argv) {
1381
printf("%s --graph=<graph> --graph-out=<graph-out> --nv=<nv>\n", basename(argv[0]));
1385
int shell_igraph_add_vertices(int argc, char **argv) {
1388
igraph_integer_t nv;
1390
char* shell_arg_graph=0;
1396
struct option shell_options[]= { { "graph",required_argument,0,0 },
1397
{ "graph-out",required_argument,0,1 },
1398
{ "nv",required_argument,0,2 },
1399
{ "help",no_argument,0,3 },
1403
/* 0 - not seen, 1 - seen as argument, 2 - seen as default */
1404
memset(shell_seen, 0, 3*sizeof(int));
1407
/* Parse arguments and read input */
1408
while (getopt_long(argc, argv, "", shell_options, &shell_index) != -1) {
1410
if (shell_index==-1) {
1414
if (shell_seen[shell_index]==1) {
1415
fprintf(stderr, "Error, `--%s' argument given twice.\n",
1416
shell_options[shell_index].name);
1419
shell_seen[shell_index]=1;
1421
switch (shell_index) {
1423
shell_read_graph(&graph, optarg);
1425
case 1: /* graph-out */
1426
shell_arg_graph=strdup(optarg);
1429
shell_read_integer(&nv, optarg);
1432
shell_igraph_add_vertices_usage(argv);
1441
/* Check that we have all arguments */
1442
for (shell_index=0; shell_index<3; shell_index++) {
1443
if (!shell_seen[shell_index]) {
1444
fprintf(stderr, "Error, argument missing: `--%s'.\n",
1445
shell_options[shell_index].name);
1450
/* Do the operation */
1451
shell_result=igraph_add_vertices(&graph, nv, 0);
1453
/* Write the result */
1454
igraph_destroy(&graph);
1455
shell_write_graph(&graph, shell_arg_graph);
1456
igraph_destroy(&graph);
1461
/*-------------------------------------------/
1462
/ igraph_delete_edges /
1463
/-------------------------------------------*/
1464
void shell_igraph_delete_edges_usage(char **argv) {
1465
printf("%s --graph=<graph> --graph-out=<graph-out> --edges=<edges>\n", basename(argv[0]));
1469
int shell_igraph_delete_edges(int argc, char **argv) {
1472
igraph_vector_t v_edges; igraph_es_t edges;
1473
char* shell_arg_graph=0;
1479
struct option shell_options[]= { { "graph",required_argument,0,0 },
1480
{ "graph-out",required_argument,0,1 },
1481
{ "edges",required_argument,0,2 },
1482
{ "help",no_argument,0,3 },
1486
/* 0 - not seen, 1 - seen as argument, 2 - seen as default */
1487
memset(shell_seen, 0, 3*sizeof(int));
1490
/* Parse arguments and read input */
1491
while (getopt_long(argc, argv, "", shell_options, &shell_index) != -1) {
1493
if (shell_index==-1) {
1497
if (shell_seen[shell_index]==1) {
1498
fprintf(stderr, "Error, `--%s' argument given twice.\n",
1499
shell_options[shell_index].name);
1502
shell_seen[shell_index]=1;
1504
switch (shell_index) {
1506
shell_read_graph(&graph, optarg);
1508
case 1: /* graph-out */
1509
shell_arg_graph=strdup(optarg);
1512
shell_read_vector(&v_edges, optarg); igraph_es_vector(&edges, &v_edges);
1515
shell_igraph_delete_edges_usage(argv);
1524
/* Check that we have all arguments */
1525
for (shell_index=0; shell_index<3; shell_index++) {
1526
if (!shell_seen[shell_index]) {
1527
fprintf(stderr, "Error, argument missing: `--%s'.\n",
1528
shell_options[shell_index].name);
1533
/* Do the operation */
1534
shell_result=igraph_delete_edges(&graph, edges);
1536
/* Write the result */
1537
igraph_destroy(&graph);
1538
shell_write_graph(&graph, shell_arg_graph);
1539
igraph_destroy(&graph);
1540
if (!igraph_es_is_all(&edges)) { igraph_es_destroy(&edges); }
1545
/*-------------------------------------------/
1546
/ igraph_delete_vertices /
1547
/-------------------------------------------*/
1548
void shell_igraph_delete_vertices_usage(char **argv) {
1549
printf("%s --graph=<graph> --graph-out=<graph-out> --vertices=<vertices>\n", basename(argv[0]));
1553
int shell_igraph_delete_vertices(int argc, char **argv) {
1556
igraph_vector_t v_vertices; igraph_vs_t vertices;
1557
char* shell_arg_graph=0;
1563
struct option shell_options[]= { { "graph",required_argument,0,0 },
1564
{ "graph-out",required_argument,0,1 },
1565
{ "vertices",required_argument,0,2 },
1566
{ "help",no_argument,0,3 },
1570
/* 0 - not seen, 1 - seen as argument, 2 - seen as default */
1571
memset(shell_seen, 0, 3*sizeof(int));
1574
/* Parse arguments and read input */
1575
while (getopt_long(argc, argv, "", shell_options, &shell_index) != -1) {
1577
if (shell_index==-1) {
1581
if (shell_seen[shell_index]==1) {
1582
fprintf(stderr, "Error, `--%s' argument given twice.\n",
1583
shell_options[shell_index].name);
1586
shell_seen[shell_index]=1;
1588
switch (shell_index) {
1590
shell_read_graph(&graph, optarg);
1592
case 1: /* graph-out */
1593
shell_arg_graph=strdup(optarg);
1595
case 2: /* vertices */
1596
shell_read_vector(&v_vertices, optarg); igraph_vs_vector(&vertices, &v_vertices);
1599
shell_igraph_delete_vertices_usage(argv);
1608
/* Check that we have all arguments */
1609
for (shell_index=0; shell_index<3; shell_index++) {
1610
if (!shell_seen[shell_index]) {
1611
fprintf(stderr, "Error, argument missing: `--%s'.\n",
1612
shell_options[shell_index].name);
1617
/* Do the operation */
1618
shell_result=igraph_delete_vertices(&graph, vertices);
1620
/* Write the result */
1621
igraph_destroy(&graph);
1622
shell_write_graph(&graph, shell_arg_graph);
1623
igraph_destroy(&graph);
1624
if (!igraph_vs_is_all(&vertices)) { igraph_vector_destroy(&v_vertices); }
1629
/*-------------------------------------------/
1631
/-------------------------------------------*/
1632
void shell_igraph_vcount_usage(char **argv) {
1633
printf("%s --graph=<graph>\n", basename(argv[0]));
1637
int shell_igraph_vcount(int argc, char **argv) {
1640
igraph_integer_t shell_result;
1641
char *shell_arg_shell_result="-";
1645
struct option shell_options[]= { { "graph",required_argument,0,0 },
1646
{ "help",no_argument,0,1 },
1650
/* 0 - not seen, 1 - seen as argument, 2 - seen as default */
1651
memset(shell_seen, 0, 1*sizeof(int));
1654
/* Parse arguments and read input */
1655
while (getopt_long(argc, argv, "", shell_options, &shell_index) != -1) {
1657
if (shell_index==-1) {
1661
if (shell_seen[shell_index]==1) {
1662
fprintf(stderr, "Error, `--%s' argument given twice.\n",
1663
shell_options[shell_index].name);
1666
shell_seen[shell_index]=1;
1668
switch (shell_index) {
1670
shell_read_graph(&graph, optarg);
1673
shell_igraph_vcount_usage(argv);
1682
/* Check that we have all arguments */
1683
for (shell_index=0; shell_index<1; shell_index++) {
1684
if (!shell_seen[shell_index]) {
1685
fprintf(stderr, "Error, argument missing: `--%s'.\n",
1686
shell_options[shell_index].name);
1691
/* Do the operation */
1692
shell_result=igraph_vcount(&graph);
1694
/* Write the result */
1695
igraph_destroy(&graph);
1700
/*-------------------------------------------/
1702
/-------------------------------------------*/
1703
void shell_igraph_ecount_usage(char **argv) {
1704
printf("%s --graph=<graph>\n", basename(argv[0]));
1708
int shell_igraph_ecount(int argc, char **argv) {
1711
igraph_integer_t shell_result;
1712
char *shell_arg_shell_result="-";
1716
struct option shell_options[]= { { "graph",required_argument,0,0 },
1717
{ "help",no_argument,0,1 },
1721
/* 0 - not seen, 1 - seen as argument, 2 - seen as default */
1722
memset(shell_seen, 0, 1*sizeof(int));
1725
/* Parse arguments and read input */
1726
while (getopt_long(argc, argv, "", shell_options, &shell_index) != -1) {
1728
if (shell_index==-1) {
1732
if (shell_seen[shell_index]==1) {
1733
fprintf(stderr, "Error, `--%s' argument given twice.\n",
1734
shell_options[shell_index].name);
1737
shell_seen[shell_index]=1;
1739
switch (shell_index) {
1741
shell_read_graph(&graph, optarg);
1744
shell_igraph_ecount_usage(argv);
1753
/* Check that we have all arguments */
1754
for (shell_index=0; shell_index<1; shell_index++) {
1755
if (!shell_seen[shell_index]) {
1756
fprintf(stderr, "Error, argument missing: `--%s'.\n",
1757
shell_options[shell_index].name);
1762
/* Do the operation */
1763
shell_result=igraph_ecount(&graph);
1765
/* Write the result */
1766
igraph_destroy(&graph);
1771
/*-------------------------------------------/
1772
/ igraph_neighbors /
1773
/-------------------------------------------*/
1774
void shell_igraph_neighbors_usage(char **argv) {
1775
printf("%s --graph=<graph> --neis=<neis> --vid=<vid> --mode=<mode>\n", basename(argv[0]));
1779
int shell_igraph_neighbors(int argc, char **argv) {
1782
igraph_vector_t neis;
1783
igraph_integer_t vid;
1784
igraph_neimode_t mode=IGRAPH_ALL;
1785
char* shell_arg_neis=0;
1791
struct option shell_options[]= { { "graph",required_argument,0,0 },
1792
{ "neis",required_argument,0,1 },
1793
{ "vid",required_argument,0,2 },
1794
{ "mode",required_argument,0,3 },
1795
{ "help",no_argument,0,4 },
1799
/* 0 - not seen, 1 - seen as argument, 2 - seen as default */
1800
memset(shell_seen, 0, 4*sizeof(int));
1803
/* Parse arguments and read input */
1804
while (getopt_long(argc, argv, "", shell_options, &shell_index) != -1) {
1806
if (shell_index==-1) {
1810
if (shell_seen[shell_index]==1) {
1811
fprintf(stderr, "Error, `--%s' argument given twice.\n",
1812
shell_options[shell_index].name);
1815
shell_seen[shell_index]=1;
1817
switch (shell_index) {
1819
shell_read_graph(&graph, optarg);
1822
shell_arg_neis=strdup(optarg);
1823
igraph_vector_init(&neis, 0);
1826
shell_read_integer(&vid, optarg);
1829
shell_read_enum(&mode, optarg, "out", 1, "in", 2, "all", 3, "total", 3, 0);
1832
shell_igraph_neighbors_usage(argv);
1841
/* Check that we have all arguments */
1842
for (shell_index=0; shell_index<4; shell_index++) {
1843
if (!shell_seen[shell_index]) {
1844
fprintf(stderr, "Error, argument missing: `--%s'.\n",
1845
shell_options[shell_index].name);
1850
/* Do the operation */
1851
shell_result=igraph_neighbors(&graph, &neis, vid, mode);
1853
/* Write the result */
1854
igraph_destroy(&graph);
1855
shell_write_vector(&neis, shell_arg_neis);
1856
igraph_vector_destroy(&neis);
1861
/*-------------------------------------------/
1862
/ igraph_is_directed /
1863
/-------------------------------------------*/
1864
void shell_igraph_is_directed_usage(char **argv) {
1865
printf("%s --graph=<graph>\n", basename(argv[0]));
1869
int shell_igraph_is_directed(int argc, char **argv) {
1872
igraph_bool_t shell_result;
1873
char *shell_arg_shell_result="-";
1877
struct option shell_options[]= { { "graph",required_argument,0,0 },
1878
{ "help",no_argument,0,1 },
1882
/* 0 - not seen, 1 - seen as argument, 2 - seen as default */
1883
memset(shell_seen, 0, 1*sizeof(int));
1886
/* Parse arguments and read input */
1887
while (getopt_long(argc, argv, "", shell_options, &shell_index) != -1) {
1889
if (shell_index==-1) {
1893
if (shell_seen[shell_index]==1) {
1894
fprintf(stderr, "Error, `--%s' argument given twice.\n",
1895
shell_options[shell_index].name);
1898
shell_seen[shell_index]=1;
1900
switch (shell_index) {
1902
shell_read_graph(&graph, optarg);
1905
shell_igraph_is_directed_usage(argv);
1914
/* Check that we have all arguments */
1915
for (shell_index=0; shell_index<1; shell_index++) {
1916
if (!shell_seen[shell_index]) {
1917
fprintf(stderr, "Error, argument missing: `--%s'.\n",
1918
shell_options[shell_index].name);
1923
/* Do the operation */
1924
shell_result=igraph_is_directed(&graph);
1926
/* Write the result */
1927
igraph_destroy(&graph);
1932
/*-------------------------------------------/
1934
/-------------------------------------------*/
1935
void shell_igraph_degree_usage(char **argv) {
1936
printf("%s --graph=<graph> --res=<res> --vids=<vids> --mode=<mode> --loops=<loops>\n", basename(argv[0]));
1940
int shell_igraph_degree(int argc, char **argv) {
1943
igraph_vector_t res;
1944
igraph_vector_t v_vids; igraph_vs_t vids=igraph_vss_all();
1945
igraph_neimode_t mode=IGRAPH_ALL;
1946
igraph_bool_t loops;
1947
char* shell_arg_res=0;
1953
struct option shell_options[]= { { "graph",required_argument,0,0 },
1954
{ "res",required_argument,0,1 },
1955
{ "vids",required_argument,0,2 },
1956
{ "mode",required_argument,0,3 },
1957
{ "loops",required_argument,0,4 },
1958
{ "help",no_argument,0,5 },
1962
/* 0 - not seen, 1 - seen as argument, 2 - seen as default */
1963
memset(shell_seen, 0, 5*sizeof(int));
1967
/* Parse arguments and read input */
1968
while (getopt_long(argc, argv, "", shell_options, &shell_index) != -1) {
1970
if (shell_index==-1) {
1974
if (shell_seen[shell_index]==1) {
1975
fprintf(stderr, "Error, `--%s' argument given twice.\n",
1976
shell_options[shell_index].name);
1979
shell_seen[shell_index]=1;
1981
switch (shell_index) {
1983
shell_read_graph(&graph, optarg);
1986
shell_arg_res=strdup(optarg);
1987
igraph_vector_init(&res, 0);
1990
shell_read_vector(&v_vids, optarg); igraph_vs_vector(&vids, &v_vids);
1993
shell_read_enum(&mode, optarg, "out", 1, "in", 2, "all", 3, "total", 3, 0);
1996
shell_read_boolean(&loops, optarg);
1999
shell_igraph_degree_usage(argv);
2008
/* Check that we have all arguments */
2009
for (shell_index=0; shell_index<5; shell_index++) {
2010
if (!shell_seen[shell_index]) {
2011
fprintf(stderr, "Error, argument missing: `--%s'.\n",
2012
shell_options[shell_index].name);
2017
/* Do the operation */
2018
shell_result=igraph_degree(&graph, &res, vids, mode, loops);
2020
/* Write the result */
2021
igraph_destroy(&graph);
2022
shell_write_vector(&res, shell_arg_res);
2023
igraph_vector_destroy(&res);
2024
if (!igraph_vs_is_all(&vids)) { igraph_vector_destroy(&v_vids); }
2029
/*-------------------------------------------/
2031
/-------------------------------------------*/
2032
void shell_igraph_edge_usage(char **argv) {
2033
printf("%s --graph=<graph> --eid=<eid> --from=<from> --to=<to>\n", basename(argv[0]));
2037
int shell_igraph_edge(int argc, char **argv) {
2040
igraph_integer_t eid;
2041
igraph_integer_t from;
2042
igraph_integer_t to;
2043
char* shell_arg_from=0;
2044
char* shell_arg_to=0;
2050
struct option shell_options[]= { { "graph",required_argument,0,0 },
2051
{ "eid",required_argument,0,1 },
2052
{ "from",required_argument,0,2 },
2053
{ "to",required_argument,0,3 },
2054
{ "help",no_argument,0,4 },
2058
/* 0 - not seen, 1 - seen as argument, 2 - seen as default */
2059
memset(shell_seen, 0, 4*sizeof(int));
2062
/* Parse arguments and read input */
2063
while (getopt_long(argc, argv, "", shell_options, &shell_index) != -1) {
2065
if (shell_index==-1) {
2069
if (shell_seen[shell_index]==1) {
2070
fprintf(stderr, "Error, `--%s' argument given twice.\n",
2071
shell_options[shell_index].name);
2074
shell_seen[shell_index]=1;
2076
switch (shell_index) {
2078
shell_read_graph(&graph, optarg);
2081
shell_read_integer(&eid, optarg);
2084
shell_arg_from=strdup(optarg);
2087
shell_arg_to=strdup(optarg);
2090
shell_igraph_edge_usage(argv);
2099
/* Check that we have all arguments */
2100
for (shell_index=0; shell_index<4; shell_index++) {
2101
if (!shell_seen[shell_index]) {
2102
fprintf(stderr, "Error, argument missing: `--%s'.\n",
2103
shell_options[shell_index].name);
2108
/* Do the operation */
2109
shell_result=igraph_edge(&graph, eid, &from, &to);
2111
/* Write the result */
2112
igraph_destroy(&graph);
2113
shell_write_integer(from, shell_arg_from);
2114
shell_write_integer(to, shell_arg_to);
2119
/*-------------------------------------------/
2121
/-------------------------------------------*/
2122
void shell_igraph_edges_usage(char **argv) {
2123
printf("%s --graph=<graph> --eids=<eids> --edges=<edges>\n", basename(argv[0]));
2127
int shell_igraph_edges(int argc, char **argv) {
2130
igraph_vector_t v_eids; igraph_es_t eids;
2131
igraph_vector_t edges;
2132
char* shell_arg_edges=0;
2138
struct option shell_options[]= { { "graph",required_argument,0,0 },
2139
{ "eids",required_argument,0,1 },
2140
{ "edges",required_argument,0,2 },
2141
{ "help",no_argument,0,3 },
2145
/* 0 - not seen, 1 - seen as argument, 2 - seen as default */
2146
memset(shell_seen, 0, 3*sizeof(int));
2149
/* Parse arguments and read input */
2150
while (getopt_long(argc, argv, "", shell_options, &shell_index) != -1) {
2152
if (shell_index==-1) {
2156
if (shell_seen[shell_index]==1) {
2157
fprintf(stderr, "Error, `--%s' argument given twice.\n",
2158
shell_options[shell_index].name);
2161
shell_seen[shell_index]=1;
2163
switch (shell_index) {
2165
shell_read_graph(&graph, optarg);
2168
shell_read_vector(&v_eids, optarg); igraph_es_vector(&eids, &v_eids);
2171
shell_arg_edges=strdup(optarg);
2172
igraph_vector_init(&edges, 0);
2175
shell_igraph_edges_usage(argv);
2184
/* Check that we have all arguments */
2185
for (shell_index=0; shell_index<3; shell_index++) {
2186
if (!shell_seen[shell_index]) {
2187
fprintf(stderr, "Error, argument missing: `--%s'.\n",
2188
shell_options[shell_index].name);
2193
/* Do the operation */
2194
shell_result=igraph_edges(&graph, eids, &edges);
2196
/* Write the result */
2197
igraph_destroy(&graph);
2198
if (!igraph_es_is_all(&eids)) { igraph_es_destroy(&eids); }
2199
shell_write_vector(&edges, shell_arg_edges);
2200
igraph_vector_destroy(&edges);
2205
/*-------------------------------------------/
2207
/-------------------------------------------*/
2208
void shell_igraph_get_eid_usage(char **argv) {
2209
printf("%s --graph=<graph> --eid=<eid> --from=<from> --to=<to> --directed=<directed>\n", basename(argv[0]));
2213
int shell_igraph_get_eid(int argc, char **argv) {
2216
igraph_integer_t eid;
2217
igraph_integer_t from;
2218
igraph_integer_t to;
2219
igraph_bool_t directed=1;
2220
char* shell_arg_eid=0;
2226
struct option shell_options[]= { { "graph",required_argument,0,0 },
2227
{ "eid",required_argument,0,1 },
2228
{ "from",required_argument,0,2 },
2229
{ "to",required_argument,0,3 },
2230
{ "directed",required_argument,0,4 },
2231
{ "help",no_argument,0,5 },
2235
/* 0 - not seen, 1 - seen as argument, 2 - seen as default */
2236
memset(shell_seen, 0, 5*sizeof(int));
2239
/* Parse arguments and read input */
2240
while (getopt_long(argc, argv, "", shell_options, &shell_index) != -1) {
2242
if (shell_index==-1) {
2246
if (shell_seen[shell_index]==1) {
2247
fprintf(stderr, "Error, `--%s' argument given twice.\n",
2248
shell_options[shell_index].name);
2251
shell_seen[shell_index]=1;
2253
switch (shell_index) {
2255
shell_read_graph(&graph, optarg);
2258
shell_arg_eid=strdup(optarg);
2261
shell_read_integer(&from, optarg);
2264
shell_read_integer(&to, optarg);
2266
case 4: /* directed */
2267
shell_read_boolean(&directed, optarg);
2270
shell_igraph_get_eid_usage(argv);
2279
/* Check that we have all arguments */
2280
for (shell_index=0; shell_index<5; shell_index++) {
2281
if (!shell_seen[shell_index]) {
2282
fprintf(stderr, "Error, argument missing: `--%s'.\n",
2283
shell_options[shell_index].name);
2288
/* Do the operation */
2289
shell_result=igraph_get_eid(&graph, &eid, from, to, directed);
2291
/* Write the result */
2292
igraph_destroy(&graph);
2293
shell_write_integer(eid, shell_arg_eid);
2298
/*-------------------------------------------/
2300
/-------------------------------------------*/
2301
void shell_igraph_get_eids_usage(char **argv) {
2302
printf("%s --graph=<graph> --eids=<eids> --pairs=<pairs> --directed=<directed>\n", basename(argv[0]));
2306
int shell_igraph_get_eids(int argc, char **argv) {
2309
igraph_vector_t eids;
2310
igraph_vector_t pairs;
2311
igraph_bool_t directed=1;
2312
char* shell_arg_eids=0;
2318
struct option shell_options[]= { { "graph",required_argument,0,0 },
2319
{ "eids",required_argument,0,1 },
2320
{ "pairs",required_argument,0,2 },
2321
{ "directed",required_argument,0,3 },
2322
{ "help",no_argument,0,4 },
2326
/* 0 - not seen, 1 - seen as argument, 2 - seen as default */
2327
memset(shell_seen, 0, 4*sizeof(int));
2330
/* Parse arguments and read input */
2331
while (getopt_long(argc, argv, "", shell_options, &shell_index) != -1) {
2333
if (shell_index==-1) {
2337
if (shell_seen[shell_index]==1) {
2338
fprintf(stderr, "Error, `--%s' argument given twice.\n",
2339
shell_options[shell_index].name);
2342
shell_seen[shell_index]=1;
2344
switch (shell_index) {
2346
shell_read_graph(&graph, optarg);
2349
shell_arg_eids=strdup(optarg);
2350
igraph_vector_init(&eids, 0);
2353
shell_read_vector(&pairs, optarg);
2355
case 3: /* directed */
2356
shell_read_boolean(&directed, optarg);
2359
shell_igraph_get_eids_usage(argv);
2368
/* Check that we have all arguments */
2369
for (shell_index=0; shell_index<4; shell_index++) {
2370
if (!shell_seen[shell_index]) {
2371
fprintf(stderr, "Error, argument missing: `--%s'.\n",
2372
shell_options[shell_index].name);
2377
/* Do the operation */
2378
shell_result=igraph_get_eids(&graph, &eids, &pairs, directed);
2380
/* Write the result */
2381
igraph_destroy(&graph);
2382
shell_write_vector(&eids, shell_arg_eids);
2383
igraph_vector_destroy(&eids);
2384
igraph_vector_destroy(&pairs);
2389
/*-------------------------------------------/
2391
/-------------------------------------------*/
2392
void shell_igraph_adjacent_usage(char **argv) {
2393
printf("%s --graph=<graph> --eids=<eids> --vid=<vid> --mode=<mode>\n", basename(argv[0]));
2397
int shell_igraph_adjacent(int argc, char **argv) {
2400
igraph_vector_t eids;
2401
igraph_integer_t vid;
2402
igraph_neimode_t mode=IGRAPH_ALL;
2403
char* shell_arg_eids=0;
2409
struct option shell_options[]= { { "graph",required_argument,0,0 },
2410
{ "eids",required_argument,0,1 },
2411
{ "vid",required_argument,0,2 },
2412
{ "mode",required_argument,0,3 },
2413
{ "help",no_argument,0,4 },
2417
/* 0 - not seen, 1 - seen as argument, 2 - seen as default */
2418
memset(shell_seen, 0, 4*sizeof(int));
2421
/* Parse arguments and read input */
2422
while (getopt_long(argc, argv, "", shell_options, &shell_index) != -1) {
2424
if (shell_index==-1) {
2428
if (shell_seen[shell_index]==1) {
2429
fprintf(stderr, "Error, `--%s' argument given twice.\n",
2430
shell_options[shell_index].name);
2433
shell_seen[shell_index]=1;
2435
switch (shell_index) {
2437
shell_read_graph(&graph, optarg);
2440
shell_arg_eids=strdup(optarg);
2441
igraph_vector_init(&eids, 0);
2444
shell_read_integer(&vid, optarg);
2447
shell_read_enum(&mode, optarg, "out", 1, "in", 2, "all", 3, "total", 3, 0);
2450
shell_igraph_adjacent_usage(argv);
2459
/* Check that we have all arguments */
2460
for (shell_index=0; shell_index<4; shell_index++) {
2461
if (!shell_seen[shell_index]) {
2462
fprintf(stderr, "Error, argument missing: `--%s'.\n",
2463
shell_options[shell_index].name);
2468
/* Do the operation */
2469
shell_result=igraph_adjacent(&graph, &eids, vid, mode);
2471
/* Write the result */
2472
igraph_destroy(&graph);
2473
shell_write_vector(&eids, shell_arg_eids);
2474
igraph_vector_destroy(&eids);
2479
/*-------------------------------------------/
2481
/-------------------------------------------*/
2482
void shell_igraph_create_usage(char **argv) {
2483
printf("%s --graph=<graph> --edges=<edges> --n=<n> --directed=<directed>\n", basename(argv[0]));
2487
int shell_igraph_create(int argc, char **argv) {
2490
igraph_vector_t edges;
2491
igraph_integer_t n=0;
2492
igraph_bool_t directed=1;
2493
char* shell_arg_graph=0;
2499
struct option shell_options[]= { { "graph",required_argument,0,0 },
2500
{ "edges",required_argument,0,1 },
2501
{ "n",required_argument,0,2 },
2502
{ "directed",required_argument,0,3 },
2503
{ "help",no_argument,0,4 },
2507
/* 0 - not seen, 1 - seen as argument, 2 - seen as default */
2508
memset(shell_seen, 0, 4*sizeof(int));
2512
/* Parse arguments and read input */
2513
while (getopt_long(argc, argv, "", shell_options, &shell_index) != -1) {
2515
if (shell_index==-1) {
2519
if (shell_seen[shell_index]==1) {
2520
fprintf(stderr, "Error, `--%s' argument given twice.\n",
2521
shell_options[shell_index].name);
2524
shell_seen[shell_index]=1;
2526
switch (shell_index) {
2528
shell_arg_graph=strdup(optarg);
2531
shell_read_vector(&edges, optarg);
2534
shell_read_integer(&n, optarg);
2536
case 3: /* directed */
2537
shell_read_boolean(&directed, optarg);
2540
shell_igraph_create_usage(argv);
2549
/* Check that we have all arguments */
2550
for (shell_index=0; shell_index<4; shell_index++) {
2551
if (!shell_seen[shell_index]) {
2552
fprintf(stderr, "Error, argument missing: `--%s'.\n",
2553
shell_options[shell_index].name);
2558
/* Do the operation */
2559
shell_result=igraph_create(&graph, &edges, n, directed);
2561
/* Write the result */
2562
shell_write_graph(&graph, shell_arg_graph);
2563
igraph_destroy(&graph);
2564
igraph_vector_destroy(&edges);
2569
/*-------------------------------------------/
2570
/ igraph_adjacency /
2571
/-------------------------------------------*/
2572
void shell_igraph_adjacency_usage(char **argv) {
2573
printf("%s --graph=<graph> --adjmatrix=<adjmatrix> --mode=<mode>\n", basename(argv[0]));
2577
int shell_igraph_adjacency(int argc, char **argv) {
2580
igraph_matrix_t adjmatrix;
2581
igraph_adjacency_t mode=IGRAPH_ADJ_DIRECTED;
2582
char* shell_arg_graph=0;
2588
struct option shell_options[]= { { "graph",required_argument,0,0 },
2589
{ "adjmatrix",required_argument,0,1 },
2590
{ "mode",required_argument,0,2 },
2591
{ "help",no_argument,0,3 },
2595
/* 0 - not seen, 1 - seen as argument, 2 - seen as default */
2596
memset(shell_seen, 0, 3*sizeof(int));
2599
/* Parse arguments and read input */
2600
while (getopt_long(argc, argv, "", shell_options, &shell_index) != -1) {
2602
if (shell_index==-1) {
2606
if (shell_seen[shell_index]==1) {
2607
fprintf(stderr, "Error, `--%s' argument given twice.\n",
2608
shell_options[shell_index].name);
2611
shell_seen[shell_index]=1;
2613
switch (shell_index) {
2615
shell_arg_graph=strdup(optarg);
2617
case 1: /* adjmatrix */
2618
shell_read_matrix(&adjmatrix, optarg);
2621
shell_read_enum(&mode, optarg, "directed", 0, "undirected", 1,
2622
"max", 1, "upper", 2, "lower", 3, "min", 4, "plus", 5, 0);
2625
shell_igraph_adjacency_usage(argv);
2634
/* Check that we have all arguments */
2635
for (shell_index=0; shell_index<3; shell_index++) {
2636
if (!shell_seen[shell_index]) {
2637
fprintf(stderr, "Error, argument missing: `--%s'.\n",
2638
shell_options[shell_index].name);
2643
/* Do the operation */
2644
shell_result=igraph_adjacency(&graph, &adjmatrix, mode);
2646
/* Write the result */
2647
shell_write_graph(&graph, shell_arg_graph);
2648
igraph_destroy(&graph);
2649
igraph_matrix_destroy(&adjmatrix);
2654
/*-------------------------------------------/
2656
/-------------------------------------------*/
2657
void shell_igraph_star_usage(char **argv) {
2658
printf("%s --graph=<graph> --n=<n> --mode=<mode> --center=<center>\n", basename(argv[0]));
2662
int shell_igraph_star(int argc, char **argv) {
2666
igraph_star_mode_t mode=IGRAPH_STAR_OUT;
2667
igraph_integer_t center=0;
2668
char* shell_arg_graph=0;
2674
struct option shell_options[]= { { "graph",required_argument,0,0 },
2675
{ "n",required_argument,0,1 },
2676
{ "mode",required_argument,0,2 },
2677
{ "center",required_argument,0,3 },
2678
{ "help",no_argument,0,4 },
2682
/* 0 - not seen, 1 - seen as argument, 2 - seen as default */
2683
memset(shell_seen, 0, 4*sizeof(int));
2687
/* Parse arguments and read input */
2688
while (getopt_long(argc, argv, "", shell_options, &shell_index) != -1) {
2690
if (shell_index==-1) {
2694
if (shell_seen[shell_index]==1) {
2695
fprintf(stderr, "Error, `--%s' argument given twice.\n",
2696
shell_options[shell_index].name);
2699
shell_seen[shell_index]=1;
2701
switch (shell_index) {
2703
shell_arg_graph=strdup(optarg);
2706
shell_read_integer(&n, optarg);
2709
shell_read_enum(&mode, optarg, "out", 0, "in", 1, "undirected", 2, 0);
2711
case 3: /* center */
2712
shell_read_integer(¢er, optarg);
2715
shell_igraph_star_usage(argv);
2724
/* Check that we have all arguments */
2725
for (shell_index=0; shell_index<4; shell_index++) {
2726
if (!shell_seen[shell_index]) {
2727
fprintf(stderr, "Error, argument missing: `--%s'.\n",
2728
shell_options[shell_index].name);
2733
/* Do the operation */
2734
shell_result=igraph_star(&graph, n, mode, center);
2736
/* Write the result */
2737
shell_write_graph(&graph, shell_arg_graph);
2738
igraph_destroy(&graph);
2743
/*-------------------------------------------/
2745
/-------------------------------------------*/
2746
void shell_igraph_lattice_usage(char **argv) {
2747
printf("%s --graph=<graph> --dimvector=<dimvector> --nei=<nei> --directed=<directed> --mutual=<mutual> --circular=<circular>\n", basename(argv[0]));
2751
int shell_igraph_lattice(int argc, char **argv) {
2754
igraph_vector_t dimvector;
2755
igraph_integer_t nei=1;
2756
igraph_bool_t directed=0;
2757
igraph_bool_t mutual=0;
2758
igraph_bool_t circular=0;
2759
char* shell_arg_graph=0;
2765
struct option shell_options[]= { { "graph",required_argument,0,0 },
2766
{ "dimvector",required_argument,0,1 },
2767
{ "nei",required_argument,0,2 },
2768
{ "directed",required_argument,0,3 },
2769
{ "mutual",required_argument,0,4 },
2770
{ "circular",required_argument,0,5 },
2771
{ "help",no_argument,0,6 },
2775
/* 0 - not seen, 1 - seen as argument, 2 - seen as default */
2776
memset(shell_seen, 0, 6*sizeof(int));
2782
/* Parse arguments and read input */
2783
while (getopt_long(argc, argv, "", shell_options, &shell_index) != -1) {
2785
if (shell_index==-1) {
2789
if (shell_seen[shell_index]==1) {
2790
fprintf(stderr, "Error, `--%s' argument given twice.\n",
2791
shell_options[shell_index].name);
2794
shell_seen[shell_index]=1;
2796
switch (shell_index) {
2798
shell_arg_graph=strdup(optarg);
2800
case 1: /* dimvector */
2801
shell_read_vector(&dimvector, optarg);
2804
shell_read_integer(&nei, optarg);
2806
case 3: /* directed */
2807
shell_read_boolean(&directed, optarg);
2809
case 4: /* mutual */
2810
shell_read_boolean(&mutual, optarg);
2812
case 5: /* circular */
2813
shell_read_boolean(&circular, optarg);
2816
shell_igraph_lattice_usage(argv);
2825
/* Check that we have all arguments */
2826
for (shell_index=0; shell_index<6; shell_index++) {
2827
if (!shell_seen[shell_index]) {
2828
fprintf(stderr, "Error, argument missing: `--%s'.\n",
2829
shell_options[shell_index].name);
2834
/* Do the operation */
2835
shell_result=igraph_lattice(&graph, &dimvector, nei, directed, mutual, circular);
2837
/* Write the result */
2838
shell_write_graph(&graph, shell_arg_graph);
2839
igraph_destroy(&graph);
2840
igraph_vector_destroy(&dimvector);
2845
/*-------------------------------------------/
2847
/-------------------------------------------*/
2848
void shell_igraph_ring_usage(char **argv) {
2849
printf("%s --graph=<graph> --n=<n> --directed=<directed> --mutual=<mutual> --circular=<circular>\n", basename(argv[0]));
2853
int shell_igraph_ring(int argc, char **argv) {
2857
igraph_bool_t directed=0;
2858
igraph_bool_t mutual=0;
2859
igraph_bool_t circular=1;
2860
char* shell_arg_graph=0;
2866
struct option shell_options[]= { { "graph",required_argument,0,0 },
2867
{ "n",required_argument,0,1 },
2868
{ "directed",required_argument,0,2 },
2869
{ "mutual",required_argument,0,3 },
2870
{ "circular",required_argument,0,4 },
2871
{ "help",no_argument,0,5 },
2875
/* 0 - not seen, 1 - seen as argument, 2 - seen as default */
2876
memset(shell_seen, 0, 5*sizeof(int));
2881
/* Parse arguments and read input */
2882
while (getopt_long(argc, argv, "", shell_options, &shell_index) != -1) {
2884
if (shell_index==-1) {
2888
if (shell_seen[shell_index]==1) {
2889
fprintf(stderr, "Error, `--%s' argument given twice.\n",
2890
shell_options[shell_index].name);
2893
shell_seen[shell_index]=1;
2895
switch (shell_index) {
2897
shell_arg_graph=strdup(optarg);
2900
shell_read_integer(&n, optarg);
2902
case 2: /* directed */
2903
shell_read_boolean(&directed, optarg);
2905
case 3: /* mutual */
2906
shell_read_boolean(&mutual, optarg);
2908
case 4: /* circular */
2909
shell_read_boolean(&circular, optarg);
2912
shell_igraph_ring_usage(argv);
2921
/* Check that we have all arguments */
2922
for (shell_index=0; shell_index<5; shell_index++) {
2923
if (!shell_seen[shell_index]) {
2924
fprintf(stderr, "Error, argument missing: `--%s'.\n",
2925
shell_options[shell_index].name);
2930
/* Do the operation */
2931
shell_result=igraph_ring(&graph, n, directed, mutual, circular);
2933
/* Write the result */
2934
shell_write_graph(&graph, shell_arg_graph);
2935
igraph_destroy(&graph);
2940
/*-------------------------------------------/
2942
/-------------------------------------------*/
2943
void shell_igraph_tree_usage(char **argv) {
2944
printf("%s --graph=<graph> --n=<n> --children=<children> --type=<type>\n", basename(argv[0]));
2948
int shell_igraph_tree(int argc, char **argv) {
2952
igraph_integer_t children=2;
2953
igraph_tree_mode_t type=IGRAPH_TREE_OUT;
2954
char* shell_arg_graph=0;
2960
struct option shell_options[]= { { "graph",required_argument,0,0 },
2961
{ "n",required_argument,0,1 },
2962
{ "children",required_argument,0,2 },
2963
{ "type",required_argument,0,3 },
2964
{ "help",no_argument,0,4 },
2968
/* 0 - not seen, 1 - seen as argument, 2 - seen as default */
2969
memset(shell_seen, 0, 4*sizeof(int));
2973
/* Parse arguments and read input */
2974
while (getopt_long(argc, argv, "", shell_options, &shell_index) != -1) {
2976
if (shell_index==-1) {
2980
if (shell_seen[shell_index]==1) {
2981
fprintf(stderr, "Error, `--%s' argument given twice.\n",
2982
shell_options[shell_index].name);
2985
shell_seen[shell_index]=1;
2987
switch (shell_index) {
2989
shell_arg_graph=strdup(optarg);
2992
shell_read_integer(&n, optarg);
2994
case 2: /* children */
2995
shell_read_integer(&children, optarg);
2998
shell_read_enum(&type, optarg, "out", 0, "in", 1, "undirected", 2, 0);
3001
shell_igraph_tree_usage(argv);
3010
/* Check that we have all arguments */
3011
for (shell_index=0; shell_index<4; shell_index++) {
3012
if (!shell_seen[shell_index]) {
3013
fprintf(stderr, "Error, argument missing: `--%s'.\n",
3014
shell_options[shell_index].name);
3019
/* Do the operation */
3020
shell_result=igraph_tree(&graph, n, children, type);
3022
/* Write the result */
3023
shell_write_graph(&graph, shell_arg_graph);
3024
igraph_destroy(&graph);
3029
/*-------------------------------------------/
3031
/-------------------------------------------*/
3032
void shell_igraph_full_usage(char **argv) {
3033
printf("%s --graph=<graph> --n=<n> --directed=<directed> --loops=<loops>\n", basename(argv[0]));
3037
int shell_igraph_full(int argc, char **argv) {
3041
igraph_bool_t directed=0;
3042
igraph_bool_t loops=0;
3043
char* shell_arg_graph=0;
3049
struct option shell_options[]= { { "graph",required_argument,0,0 },
3050
{ "n",required_argument,0,1 },
3051
{ "directed",required_argument,0,2 },
3052
{ "loops",required_argument,0,3 },
3053
{ "help",no_argument,0,4 },
3057
/* 0 - not seen, 1 - seen as argument, 2 - seen as default */
3058
memset(shell_seen, 0, 4*sizeof(int));
3062
/* Parse arguments and read input */
3063
while (getopt_long(argc, argv, "", shell_options, &shell_index) != -1) {
3065
if (shell_index==-1) {
3069
if (shell_seen[shell_index]==1) {
3070
fprintf(stderr, "Error, `--%s' argument given twice.\n",
3071
shell_options[shell_index].name);
3074
shell_seen[shell_index]=1;
3076
switch (shell_index) {
3078
shell_arg_graph=strdup(optarg);
3081
shell_read_integer(&n, optarg);
3083
case 2: /* directed */
3084
shell_read_boolean(&directed, optarg);
3087
shell_read_boolean(&loops, optarg);
3090
shell_igraph_full_usage(argv);
3099
/* Check that we have all arguments */
3100
for (shell_index=0; shell_index<4; shell_index++) {
3101
if (!shell_seen[shell_index]) {
3102
fprintf(stderr, "Error, argument missing: `--%s'.\n",
3103
shell_options[shell_index].name);
3108
/* Do the operation */
3109
shell_result=igraph_full(&graph, n, directed, loops);
3111
/* Write the result */
3112
shell_write_graph(&graph, shell_arg_graph);
3113
igraph_destroy(&graph);
3118
/*-------------------------------------------/
3119
/ igraph_full_citation /
3120
/-------------------------------------------*/
3121
void shell_igraph_full_citation_usage(char **argv) {
3122
printf("%s --graph=<graph> --n=<n> --directed=<directed>\n", basename(argv[0]));
3126
int shell_igraph_full_citation(int argc, char **argv) {
3130
igraph_bool_t directed=1;
3131
char* shell_arg_graph=0;
3137
struct option shell_options[]= { { "graph",required_argument,0,0 },
3138
{ "n",required_argument,0,1 },
3139
{ "directed",required_argument,0,2 },
3140
{ "help",no_argument,0,3 },
3144
/* 0 - not seen, 1 - seen as argument, 2 - seen as default */
3145
memset(shell_seen, 0, 3*sizeof(int));
3148
/* Parse arguments and read input */
3149
while (getopt_long(argc, argv, "", shell_options, &shell_index) != -1) {
3151
if (shell_index==-1) {
3155
if (shell_seen[shell_index]==1) {
3156
fprintf(stderr, "Error, `--%s' argument given twice.\n",
3157
shell_options[shell_index].name);
3160
shell_seen[shell_index]=1;
3162
switch (shell_index) {
3164
shell_arg_graph=strdup(optarg);
3167
shell_read_integer(&n, optarg);
3169
case 2: /* directed */
3170
shell_read_boolean(&directed, optarg);
3173
shell_igraph_full_citation_usage(argv);
3182
/* Check that we have all arguments */
3183
for (shell_index=0; shell_index<3; shell_index++) {
3184
if (!shell_seen[shell_index]) {
3185
fprintf(stderr, "Error, argument missing: `--%s'.\n",
3186
shell_options[shell_index].name);
3191
/* Do the operation */
3192
shell_result=igraph_full_citation(&graph, n, directed);
3194
/* Write the result */
3195
shell_write_graph(&graph, shell_arg_graph);
3196
igraph_destroy(&graph);
3201
/*-------------------------------------------/
3203
/-------------------------------------------*/
3204
void shell_igraph_atlas_usage(char **argv) {
3205
printf("%s --graph=<graph> --number=<number>\n", basename(argv[0]));
3209
int shell_igraph_atlas(int argc, char **argv) {
3213
char* shell_arg_graph=0;
3219
struct option shell_options[]= { { "graph",required_argument,0,0 },
3220
{ "number",required_argument,0,1 },
3221
{ "help",no_argument,0,2 },
3225
/* 0 - not seen, 1 - seen as argument, 2 - seen as default */
3226
memset(shell_seen, 0, 2*sizeof(int));
3229
/* Parse arguments and read input */
3230
while (getopt_long(argc, argv, "", shell_options, &shell_index) != -1) {
3232
if (shell_index==-1) {
3236
if (shell_seen[shell_index]==1) {
3237
fprintf(stderr, "Error, `--%s' argument given twice.\n",
3238
shell_options[shell_index].name);
3241
shell_seen[shell_index]=1;
3243
switch (shell_index) {
3245
shell_arg_graph=strdup(optarg);
3247
case 1: /* number */
3248
shell_read_int(&number, optarg);
3251
shell_igraph_atlas_usage(argv);
3260
/* Check that we have all arguments */
3261
for (shell_index=0; shell_index<2; shell_index++) {
3262
if (!shell_seen[shell_index]) {
3263
fprintf(stderr, "Error, argument missing: `--%s'.\n",
3264
shell_options[shell_index].name);
3269
/* Do the operation */
3270
shell_result=igraph_atlas(&graph, number);
3272
/* Write the result */
3273
shell_write_graph(&graph, shell_arg_graph);
3274
igraph_destroy(&graph);
3279
/*-------------------------------------------/
3280
/ igraph_extended_chordal_ring /
3281
/-------------------------------------------*/
3282
void shell_igraph_extended_chordal_ring_usage(char **argv) {
3283
printf("%s --graph=<graph> --nodes=<nodes> --W=<W>\n", basename(argv[0]));
3287
int shell_igraph_extended_chordal_ring(int argc, char **argv) {
3290
igraph_integer_t nodes;
3292
char* shell_arg_graph=0;
3298
struct option shell_options[]= { { "graph",required_argument,0,0 },
3299
{ "nodes",required_argument,0,1 },
3300
{ "W",required_argument,0,2 },
3301
{ "help",no_argument,0,3 },
3305
/* 0 - not seen, 1 - seen as argument, 2 - seen as default */
3306
memset(shell_seen, 0, 3*sizeof(int));
3309
/* Parse arguments and read input */
3310
while (getopt_long(argc, argv, "", shell_options, &shell_index) != -1) {
3312
if (shell_index==-1) {
3316
if (shell_seen[shell_index]==1) {
3317
fprintf(stderr, "Error, `--%s' argument given twice.\n",
3318
shell_options[shell_index].name);
3321
shell_seen[shell_index]=1;
3323
switch (shell_index) {
3325
shell_arg_graph=strdup(optarg);
3328
shell_read_integer(&nodes, optarg);
3331
shell_read_matrix(&W, optarg);
3334
shell_igraph_extended_chordal_ring_usage(argv);
3343
/* Check that we have all arguments */
3344
for (shell_index=0; shell_index<3; shell_index++) {
3345
if (!shell_seen[shell_index]) {
3346
fprintf(stderr, "Error, argument missing: `--%s'.\n",
3347
shell_options[shell_index].name);
3352
/* Do the operation */
3353
shell_result=igraph_extended_chordal_ring(&graph, nodes, &W);
3355
/* Write the result */
3356
shell_write_graph(&graph, shell_arg_graph);
3357
igraph_destroy(&graph);
3358
igraph_matrix_destroy(&W);
3363
/*-------------------------------------------/
3364
/ igraph_connect_neighborhood /
3365
/-------------------------------------------*/
3366
void shell_igraph_connect_neighborhood_usage(char **argv) {
3367
printf("%s --graph=<graph> --graph-out=<graph-out> --order=<order> --mode=<mode>\n", basename(argv[0]));
3371
int shell_igraph_connect_neighborhood(int argc, char **argv) {
3374
igraph_integer_t order=2;
3375
igraph_neimode_t mode=IGRAPH_ALL;
3376
char* shell_arg_graph=0;
3382
struct option shell_options[]= { { "graph",required_argument,0,0 },
3383
{ "graph-out",required_argument,0,1 },
3384
{ "order",required_argument,0,2 },
3385
{ "mode",required_argument,0,3 },
3386
{ "help",no_argument,0,4 },
3390
/* 0 - not seen, 1 - seen as argument, 2 - seen as default */
3391
memset(shell_seen, 0, 4*sizeof(int));
3395
/* Parse arguments and read input */
3396
while (getopt_long(argc, argv, "", shell_options, &shell_index) != -1) {
3398
if (shell_index==-1) {
3402
if (shell_seen[shell_index]==1) {
3403
fprintf(stderr, "Error, `--%s' argument given twice.\n",
3404
shell_options[shell_index].name);
3407
shell_seen[shell_index]=1;
3409
switch (shell_index) {
3411
shell_read_graph(&graph, optarg);
3413
case 1: /* graph-out */
3414
shell_arg_graph=strdup(optarg);
3417
shell_read_integer(&order, optarg);
3420
shell_read_enum(&mode, optarg, "out", 1, "in", 2, "all", 3, "total", 3, 0);
3423
shell_igraph_connect_neighborhood_usage(argv);
3432
/* Check that we have all arguments */
3433
for (shell_index=0; shell_index<4; shell_index++) {
3434
if (!shell_seen[shell_index]) {
3435
fprintf(stderr, "Error, argument missing: `--%s'.\n",
3436
shell_options[shell_index].name);
3441
/* Do the operation */
3442
shell_result=igraph_connect_neighborhood(&graph, order, mode);
3444
/* Write the result */
3445
igraph_destroy(&graph);
3446
shell_write_graph(&graph, shell_arg_graph);
3447
igraph_destroy(&graph);
3452
/*-------------------------------------------/
3453
/ igraph_linegraph /
3454
/-------------------------------------------*/
3455
void shell_igraph_linegraph_usage(char **argv) {
3456
printf("%s --graph=<graph> --linegraph=<linegraph>\n", basename(argv[0]));
3460
int shell_igraph_linegraph(int argc, char **argv) {
3464
char* shell_arg_linegraph=0;
3470
struct option shell_options[]= { { "graph",required_argument,0,0 },
3471
{ "linegraph",required_argument,0,1 },
3472
{ "help",no_argument,0,2 },
3476
/* 0 - not seen, 1 - seen as argument, 2 - seen as default */
3477
memset(shell_seen, 0, 2*sizeof(int));
3480
/* Parse arguments and read input */
3481
while (getopt_long(argc, argv, "", shell_options, &shell_index) != -1) {
3483
if (shell_index==-1) {
3487
if (shell_seen[shell_index]==1) {
3488
fprintf(stderr, "Error, `--%s' argument given twice.\n",
3489
shell_options[shell_index].name);
3492
shell_seen[shell_index]=1;
3494
switch (shell_index) {
3496
shell_read_graph(&graph, optarg);
3498
case 1: /* linegraph */
3499
shell_arg_linegraph=strdup(optarg);
3502
shell_igraph_linegraph_usage(argv);
3511
/* Check that we have all arguments */
3512
for (shell_index=0; shell_index<2; shell_index++) {
3513
if (!shell_seen[shell_index]) {
3514
fprintf(stderr, "Error, argument missing: `--%s'.\n",
3515
shell_options[shell_index].name);
3520
/* Do the operation */
3521
shell_result=igraph_linegraph(&graph, &linegraph);
3523
/* Write the result */
3524
igraph_destroy(&graph);
3525
shell_write_graph(&linegraph, shell_arg_linegraph);
3526
igraph_destroy(&linegraph);
3531
/*-------------------------------------------/
3532
/ igraph_de_bruijn /
3533
/-------------------------------------------*/
3534
void shell_igraph_de_bruijn_usage(char **argv) {
3535
printf("%s --graph=<graph> --m=<m> --n=<n>\n", basename(argv[0]));
3539
int shell_igraph_de_bruijn(int argc, char **argv) {
3544
char* shell_arg_graph=0;
3550
struct option shell_options[]= { { "graph",required_argument,0,0 },
3551
{ "m",required_argument,0,1 },
3552
{ "n",required_argument,0,2 },
3553
{ "help",no_argument,0,3 },
3557
/* 0 - not seen, 1 - seen as argument, 2 - seen as default */
3558
memset(shell_seen, 0, 3*sizeof(int));
3561
/* Parse arguments and read input */
3562
while (getopt_long(argc, argv, "", shell_options, &shell_index) != -1) {
3564
if (shell_index==-1) {
3568
if (shell_seen[shell_index]==1) {
3569
fprintf(stderr, "Error, `--%s' argument given twice.\n",
3570
shell_options[shell_index].name);
3573
shell_seen[shell_index]=1;
3575
switch (shell_index) {
3577
shell_arg_graph=strdup(optarg);
3580
shell_read_integer(&m, optarg);
3583
shell_read_integer(&n, optarg);
3586
shell_igraph_de_bruijn_usage(argv);
3595
/* Check that we have all arguments */
3596
for (shell_index=0; shell_index<3; shell_index++) {
3597
if (!shell_seen[shell_index]) {
3598
fprintf(stderr, "Error, argument missing: `--%s'.\n",
3599
shell_options[shell_index].name);
3604
/* Do the operation */
3605
shell_result=igraph_de_bruijn(&graph, m, n);
3607
/* Write the result */
3608
shell_write_graph(&graph, shell_arg_graph);
3609
igraph_destroy(&graph);
3614
/*-------------------------------------------/
3616
/-------------------------------------------*/
3617
void shell_igraph_kautz_usage(char **argv) {
3618
printf("%s --graph=<graph> --m=<m> --n=<n>\n", basename(argv[0]));
3622
int shell_igraph_kautz(int argc, char **argv) {
3627
char* shell_arg_graph=0;
3633
struct option shell_options[]= { { "graph",required_argument,0,0 },
3634
{ "m",required_argument,0,1 },
3635
{ "n",required_argument,0,2 },
3636
{ "help",no_argument,0,3 },
3640
/* 0 - not seen, 1 - seen as argument, 2 - seen as default */
3641
memset(shell_seen, 0, 3*sizeof(int));
3644
/* Parse arguments and read input */
3645
while (getopt_long(argc, argv, "", shell_options, &shell_index) != -1) {
3647
if (shell_index==-1) {
3651
if (shell_seen[shell_index]==1) {
3652
fprintf(stderr, "Error, `--%s' argument given twice.\n",
3653
shell_options[shell_index].name);
3656
shell_seen[shell_index]=1;
3658
switch (shell_index) {
3660
shell_arg_graph=strdup(optarg);
3663
shell_read_integer(&m, optarg);
3666
shell_read_integer(&n, optarg);
3669
shell_igraph_kautz_usage(argv);
3678
/* Check that we have all arguments */
3679
for (shell_index=0; shell_index<3; shell_index++) {
3680
if (!shell_seen[shell_index]) {
3681
fprintf(stderr, "Error, argument missing: `--%s'.\n",
3682
shell_options[shell_index].name);
3687
/* Do the operation */
3688
shell_result=igraph_kautz(&graph, m, n);
3690
/* Write the result */
3691
shell_write_graph(&graph, shell_arg_graph);
3692
igraph_destroy(&graph);
3697
/*-------------------------------------------/
3699
/-------------------------------------------*/
3700
void shell_igraph_famous_usage(char **argv) {
3701
printf("%s --graph=<graph> --name=<name>\n", basename(argv[0]));
3705
int shell_igraph_famous(int argc, char **argv) {
3709
char* shell_arg_graph=0;
3715
struct option shell_options[]= { { "graph",required_argument,0,0 },
3716
{ "name",required_argument,0,1 },
3717
{ "help",no_argument,0,2 },
3721
/* 0 - not seen, 1 - seen as argument, 2 - seen as default */
3722
memset(shell_seen, 0, 2*sizeof(int));
3725
/* Parse arguments and read input */
3726
while (getopt_long(argc, argv, "", shell_options, &shell_index) != -1) {
3728
if (shell_index==-1) {
3732
if (shell_seen[shell_index]==1) {
3733
fprintf(stderr, "Error, `--%s' argument given twice.\n",
3734
shell_options[shell_index].name);
3737
shell_seen[shell_index]=1;
3739
switch (shell_index) {
3741
shell_arg_graph=strdup(optarg);
3744
name=strdup(optarg);
3747
shell_igraph_famous_usage(argv);
3756
/* Check that we have all arguments */
3757
for (shell_index=0; shell_index<2; shell_index++) {
3758
if (!shell_seen[shell_index]) {
3759
fprintf(stderr, "Error, argument missing: `--%s'.\n",
3760
shell_options[shell_index].name);
3765
/* Do the operation */
3766
shell_result=igraph_famous(&graph, name);
3768
/* Write the result */
3769
shell_write_graph(&graph, shell_arg_graph);
3770
igraph_destroy(&graph);
3776
/*-------------------------------------------/
3777
/ igraph_lcf_vector /
3778
/-------------------------------------------*/
3779
void shell_igraph_lcf_vector_usage(char **argv) {
3780
printf("%s --graph=<graph> --n=<n> --shifts=<shifts> --repeats=<repeats>\n", basename(argv[0]));
3784
int shell_igraph_lcf_vector(int argc, char **argv) {
3788
igraph_vector_t shifts;
3789
igraph_integer_t repeats=1;
3790
char* shell_arg_graph=0;
3796
struct option shell_options[]= { { "graph",required_argument,0,0 },
3797
{ "n",required_argument,0,1 },
3798
{ "shifts",required_argument,0,2 },
3799
{ "repeats",required_argument,0,3 },
3800
{ "help",no_argument,0,4 },
3804
/* 0 - not seen, 1 - seen as argument, 2 - seen as default */
3805
memset(shell_seen, 0, 4*sizeof(int));
3808
/* Parse arguments and read input */
3809
while (getopt_long(argc, argv, "", shell_options, &shell_index) != -1) {
3811
if (shell_index==-1) {
3815
if (shell_seen[shell_index]==1) {
3816
fprintf(stderr, "Error, `--%s' argument given twice.\n",
3817
shell_options[shell_index].name);
3820
shell_seen[shell_index]=1;
3822
switch (shell_index) {
3824
shell_arg_graph=strdup(optarg);
3827
shell_read_integer(&n, optarg);
3829
case 2: /* shifts */
3830
shell_read_vector(&shifts, optarg);
3832
case 3: /* repeats */
3833
shell_read_integer(&repeats, optarg);
3836
shell_igraph_lcf_vector_usage(argv);
3845
/* Check that we have all arguments */
3846
for (shell_index=0; shell_index<4; shell_index++) {
3847
if (!shell_seen[shell_index]) {
3848
fprintf(stderr, "Error, argument missing: `--%s'.\n",
3849
shell_options[shell_index].name);
3854
/* Do the operation */
3855
shell_result=igraph_lcf_vector(&graph, n, &shifts, repeats);
3857
/* Write the result */
3858
shell_write_graph(&graph, shell_arg_graph);
3859
igraph_destroy(&graph);
3860
igraph_vector_destroy(&shifts);
3865
/*-------------------------------------------/
3867
/-------------------------------------------*/
3868
void shell_igraph_adjlist_usage(char **argv) {
3869
printf("%s --graph=<graph> --directed=<directed> --duplicate=<duplicate>\n", basename(argv[0]));
3873
int shell_igraph_adjlist(int argc, char **argv) {
3877
igraph_bool_t directed=1;
3878
igraph_bool_t duplicate=1;
3879
char* shell_arg_graph=0;
3885
struct option shell_options[]= { { "graph",required_argument,0,0 },
3886
{ "directed",required_argument,0,1 },
3887
{ "duplicate",required_argument,0,2 },
3888
{ "help",no_argument,0,3 },
3892
/* 0 - not seen, 1 - seen as argument, 2 - seen as default */
3893
memset(shell_seen, 0, 3*sizeof(int));
3897
/* Parse arguments and read input */
3898
while (getopt_long(argc, argv, "", shell_options, &shell_index) != -1) {
3900
if (shell_index==-1) {
3904
if (shell_seen[shell_index]==1) {
3905
fprintf(stderr, "Error, `--%s' argument given twice.\n",
3906
shell_options[shell_index].name);
3909
shell_seen[shell_index]=1;
3911
switch (shell_index) {
3913
shell_arg_graph=strdup(optarg);
3915
case 1: /* directed */
3916
shell_read_boolean(&directed, optarg);
3918
case 2: /* duplicate */
3919
shell_read_boolean(&duplicate, optarg);
3922
shell_igraph_adjlist_usage(argv);
3931
/* Check that we have all arguments */
3932
for (shell_index=0; shell_index<3; shell_index++) {
3933
if (!shell_seen[shell_index]) {
3934
fprintf(stderr, "Error, argument missing: `--%s'.\n",
3935
shell_options[shell_index].name);
3940
/* Do the operation */
3941
shell_result=igraph_adjlist(&graph, adjlist, directed, duplicate);
3943
/* Write the result */
3944
shell_write_graph(&graph, shell_arg_graph);
3945
igraph_destroy(&graph);
3950
/*-------------------------------------------/
3951
/ igraph_full_bipartite /
3952
/-------------------------------------------*/
3953
void shell_igraph_full_bipartite_usage(char **argv) {
3954
printf("%s --graph=<graph> --n1=<n1> --n2=<n2> --directed=<directed> --mode=<mode>\n", basename(argv[0]));
3958
int shell_igraph_full_bipartite(int argc, char **argv) {
3962
igraph_integer_t n1;
3963
igraph_integer_t n2;
3964
igraph_bool_t directed=0;
3965
igraph_neimode_t mode=IGRAPH_ALL;
3966
char* shell_arg_graph=0;
3967
char* shell_arg_types=0;
3973
struct option shell_options[]= { { "graph",required_argument,0,0 },
3974
{ "n1",required_argument,0,1 },
3975
{ "n2",required_argument,0,2 },
3976
{ "directed",required_argument,0,3 },
3977
{ "mode",required_argument,0,4 },
3978
{ "help",no_argument,0,5 },
3982
/* 0 - not seen, 1 - seen as argument, 2 - seen as default */
3983
memset(shell_seen, 0, 5*sizeof(int));
3987
/* Parse arguments and read input */
3988
while (getopt_long(argc, argv, "", shell_options, &shell_index) != -1) {
3990
if (shell_index==-1) {
3994
if (shell_seen[shell_index]==1) {
3995
fprintf(stderr, "Error, `--%s' argument given twice.\n",
3996
shell_options[shell_index].name);
3999
shell_seen[shell_index]=1;
4001
switch (shell_index) {
4003
shell_arg_graph=strdup(optarg);
4006
shell_read_integer(&n1, optarg);
4009
shell_read_integer(&n2, optarg);
4011
case 3: /* directed */
4012
shell_read_boolean(&directed, optarg);
4015
shell_read_enum(&mode, optarg, "out", 1, "in", 2, "all", 3, "total", 3, 0);
4018
shell_igraph_full_bipartite_usage(argv);
4027
/* Check that we have all arguments */
4028
for (shell_index=0; shell_index<5; shell_index++) {
4029
if (!shell_seen[shell_index]) {
4030
fprintf(stderr, "Error, argument missing: `--%s'.\n",
4031
shell_options[shell_index].name);
4036
/* Do the operation */
4037
shell_result=igraph_full_bipartite(&graph, types, n1, n2, directed, mode);
4039
/* Write the result */
4040
shell_write_graph(&graph, shell_arg_graph);
4041
igraph_destroy(&graph);
4046
/*-------------------------------------------/
4047
/ igraph_barabasi_game /
4048
/-------------------------------------------*/
4049
void shell_igraph_barabasi_game_usage(char **argv) {
4050
printf("%s --graph=<graph> --n=<n> --m=<m> --outseq=<outseq> --outpref=<outpref> --directed=<directed>\n", basename(argv[0]));
4054
int shell_igraph_barabasi_game(int argc, char **argv) {
4058
igraph_integer_t m=1;
4059
igraph_vector_t v_outseq; igraph_vector_t *outseq=0;
4060
igraph_bool_t outpref=0;
4061
igraph_bool_t directed=1;
4062
char* shell_arg_graph=0;
4068
struct option shell_options[]= { { "graph",required_argument,0,0 },
4069
{ "n",required_argument,0,1 },
4070
{ "m",required_argument,0,2 },
4071
{ "outseq",required_argument,0,3 },
4072
{ "outpref",required_argument,0,4 },
4073
{ "directed",required_argument,0,5 },
4074
{ "help",no_argument,0,6 },
4078
/* 0 - not seen, 1 - seen as argument, 2 - seen as default */
4079
memset(shell_seen, 0, 6*sizeof(int));
4084
/* Parse arguments and read input */
4085
while (getopt_long(argc, argv, "", shell_options, &shell_index) != -1) {
4087
if (shell_index==-1) {
4091
if (shell_seen[shell_index]==1) {
4092
fprintf(stderr, "Error, `--%s' argument given twice.\n",
4093
shell_options[shell_index].name);
4096
shell_seen[shell_index]=1;
4098
switch (shell_index) {
4100
shell_arg_graph=strdup(optarg);
4103
shell_read_integer(&n, optarg);
4106
shell_read_integer(&m, optarg);
4108
case 3: /* outseq */
4109
outseq=&v_outseq; shell_read_vector(outseq, optarg);
4111
case 4: /* outpref */
4112
shell_read_boolean(&outpref, optarg);
4114
case 5: /* directed */
4115
shell_read_boolean(&directed, optarg);
4118
shell_igraph_barabasi_game_usage(argv);
4127
/* Check that we have all arguments */
4128
for (shell_index=0; shell_index<6; shell_index++) {
4129
if (!shell_seen[shell_index]) {
4130
fprintf(stderr, "Error, argument missing: `--%s'.\n",
4131
shell_options[shell_index].name);
4136
/* Do the operation */
4137
shell_result=igraph_barabasi_game(&graph, n, m, outseq, outpref, directed);
4139
/* Write the result */
4140
shell_write_graph(&graph, shell_arg_graph);
4141
igraph_destroy(&graph);
4142
if (outseq) { igraph_vector_destroy(outseq); }
4147
/*-------------------------------------------/
4148
/ igraph_nonlinear_barabasi_game /
4149
/-------------------------------------------*/
4150
void shell_igraph_nonlinear_barabasi_game_usage(char **argv) {
4151
printf("%s --graph=<graph> --n=<n> --power=<power> --m=<m> --outseq=<outseq> --outpref=<outpref> --zeroappeal=<zeroappeal> --directed=<directed>\n", basename(argv[0]));
4155
int shell_igraph_nonlinear_barabasi_game(int argc, char **argv) {
4159
igraph_real_t power=1.0;
4160
igraph_integer_t m=1;
4161
igraph_vector_t v_outseq; igraph_vector_t *outseq=0;
4162
igraph_bool_t outpref=0;
4163
igraph_real_t zeroappeal=1.0;
4164
igraph_bool_t directed=1;
4165
char* shell_arg_graph=0;
4171
struct option shell_options[]= { { "graph",required_argument,0,0 },
4172
{ "n",required_argument,0,1 },
4173
{ "power",required_argument,0,2 },
4174
{ "m",required_argument,0,3 },
4175
{ "outseq",required_argument,0,4 },
4176
{ "outpref",required_argument,0,5 },
4177
{ "zeroappeal",required_argument,0,6 },
4178
{ "directed",required_argument,0,7 },
4179
{ "help",no_argument,0,8 },
4183
/* 0 - not seen, 1 - seen as argument, 2 - seen as default */
4184
memset(shell_seen, 0, 8*sizeof(int));
4191
/* Parse arguments and read input */
4192
while (getopt_long(argc, argv, "", shell_options, &shell_index) != -1) {
4194
if (shell_index==-1) {
4198
if (shell_seen[shell_index]==1) {
4199
fprintf(stderr, "Error, `--%s' argument given twice.\n",
4200
shell_options[shell_index].name);
4203
shell_seen[shell_index]=1;
4205
switch (shell_index) {
4207
shell_arg_graph=strdup(optarg);
4210
shell_read_integer(&n, optarg);
4213
shell_read_real(&power, optarg);
4216
shell_read_integer(&m, optarg);
4218
case 4: /* outseq */
4219
outseq=&v_outseq; shell_read_vector(outseq, optarg);
4221
case 5: /* outpref */
4222
shell_read_boolean(&outpref, optarg);
4224
case 6: /* zeroappeal */
4225
shell_read_real(&zeroappeal, optarg);
4227
case 7: /* directed */
4228
shell_read_boolean(&directed, optarg);
4231
shell_igraph_nonlinear_barabasi_game_usage(argv);
4240
/* Check that we have all arguments */
4241
for (shell_index=0; shell_index<8; shell_index++) {
4242
if (!shell_seen[shell_index]) {
4243
fprintf(stderr, "Error, argument missing: `--%s'.\n",
4244
shell_options[shell_index].name);
4249
/* Do the operation */
4250
shell_result=igraph_nonlinear_barabasi_game(&graph, n, power, m, outseq, outpref, zeroappeal, directed);
4252
/* Write the result */
4253
shell_write_graph(&graph, shell_arg_graph);
4254
igraph_destroy(&graph);
4255
if (outseq) { igraph_vector_destroy(outseq); }
4260
/*-------------------------------------------/
4261
/ igraph_erdos_renyi_game_gnp /
4262
/-------------------------------------------*/
4263
void shell_igraph_erdos_renyi_game_gnp_usage(char **argv) {
4264
printf("%s --graph=<graph> --n=<n> --p=<p> --directed=<directed> --loops=<loops>\n", basename(argv[0]));
4268
int shell_igraph_erdos_renyi_game_gnp(int argc, char **argv) {
4273
igraph_bool_t directed=0;
4274
igraph_bool_t loops=0;
4275
char* shell_arg_graph=0;
4281
struct option shell_options[]= { { "graph",required_argument,0,0 },
4282
{ "n",required_argument,0,1 },
4283
{ "p",required_argument,0,2 },
4284
{ "directed",required_argument,0,3 },
4285
{ "loops",required_argument,0,4 },
4286
{ "help",no_argument,0,5 },
4290
/* 0 - not seen, 1 - seen as argument, 2 - seen as default */
4291
memset(shell_seen, 0, 5*sizeof(int));
4295
/* Parse arguments and read input */
4296
while (getopt_long(argc, argv, "", shell_options, &shell_index) != -1) {
4298
if (shell_index==-1) {
4302
if (shell_seen[shell_index]==1) {
4303
fprintf(stderr, "Error, `--%s' argument given twice.\n",
4304
shell_options[shell_index].name);
4307
shell_seen[shell_index]=1;
4309
switch (shell_index) {
4311
shell_arg_graph=strdup(optarg);
4314
shell_read_integer(&n, optarg);
4317
shell_read_real(&p, optarg);
4319
case 3: /* directed */
4320
shell_read_boolean(&directed, optarg);
4323
shell_read_boolean(&loops, optarg);
4326
shell_igraph_erdos_renyi_game_gnp_usage(argv);
4335
/* Check that we have all arguments */
4336
for (shell_index=0; shell_index<5; shell_index++) {
4337
if (!shell_seen[shell_index]) {
4338
fprintf(stderr, "Error, argument missing: `--%s'.\n",
4339
shell_options[shell_index].name);
4344
/* Do the operation */
4345
shell_result=igraph_erdos_renyi_game_gnp(&graph, n, p, directed, loops);
4347
/* Write the result */
4348
shell_write_graph(&graph, shell_arg_graph);
4349
igraph_destroy(&graph);
4354
/*-------------------------------------------/
4355
/ igraph_erdos_renyi_game_gnm /
4356
/-------------------------------------------*/
4357
void shell_igraph_erdos_renyi_game_gnm_usage(char **argv) {
4358
printf("%s --graph=<graph> --n=<n> --m=<m> --directed=<directed> --loops=<loops>\n", basename(argv[0]));
4362
int shell_igraph_erdos_renyi_game_gnm(int argc, char **argv) {
4367
igraph_bool_t directed=0;
4368
igraph_bool_t loops=0;
4369
char* shell_arg_graph=0;
4375
struct option shell_options[]= { { "graph",required_argument,0,0 },
4376
{ "n",required_argument,0,1 },
4377
{ "m",required_argument,0,2 },
4378
{ "directed",required_argument,0,3 },
4379
{ "loops",required_argument,0,4 },
4380
{ "help",no_argument,0,5 },
4384
/* 0 - not seen, 1 - seen as argument, 2 - seen as default */
4385
memset(shell_seen, 0, 5*sizeof(int));
4389
/* Parse arguments and read input */
4390
while (getopt_long(argc, argv, "", shell_options, &shell_index) != -1) {
4392
if (shell_index==-1) {
4396
if (shell_seen[shell_index]==1) {
4397
fprintf(stderr, "Error, `--%s' argument given twice.\n",
4398
shell_options[shell_index].name);
4401
shell_seen[shell_index]=1;
4403
switch (shell_index) {
4405
shell_arg_graph=strdup(optarg);
4408
shell_read_integer(&n, optarg);
4411
shell_read_real(&m, optarg);
4413
case 3: /* directed */
4414
shell_read_boolean(&directed, optarg);
4417
shell_read_boolean(&loops, optarg);
4420
shell_igraph_erdos_renyi_game_gnm_usage(argv);
4429
/* Check that we have all arguments */
4430
for (shell_index=0; shell_index<5; shell_index++) {
4431
if (!shell_seen[shell_index]) {
4432
fprintf(stderr, "Error, argument missing: `--%s'.\n",
4433
shell_options[shell_index].name);
4438
/* Do the operation */
4439
shell_result=igraph_erdos_renyi_game_gnm(&graph, n, m, directed, loops);
4441
/* Write the result */
4442
shell_write_graph(&graph, shell_arg_graph);
4443
igraph_destroy(&graph);
4448
/*-------------------------------------------/
4449
/ igraph_degree_sequence_game /
4450
/-------------------------------------------*/
4451
void shell_igraph_degree_sequence_game_usage(char **argv) {
4452
printf("%s --graph=<graph> --out_deg=<out_deg> --in_deg=<in_deg> --method=<method>\n", basename(argv[0]));
4456
int shell_igraph_degree_sequence_game(int argc, char **argv) {
4459
igraph_vector_t out_deg;
4460
igraph_vector_t v_in_deg; igraph_vector_t *in_deg=0;
4461
igraph_degseq_t method=IGRAPH_DEGSEQ_SIMPLE;
4462
char* shell_arg_graph=0;
4468
struct option shell_options[]= { { "graph",required_argument,0,0 },
4469
{ "out_deg",required_argument,0,1 },
4470
{ "in_deg",required_argument,0,2 },
4471
{ "method",required_argument,0,3 },
4472
{ "help",no_argument,0,4 },
4476
/* 0 - not seen, 1 - seen as argument, 2 - seen as default */
4477
memset(shell_seen, 0, 4*sizeof(int));
4480
/* Parse arguments and read input */
4481
while (getopt_long(argc, argv, "", shell_options, &shell_index) != -1) {
4483
if (shell_index==-1) {
4487
if (shell_seen[shell_index]==1) {
4488
fprintf(stderr, "Error, `--%s' argument given twice.\n",
4489
shell_options[shell_index].name);
4492
shell_seen[shell_index]=1;
4494
switch (shell_index) {
4496
shell_arg_graph=strdup(optarg);
4498
case 1: /* out_deg */
4499
shell_read_vector(&out_deg, optarg);
4501
case 2: /* in_deg */
4502
in_deg=&v_in_deg; shell_read_vector(in_deg, optarg);
4504
case 3: /* method */
4505
shell_read_enum(&method, optarg, "simple", 0, 0);
4508
shell_igraph_degree_sequence_game_usage(argv);
4517
/* Check that we have all arguments */
4518
for (shell_index=0; shell_index<4; shell_index++) {
4519
if (!shell_seen[shell_index]) {
4520
fprintf(stderr, "Error, argument missing: `--%s'.\n",
4521
shell_options[shell_index].name);
4526
/* Do the operation */
4527
shell_result=igraph_degree_sequence_game(&graph, &out_deg, in_deg, method);
4529
/* Write the result */
4530
shell_write_graph(&graph, shell_arg_graph);
4531
igraph_destroy(&graph);
4532
igraph_vector_destroy(&out_deg);
4533
if (in_deg) { igraph_vector_destroy(in_deg); }
4538
/*-------------------------------------------/
4539
/ igraph_growing_random_game /
4540
/-------------------------------------------*/
4541
void shell_igraph_growing_random_game_usage(char **argv) {
4542
printf("%s --graph=<graph> --n=<n> --m=<m> --directed=<directed> --citation=<citation>\n", basename(argv[0]));
4546
int shell_igraph_growing_random_game(int argc, char **argv) {
4550
igraph_integer_t m=1;
4551
igraph_bool_t directed=0;
4552
igraph_bool_t citation=0;
4553
char* shell_arg_graph=0;
4559
struct option shell_options[]= { { "graph",required_argument,0,0 },
4560
{ "n",required_argument,0,1 },
4561
{ "m",required_argument,0,2 },
4562
{ "directed",required_argument,0,3 },
4563
{ "citation",required_argument,0,4 },
4564
{ "help",no_argument,0,5 },
4568
/* 0 - not seen, 1 - seen as argument, 2 - seen as default */
4569
memset(shell_seen, 0, 5*sizeof(int));
4574
/* Parse arguments and read input */
4575
while (getopt_long(argc, argv, "", shell_options, &shell_index) != -1) {
4577
if (shell_index==-1) {
4581
if (shell_seen[shell_index]==1) {
4582
fprintf(stderr, "Error, `--%s' argument given twice.\n",
4583
shell_options[shell_index].name);
4586
shell_seen[shell_index]=1;
4588
switch (shell_index) {
4590
shell_arg_graph=strdup(optarg);
4593
shell_read_integer(&n, optarg);
4596
shell_read_integer(&m, optarg);
4598
case 3: /* directed */
4599
shell_read_boolean(&directed, optarg);
4601
case 4: /* citation */
4602
shell_read_boolean(&citation, optarg);
4605
shell_igraph_growing_random_game_usage(argv);
4614
/* Check that we have all arguments */
4615
for (shell_index=0; shell_index<5; shell_index++) {
4616
if (!shell_seen[shell_index]) {
4617
fprintf(stderr, "Error, argument missing: `--%s'.\n",
4618
shell_options[shell_index].name);
4623
/* Do the operation */
4624
shell_result=igraph_growing_random_game(&graph, n, m, directed, citation);
4626
/* Write the result */
4627
shell_write_graph(&graph, shell_arg_graph);
4628
igraph_destroy(&graph);
4633
/*-------------------------------------------/
4634
/ igraph_barabasi_aging_game /
4635
/-------------------------------------------*/
4636
void shell_igraph_barabasi_aging_game_usage(char **argv) {
4637
printf("%s --graph=<graph> --nodes=<nodes> --m=<m> --outseq=<outseq> --outpref=<outpref> --pa_exp=<pa_exp> --aging_exp=<aging_exp> --aging_bin=<aging_bin> --zero_deg_appeal=<zero_deg_appeal> --zero_age_appeal=<zero_age_appeal> --deg_coef=<deg_coef> --age_coef=<age_coef> --directed=<directed>\n", basename(argv[0]));
4641
int shell_igraph_barabasi_aging_game(int argc, char **argv) {
4644
igraph_integer_t nodes;
4645
igraph_integer_t m=1;
4646
igraph_vector_t v_outseq; igraph_vector_t *outseq=0;
4647
igraph_bool_t outpref=0;
4648
igraph_real_t pa_exp=1.0;
4649
igraph_real_t aging_exp=0.0;
4650
igraph_integer_t aging_bin=1;
4651
igraph_real_t zero_deg_appeal=1.0;
4652
igraph_real_t zero_age_appeal=0.0;
4653
igraph_real_t deg_coef=1.0;
4654
igraph_real_t age_coef=1.0;
4655
igraph_bool_t directed=1;
4656
char* shell_arg_graph=0;
4662
struct option shell_options[]= { { "graph",required_argument,0,0 },
4663
{ "nodes",required_argument,0,1 },
4664
{ "m",required_argument,0,2 },
4665
{ "outseq",required_argument,0,3 },
4666
{ "outpref",required_argument,0,4 },
4667
{ "pa_exp",required_argument,0,5 },
4668
{ "aging_exp",required_argument,0,6 },
4669
{ "aging_bin",required_argument,0,7 },
4670
{ "zero_deg_appeal",required_argument,0,8 },
4671
{ "zero_age_appeal",required_argument,0,9 },
4672
{ "deg_coef",required_argument,0,10 },
4673
{ "age_coef",required_argument,0,11 },
4674
{ "directed",required_argument,0,12 },
4675
{ "help",no_argument,0,13 },
4679
/* 0 - not seen, 1 - seen as argument, 2 - seen as default */
4680
memset(shell_seen, 0, 13*sizeof(int));
4692
/* Parse arguments and read input */
4693
while (getopt_long(argc, argv, "", shell_options, &shell_index) != -1) {
4695
if (shell_index==-1) {
4699
if (shell_seen[shell_index]==1) {
4700
fprintf(stderr, "Error, `--%s' argument given twice.\n",
4701
shell_options[shell_index].name);
4704
shell_seen[shell_index]=1;
4706
switch (shell_index) {
4708
shell_arg_graph=strdup(optarg);
4711
shell_read_integer(&nodes, optarg);
4714
shell_read_integer(&m, optarg);
4716
case 3: /* outseq */
4717
outseq=&v_outseq; shell_read_vector(outseq, optarg);
4719
case 4: /* outpref */
4720
shell_read_boolean(&outpref, optarg);
4722
case 5: /* pa_exp */
4723
shell_read_real(&pa_exp, optarg);
4725
case 6: /* aging_exp */
4726
shell_read_real(&aging_exp, optarg);
4728
case 7: /* aging_bin */
4729
shell_read_integer(&aging_bin, optarg);
4731
case 8: /* zero_deg_appeal */
4732
shell_read_real(&zero_deg_appeal, optarg);
4734
case 9: /* zero_age_appeal */
4735
shell_read_real(&zero_age_appeal, optarg);
4737
case 10: /* deg_coef */
4738
shell_read_real(°_coef, optarg);
4740
case 11: /* age_coef */
4741
shell_read_real(&age_coef, optarg);
4743
case 12: /* directed */
4744
shell_read_boolean(&directed, optarg);
4747
shell_igraph_barabasi_aging_game_usage(argv);
4756
/* Check that we have all arguments */
4757
for (shell_index=0; shell_index<13; shell_index++) {
4758
if (!shell_seen[shell_index]) {
4759
fprintf(stderr, "Error, argument missing: `--%s'.\n",
4760
shell_options[shell_index].name);
4765
/* Do the operation */
4766
shell_result=igraph_barabasi_aging_game(&graph, nodes, m, outseq, outpref, pa_exp, aging_exp, aging_bin, zero_deg_appeal, zero_age_appeal, deg_coef, age_coef, directed);
4768
/* Write the result */
4769
shell_write_graph(&graph, shell_arg_graph);
4770
igraph_destroy(&graph);
4771
if (outseq) { igraph_vector_destroy(outseq); }
4776
/*-------------------------------------------/
4777
/ igraph_recent_degree_game /
4778
/-------------------------------------------*/
4779
void shell_igraph_recent_degree_game_usage(char **argv) {
4780
printf("%s --graph=<graph> --n=<n> --power=<power> --window=<window> --m=<m> --outseq=<outseq> --outpref=<outpref> --zero_appeal=<zero_appeal> --directed=<directed>\n", basename(argv[0]));
4784
int shell_igraph_recent_degree_game(int argc, char **argv) {
4788
igraph_real_t power=1.0;
4789
igraph_integer_t window=1;
4790
igraph_integer_t m=1;
4791
igraph_vector_t v_outseq; igraph_vector_t *outseq=0;
4792
igraph_bool_t outpref=0;
4793
igraph_real_t zero_appeal=1.0;
4794
igraph_bool_t directed=1;
4795
char* shell_arg_graph=0;
4801
struct option shell_options[]= { { "graph",required_argument,0,0 },
4802
{ "n",required_argument,0,1 },
4803
{ "power",required_argument,0,2 },
4804
{ "window",required_argument,0,3 },
4805
{ "m",required_argument,0,4 },
4806
{ "outseq",required_argument,0,5 },
4807
{ "outpref",required_argument,0,6 },
4808
{ "zero_appeal",required_argument,0,7 },
4809
{ "directed",required_argument,0,8 },
4810
{ "help",no_argument,0,9 },
4814
/* 0 - not seen, 1 - seen as argument, 2 - seen as default */
4815
memset(shell_seen, 0, 9*sizeof(int));
4823
/* Parse arguments and read input */
4824
while (getopt_long(argc, argv, "", shell_options, &shell_index) != -1) {
4826
if (shell_index==-1) {
4830
if (shell_seen[shell_index]==1) {
4831
fprintf(stderr, "Error, `--%s' argument given twice.\n",
4832
shell_options[shell_index].name);
4835
shell_seen[shell_index]=1;
4837
switch (shell_index) {
4839
shell_arg_graph=strdup(optarg);
4842
shell_read_integer(&n, optarg);
4845
shell_read_real(&power, optarg);
4847
case 3: /* window */
4848
shell_read_integer(&window, optarg);
4851
shell_read_integer(&m, optarg);
4853
case 5: /* outseq */
4854
outseq=&v_outseq; shell_read_vector(outseq, optarg);
4856
case 6: /* outpref */
4857
shell_read_boolean(&outpref, optarg);
4859
case 7: /* zero_appeal */
4860
shell_read_real(&zero_appeal, optarg);
4862
case 8: /* directed */
4863
shell_read_boolean(&directed, optarg);
4866
shell_igraph_recent_degree_game_usage(argv);
4875
/* Check that we have all arguments */
4876
for (shell_index=0; shell_index<9; shell_index++) {
4877
if (!shell_seen[shell_index]) {
4878
fprintf(stderr, "Error, argument missing: `--%s'.\n",
4879
shell_options[shell_index].name);
4884
/* Do the operation */
4885
shell_result=igraph_recent_degree_game(&graph, n, power, window, m, outseq, outpref, zero_appeal, directed);
4887
/* Write the result */
4888
shell_write_graph(&graph, shell_arg_graph);
4889
igraph_destroy(&graph);
4890
if (outseq) { igraph_vector_destroy(outseq); }
4895
/*-------------------------------------------/
4896
/ igraph_recent_degree_aging_game /
4897
/-------------------------------------------*/
4898
void shell_igraph_recent_degree_aging_game_usage(char **argv) {
4899
printf("%s --graph=<graph> --nodes=<nodes> --m=<m> --outseq=<outseq> --outpref=<outpref> --pa_exp=<pa_exp> --aging_exp=<aging_exp> --aging_bin=<aging_bin> --window=<window> --zero_appeal=<zero_appeal> --directed=<directed>\n", basename(argv[0]));
4903
int shell_igraph_recent_degree_aging_game(int argc, char **argv) {
4906
igraph_integer_t nodes;
4907
igraph_integer_t m=1;
4908
igraph_vector_t v_outseq; igraph_vector_t *outseq=0;
4909
igraph_bool_t outpref=0;
4910
igraph_real_t pa_exp=1.0;
4911
igraph_real_t aging_exp=0.0;
4912
igraph_integer_t aging_bin=1;
4913
igraph_integer_t window=1;
4914
igraph_real_t zero_appeal=1.0;
4915
igraph_bool_t directed=1;
4916
char* shell_arg_graph=0;
4922
struct option shell_options[]= { { "graph",required_argument,0,0 },
4923
{ "nodes",required_argument,0,1 },
4924
{ "m",required_argument,0,2 },
4925
{ "outseq",required_argument,0,3 },
4926
{ "outpref",required_argument,0,4 },
4927
{ "pa_exp",required_argument,0,5 },
4928
{ "aging_exp",required_argument,0,6 },
4929
{ "aging_bin",required_argument,0,7 },
4930
{ "window",required_argument,0,8 },
4931
{ "zero_appeal",required_argument,0,9 },
4932
{ "directed",required_argument,0,10 },
4933
{ "help",no_argument,0,11 },
4937
/* 0 - not seen, 1 - seen as argument, 2 - seen as default */
4938
memset(shell_seen, 0, 11*sizeof(int));
4948
/* Parse arguments and read input */
4949
while (getopt_long(argc, argv, "", shell_options, &shell_index) != -1) {
4951
if (shell_index==-1) {
4955
if (shell_seen[shell_index]==1) {
4956
fprintf(stderr, "Error, `--%s' argument given twice.\n",
4957
shell_options[shell_index].name);
4960
shell_seen[shell_index]=1;
4962
switch (shell_index) {
4964
shell_arg_graph=strdup(optarg);
4967
shell_read_integer(&nodes, optarg);
4970
shell_read_integer(&m, optarg);
4972
case 3: /* outseq */
4973
outseq=&v_outseq; shell_read_vector(outseq, optarg);
4975
case 4: /* outpref */
4976
shell_read_boolean(&outpref, optarg);
4978
case 5: /* pa_exp */
4979
shell_read_real(&pa_exp, optarg);
4981
case 6: /* aging_exp */
4982
shell_read_real(&aging_exp, optarg);
4984
case 7: /* aging_bin */
4985
shell_read_integer(&aging_bin, optarg);
4987
case 8: /* window */
4988
shell_read_integer(&window, optarg);
4990
case 9: /* zero_appeal */
4991
shell_read_real(&zero_appeal, optarg);
4993
case 10: /* directed */
4994
shell_read_boolean(&directed, optarg);
4997
shell_igraph_recent_degree_aging_game_usage(argv);
5006
/* Check that we have all arguments */
5007
for (shell_index=0; shell_index<11; shell_index++) {
5008
if (!shell_seen[shell_index]) {
5009
fprintf(stderr, "Error, argument missing: `--%s'.\n",
5010
shell_options[shell_index].name);
5015
/* Do the operation */
5016
shell_result=igraph_recent_degree_aging_game(&graph, nodes, m, outseq, outpref, pa_exp, aging_exp, aging_bin, window, zero_appeal, directed);
5018
/* Write the result */
5019
shell_write_graph(&graph, shell_arg_graph);
5020
igraph_destroy(&graph);
5021
if (outseq) { igraph_vector_destroy(outseq); }
5026
/*-------------------------------------------/
5027
/ igraph_callaway_traits_game /
5028
/-------------------------------------------*/
5029
void shell_igraph_callaway_traits_game_usage(char **argv) {
5030
printf("%s --graph=<graph> --nodes=<nodes> --types=<types> --edges_per_step=<edges_per_step> --type_dist=<type_dist> --pref_matrix=<pref_matrix> --directed=<directed>\n", basename(argv[0]));
5034
int shell_igraph_callaway_traits_game(int argc, char **argv) {
5037
igraph_integer_t nodes;
5038
igraph_integer_t types;
5039
igraph_integer_t edges_per_step=1;
5040
igraph_vector_t type_dist;
5041
igraph_matrix_t pref_matrix;
5042
igraph_bool_t directed=0;
5043
char* shell_arg_graph=0;
5049
struct option shell_options[]= { { "graph",required_argument,0,0 },
5050
{ "nodes",required_argument,0,1 },
5051
{ "types",required_argument,0,2 },
5052
{ "edges_per_step",required_argument,0,3 },
5053
{ "type_dist",required_argument,0,4 },
5054
{ "pref_matrix",required_argument,0,5 },
5055
{ "directed",required_argument,0,6 },
5056
{ "help",no_argument,0,7 },
5060
/* 0 - not seen, 1 - seen as argument, 2 - seen as default */
5061
memset(shell_seen, 0, 7*sizeof(int));
5065
/* Parse arguments and read input */
5066
while (getopt_long(argc, argv, "", shell_options, &shell_index) != -1) {
5068
if (shell_index==-1) {
5072
if (shell_seen[shell_index]==1) {
5073
fprintf(stderr, "Error, `--%s' argument given twice.\n",
5074
shell_options[shell_index].name);
5077
shell_seen[shell_index]=1;
5079
switch (shell_index) {
5081
shell_arg_graph=strdup(optarg);
5084
shell_read_integer(&nodes, optarg);
5087
shell_read_integer(&types, optarg);
5089
case 3: /* edges_per_step */
5090
shell_read_integer(&edges_per_step, optarg);
5092
case 4: /* type_dist */
5093
shell_read_vector(&type_dist, optarg);
5095
case 5: /* pref_matrix */
5096
shell_read_matrix(&pref_matrix, optarg);
5098
case 6: /* directed */
5099
shell_read_boolean(&directed, optarg);
5102
shell_igraph_callaway_traits_game_usage(argv);
5111
/* Check that we have all arguments */
5112
for (shell_index=0; shell_index<7; shell_index++) {
5113
if (!shell_seen[shell_index]) {
5114
fprintf(stderr, "Error, argument missing: `--%s'.\n",
5115
shell_options[shell_index].name);
5120
/* Do the operation */
5121
shell_result=igraph_callaway_traits_game(&graph, nodes, types, edges_per_step, &type_dist, &pref_matrix, directed);
5123
/* Write the result */
5124
shell_write_graph(&graph, shell_arg_graph);
5125
igraph_destroy(&graph);
5126
igraph_vector_destroy(&type_dist);
5127
igraph_matrix_destroy(&pref_matrix);
5132
/*-------------------------------------------/
5133
/ igraph_establishment_game /
5134
/-------------------------------------------*/
5135
void shell_igraph_establishment_game_usage(char **argv) {
5136
printf("%s --graph=<graph> --nodes=<nodes> --types=<types> --k=<k> --type_dist=<type_dist> --pref_matrix=<pref_matrix> --directed=<directed>\n", basename(argv[0]));
5140
int shell_igraph_establishment_game(int argc, char **argv) {
5143
igraph_integer_t nodes;
5144
igraph_integer_t types;
5145
igraph_integer_t k=1;
5146
igraph_vector_t type_dist;
5147
igraph_matrix_t pref_matrix;
5148
igraph_bool_t directed=1;
5149
char* shell_arg_graph=0;
5155
struct option shell_options[]= { { "graph",required_argument,0,0 },
5156
{ "nodes",required_argument,0,1 },
5157
{ "types",required_argument,0,2 },
5158
{ "k",required_argument,0,3 },
5159
{ "type_dist",required_argument,0,4 },
5160
{ "pref_matrix",required_argument,0,5 },
5161
{ "directed",required_argument,0,6 },
5162
{ "help",no_argument,0,7 },
5166
/* 0 - not seen, 1 - seen as argument, 2 - seen as default */
5167
memset(shell_seen, 0, 7*sizeof(int));
5171
/* Parse arguments and read input */
5172
while (getopt_long(argc, argv, "", shell_options, &shell_index) != -1) {
5174
if (shell_index==-1) {
5178
if (shell_seen[shell_index]==1) {
5179
fprintf(stderr, "Error, `--%s' argument given twice.\n",
5180
shell_options[shell_index].name);
5183
shell_seen[shell_index]=1;
5185
switch (shell_index) {
5187
shell_arg_graph=strdup(optarg);
5190
shell_read_integer(&nodes, optarg);
5193
shell_read_integer(&types, optarg);
5196
shell_read_integer(&k, optarg);
5198
case 4: /* type_dist */
5199
shell_read_vector(&type_dist, optarg);
5201
case 5: /* pref_matrix */
5202
shell_read_matrix(&pref_matrix, optarg);
5204
case 6: /* directed */
5205
shell_read_boolean(&directed, optarg);
5208
shell_igraph_establishment_game_usage(argv);
5217
/* Check that we have all arguments */
5218
for (shell_index=0; shell_index<7; shell_index++) {
5219
if (!shell_seen[shell_index]) {
5220
fprintf(stderr, "Error, argument missing: `--%s'.\n",
5221
shell_options[shell_index].name);
5226
/* Do the operation */
5227
shell_result=igraph_establishment_game(&graph, nodes, types, k, &type_dist, &pref_matrix, directed);
5229
/* Write the result */
5230
shell_write_graph(&graph, shell_arg_graph);
5231
igraph_destroy(&graph);
5232
igraph_vector_destroy(&type_dist);
5233
igraph_matrix_destroy(&pref_matrix);
5238
/*-------------------------------------------/
5240
/-------------------------------------------*/
5241
void shell_igraph_grg_game_usage(char **argv) {
5242
printf("%s --graph=<graph> --nodes=<nodes> --radius=<radius> --torus=<torus> --x=<x> --y=<y>\n", basename(argv[0]));
5246
int shell_igraph_grg_game(int argc, char **argv) {
5249
igraph_integer_t nodes;
5250
igraph_real_t radius;
5251
igraph_bool_t torus=0;
5252
igraph_vector_t v_x; igraph_vector_t *x=0;
5253
igraph_vector_t v_y; igraph_vector_t *y=0;
5254
char* shell_arg_graph=0;
5260
struct option shell_options[]= { { "graph",required_argument,0,0 },
5261
{ "nodes",required_argument,0,1 },
5262
{ "radius",required_argument,0,2 },
5263
{ "torus",required_argument,0,3 },
5264
{ "x",required_argument,0,4 },
5265
{ "y",required_argument,0,5 },
5266
{ "help",no_argument,0,6 },
5270
/* 0 - not seen, 1 - seen as argument, 2 - seen as default */
5271
memset(shell_seen, 0, 6*sizeof(int));
5274
/* Parse arguments and read input */
5275
while (getopt_long(argc, argv, "", shell_options, &shell_index) != -1) {
5277
if (shell_index==-1) {
5281
if (shell_seen[shell_index]==1) {
5282
fprintf(stderr, "Error, `--%s' argument given twice.\n",
5283
shell_options[shell_index].name);
5286
shell_seen[shell_index]=1;
5288
switch (shell_index) {
5290
shell_arg_graph=strdup(optarg);
5293
shell_read_integer(&nodes, optarg);
5295
case 2: /* radius */
5296
shell_read_real(&radius, optarg);
5299
shell_read_boolean(&torus, optarg);
5302
x=&v_x; shell_read_vector(x, optarg);
5305
y=&v_y; shell_read_vector(y, optarg);
5308
shell_igraph_grg_game_usage(argv);
5317
/* Check that we have all arguments */
5318
for (shell_index=0; shell_index<6; shell_index++) {
5319
if (!shell_seen[shell_index]) {
5320
fprintf(stderr, "Error, argument missing: `--%s'.\n",
5321
shell_options[shell_index].name);
5326
/* Do the operation */
5327
shell_result=igraph_grg_game(&graph, nodes, radius, torus, x, y);
5329
/* Write the result */
5330
shell_write_graph(&graph, shell_arg_graph);
5331
igraph_destroy(&graph);
5332
if (x) { igraph_vector_destroy(x); }
5333
if (y) { igraph_vector_destroy(y); }
5338
/*-------------------------------------------/
5339
/ igraph_preference_game /
5340
/-------------------------------------------*/
5341
void shell_igraph_preference_game_usage(char **argv) {
5342
printf("%s --graph=<graph> --nodes=<nodes> --types=<types> --type_dist=<type_dist> --pref_matrix=<pref_matrix> --node_type_vec=<node_type_vec> --directed=<directed> --loops=<loops>\n", basename(argv[0]));
5346
int shell_igraph_preference_game(int argc, char **argv) {
5349
igraph_integer_t nodes;
5350
igraph_integer_t types;
5351
igraph_vector_t type_dist;
5352
igraph_matrix_t pref_matrix;
5353
igraph_vector_t node_type_vec;
5354
igraph_bool_t directed=0;
5355
igraph_bool_t loops=0;
5356
char* shell_arg_graph=0;
5357
char* shell_arg_node_type_vec=0;
5363
struct option shell_options[]= { { "graph",required_argument,0,0 },
5364
{ "nodes",required_argument,0,1 },
5365
{ "types",required_argument,0,2 },
5366
{ "type_dist",required_argument,0,3 },
5367
{ "pref_matrix",required_argument,0,4 },
5368
{ "node_type_vec",required_argument,0,5 },
5369
{ "directed",required_argument,0,6 },
5370
{ "loops",required_argument,0,7 },
5371
{ "help",no_argument,0,8 },
5375
/* 0 - not seen, 1 - seen as argument, 2 - seen as default */
5376
memset(shell_seen, 0, 8*sizeof(int));
5380
/* Parse arguments and read input */
5381
while (getopt_long(argc, argv, "", shell_options, &shell_index) != -1) {
5383
if (shell_index==-1) {
5387
if (shell_seen[shell_index]==1) {
5388
fprintf(stderr, "Error, `--%s' argument given twice.\n",
5389
shell_options[shell_index].name);
5392
shell_seen[shell_index]=1;
5394
switch (shell_index) {
5396
shell_arg_graph=strdup(optarg);
5399
shell_read_integer(&nodes, optarg);
5402
shell_read_integer(&types, optarg);
5404
case 3: /* type_dist */
5405
shell_read_vector(&type_dist, optarg);
5407
case 4: /* pref_matrix */
5408
shell_read_matrix(&pref_matrix, optarg);
5410
case 5: /* node_type_vec */
5411
shell_arg_node_type_vec=strdup(optarg);
5412
igraph_vector_init(&node_type_vec, 0);
5414
case 6: /* directed */
5415
shell_read_boolean(&directed, optarg);
5418
shell_read_boolean(&loops, optarg);
5421
shell_igraph_preference_game_usage(argv);
5430
/* Check that we have all arguments */
5431
for (shell_index=0; shell_index<8; shell_index++) {
5432
if (!shell_seen[shell_index]) {
5433
fprintf(stderr, "Error, argument missing: `--%s'.\n",
5434
shell_options[shell_index].name);
5439
/* Do the operation */
5440
shell_result=igraph_preference_game(&graph, nodes, types, &type_dist, &pref_matrix, &node_type_vec, directed, loops);
5442
/* Write the result */
5443
shell_write_graph(&graph, shell_arg_graph);
5444
igraph_destroy(&graph);
5445
igraph_vector_destroy(&type_dist);
5446
igraph_matrix_destroy(&pref_matrix);
5447
shell_write_vector(&node_type_vec, shell_arg_node_type_vec);
5448
igraph_vector_destroy(&node_type_vec);
5453
/*-------------------------------------------/
5454
/ igraph_asymmetric_preference_game /
5455
/-------------------------------------------*/
5456
void shell_igraph_asymmetric_preference_game_usage(char **argv) {
5457
printf("%s --graph=<graph> --nodes=<nodes> --types=<types> --type_dist_matrix=<type_dist_matrix> --pref_matrix=<pref_matrix> --node_type_in_vec=<node_type_in_vec> --node_type_out_vec=<node_type_out_vec> --loops=<loops>\n", basename(argv[0]));
5461
int shell_igraph_asymmetric_preference_game(int argc, char **argv) {
5464
igraph_integer_t nodes;
5465
igraph_integer_t types;
5466
igraph_matrix_t type_dist_matrix;
5467
igraph_matrix_t pref_matrix;
5468
igraph_vector_t node_type_in_vec;
5469
igraph_vector_t node_type_out_vec;
5470
igraph_bool_t loops=0;
5471
char* shell_arg_graph=0;
5472
char* shell_arg_node_type_in_vec=0;
5473
char* shell_arg_node_type_out_vec=0;
5479
struct option shell_options[]= { { "graph",required_argument,0,0 },
5480
{ "nodes",required_argument,0,1 },
5481
{ "types",required_argument,0,2 },
5482
{ "type_dist_matrix",required_argument,0,3 },
5483
{ "pref_matrix",required_argument,0,4 },
5484
{ "node_type_in_vec",required_argument,0,5 },
5485
{ "node_type_out_vec",required_argument,0,6 },
5486
{ "loops",required_argument,0,7 },
5487
{ "help",no_argument,0,8 },
5491
/* 0 - not seen, 1 - seen as argument, 2 - seen as default */
5492
memset(shell_seen, 0, 8*sizeof(int));
5495
/* Parse arguments and read input */
5496
while (getopt_long(argc, argv, "", shell_options, &shell_index) != -1) {
5498
if (shell_index==-1) {
5502
if (shell_seen[shell_index]==1) {
5503
fprintf(stderr, "Error, `--%s' argument given twice.\n",
5504
shell_options[shell_index].name);
5507
shell_seen[shell_index]=1;
5509
switch (shell_index) {
5511
shell_arg_graph=strdup(optarg);
5514
shell_read_integer(&nodes, optarg);
5517
shell_read_integer(&types, optarg);
5519
case 3: /* type_dist_matrix */
5520
shell_read_matrix(&type_dist_matrix, optarg);
5522
case 4: /* pref_matrix */
5523
shell_read_matrix(&pref_matrix, optarg);
5525
case 5: /* node_type_in_vec */
5526
shell_arg_node_type_in_vec=strdup(optarg);
5527
igraph_vector_init(&node_type_in_vec, 0);
5529
case 6: /* node_type_out_vec */
5530
shell_arg_node_type_out_vec=strdup(optarg);
5531
igraph_vector_init(&node_type_out_vec, 0);
5534
shell_read_boolean(&loops, optarg);
5537
shell_igraph_asymmetric_preference_game_usage(argv);
5546
/* Check that we have all arguments */
5547
for (shell_index=0; shell_index<8; shell_index++) {
5548
if (!shell_seen[shell_index]) {
5549
fprintf(stderr, "Error, argument missing: `--%s'.\n",
5550
shell_options[shell_index].name);
5555
/* Do the operation */
5556
shell_result=igraph_asymmetric_preference_game(&graph, nodes, types, &type_dist_matrix, &pref_matrix, &node_type_in_vec, &node_type_out_vec, loops);
5558
/* Write the result */
5559
shell_write_graph(&graph, shell_arg_graph);
5560
igraph_destroy(&graph);
5561
igraph_matrix_destroy(&type_dist_matrix);
5562
igraph_matrix_destroy(&pref_matrix);
5563
shell_write_vector(&node_type_in_vec, shell_arg_node_type_in_vec);
5564
igraph_vector_destroy(&node_type_in_vec);
5565
shell_write_vector(&node_type_out_vec, shell_arg_node_type_out_vec);
5566
igraph_vector_destroy(&node_type_out_vec);
5571
/*-------------------------------------------/
5572
/ igraph_rewire_edges /
5573
/-------------------------------------------*/
5574
void shell_igraph_rewire_edges_usage(char **argv) {
5575
printf("%s --graph=<graph> --graph-out=<graph-out> --prob=<prob>\n", basename(argv[0]));
5579
int shell_igraph_rewire_edges(int argc, char **argv) {
5583
char* shell_arg_graph=0;
5589
struct option shell_options[]= { { "graph",required_argument,0,0 },
5590
{ "graph-out",required_argument,0,1 },
5591
{ "prob",required_argument,0,2 },
5592
{ "help",no_argument,0,3 },
5596
/* 0 - not seen, 1 - seen as argument, 2 - seen as default */
5597
memset(shell_seen, 0, 3*sizeof(int));
5600
/* Parse arguments and read input */
5601
while (getopt_long(argc, argv, "", shell_options, &shell_index) != -1) {
5603
if (shell_index==-1) {
5607
if (shell_seen[shell_index]==1) {
5608
fprintf(stderr, "Error, `--%s' argument given twice.\n",
5609
shell_options[shell_index].name);
5612
shell_seen[shell_index]=1;
5614
switch (shell_index) {
5616
shell_read_graph(&graph, optarg);
5618
case 1: /* graph-out */
5619
shell_arg_graph=strdup(optarg);
5622
shell_read_real(&prob, optarg);
5625
shell_igraph_rewire_edges_usage(argv);
5634
/* Check that we have all arguments */
5635
for (shell_index=0; shell_index<3; shell_index++) {
5636
if (!shell_seen[shell_index]) {
5637
fprintf(stderr, "Error, argument missing: `--%s'.\n",
5638
shell_options[shell_index].name);
5643
/* Do the operation */
5644
shell_result=igraph_rewire_edges(&graph, prob);
5646
/* Write the result */
5647
igraph_destroy(&graph);
5648
shell_write_graph(&graph, shell_arg_graph);
5649
igraph_destroy(&graph);
5654
/*-------------------------------------------/
5655
/ igraph_watts_strogatz_game /
5656
/-------------------------------------------*/
5657
void shell_igraph_watts_strogatz_game_usage(char **argv) {
5658
printf("%s --graph=<graph> --dim=<dim> --size=<size> --nei=<nei> --p=<p>\n", basename(argv[0]));
5662
int shell_igraph_watts_strogatz_game(int argc, char **argv) {
5665
igraph_integer_t dim;
5666
igraph_integer_t size;
5667
igraph_integer_t nei;
5669
char* shell_arg_graph=0;
5675
struct option shell_options[]= { { "graph",required_argument,0,0 },
5676
{ "dim",required_argument,0,1 },
5677
{ "size",required_argument,0,2 },
5678
{ "nei",required_argument,0,3 },
5679
{ "p",required_argument,0,4 },
5680
{ "help",no_argument,0,5 },
5684
/* 0 - not seen, 1 - seen as argument, 2 - seen as default */
5685
memset(shell_seen, 0, 5*sizeof(int));
5688
/* Parse arguments and read input */
5689
while (getopt_long(argc, argv, "", shell_options, &shell_index) != -1) {
5691
if (shell_index==-1) {
5695
if (shell_seen[shell_index]==1) {
5696
fprintf(stderr, "Error, `--%s' argument given twice.\n",
5697
shell_options[shell_index].name);
5700
shell_seen[shell_index]=1;
5702
switch (shell_index) {
5704
shell_arg_graph=strdup(optarg);
5707
shell_read_integer(&dim, optarg);
5710
shell_read_integer(&size, optarg);
5713
shell_read_integer(&nei, optarg);
5716
shell_read_real(&p, optarg);
5719
shell_igraph_watts_strogatz_game_usage(argv);
5728
/* Check that we have all arguments */
5729
for (shell_index=0; shell_index<5; shell_index++) {
5730
if (!shell_seen[shell_index]) {
5731
fprintf(stderr, "Error, argument missing: `--%s'.\n",
5732
shell_options[shell_index].name);
5737
/* Do the operation */
5738
shell_result=igraph_watts_strogatz_game(&graph, dim, size, nei, p);
5740
/* Write the result */
5741
shell_write_graph(&graph, shell_arg_graph);
5742
igraph_destroy(&graph);
5747
/*-------------------------------------------/
5748
/ igraph_lastcit_game /
5749
/-------------------------------------------*/
5750
void shell_igraph_lastcit_game_usage(char **argv) {
5751
printf("%s --graph=<graph> --nodes=<nodes> --edges_per_node=<edges_per_node> --agebins=<agebins> --preference=<preference> --directed=<directed>\n", basename(argv[0]));
5755
int shell_igraph_lastcit_game(int argc, char **argv) {
5758
igraph_integer_t nodes;
5759
igraph_integer_t edges_per_node=1;
5760
igraph_integer_t agebins=1;
5761
igraph_vector_t preference;
5762
igraph_bool_t directed=1;
5763
char* shell_arg_graph=0;
5769
struct option shell_options[]= { { "graph",required_argument,0,0 },
5770
{ "nodes",required_argument,0,1 },
5771
{ "edges_per_node",required_argument,0,2 },
5772
{ "agebins",required_argument,0,3 },
5773
{ "preference",required_argument,0,4 },
5774
{ "directed",required_argument,0,5 },
5775
{ "help",no_argument,0,6 },
5779
/* 0 - not seen, 1 - seen as argument, 2 - seen as default */
5780
memset(shell_seen, 0, 6*sizeof(int));
5785
/* Parse arguments and read input */
5786
while (getopt_long(argc, argv, "", shell_options, &shell_index) != -1) {
5788
if (shell_index==-1) {
5792
if (shell_seen[shell_index]==1) {
5793
fprintf(stderr, "Error, `--%s' argument given twice.\n",
5794
shell_options[shell_index].name);
5797
shell_seen[shell_index]=1;
5799
switch (shell_index) {
5801
shell_arg_graph=strdup(optarg);
5804
shell_read_integer(&nodes, optarg);
5806
case 2: /* edges_per_node */
5807
shell_read_integer(&edges_per_node, optarg);
5809
case 3: /* agebins */
5810
shell_read_integer(&agebins, optarg);
5812
case 4: /* preference */
5813
shell_read_vector(&preference, optarg);
5815
case 5: /* directed */
5816
shell_read_boolean(&directed, optarg);
5819
shell_igraph_lastcit_game_usage(argv);
5828
/* Check that we have all arguments */
5829
for (shell_index=0; shell_index<6; shell_index++) {
5830
if (!shell_seen[shell_index]) {
5831
fprintf(stderr, "Error, argument missing: `--%s'.\n",
5832
shell_options[shell_index].name);
5837
/* Do the operation */
5838
shell_result=igraph_lastcit_game(&graph, nodes, edges_per_node, agebins, &preference, directed);
5840
/* Write the result */
5841
shell_write_graph(&graph, shell_arg_graph);
5842
igraph_destroy(&graph);
5843
igraph_vector_destroy(&preference);
5848
/*-------------------------------------------/
5849
/ igraph_cited_type_game /
5850
/-------------------------------------------*/
5851
void shell_igraph_cited_type_game_usage(char **argv) {
5852
printf("%s --graph=<graph> --nodes=<nodes> --types=<types> --pref=<pref> --edges_per_step=<edges_per_step> --directed=<directed>\n", basename(argv[0]));
5856
int shell_igraph_cited_type_game(int argc, char **argv) {
5859
igraph_integer_t nodes;
5860
igraph_vector_t types;
5861
igraph_vector_t pref;
5862
igraph_integer_t edges_per_step=1;
5863
igraph_bool_t directed=1;
5864
char* shell_arg_graph=0;
5870
struct option shell_options[]= { { "graph",required_argument,0,0 },
5871
{ "nodes",required_argument,0,1 },
5872
{ "types",required_argument,0,2 },
5873
{ "pref",required_argument,0,3 },
5874
{ "edges_per_step",required_argument,0,4 },
5875
{ "directed",required_argument,0,5 },
5876
{ "help",no_argument,0,6 },
5880
/* 0 - not seen, 1 - seen as argument, 2 - seen as default */
5881
memset(shell_seen, 0, 6*sizeof(int));
5885
/* Parse arguments and read input */
5886
while (getopt_long(argc, argv, "", shell_options, &shell_index) != -1) {
5888
if (shell_index==-1) {
5892
if (shell_seen[shell_index]==1) {
5893
fprintf(stderr, "Error, `--%s' argument given twice.\n",
5894
shell_options[shell_index].name);
5897
shell_seen[shell_index]=1;
5899
switch (shell_index) {
5901
shell_arg_graph=strdup(optarg);
5904
shell_read_integer(&nodes, optarg);
5907
shell_read_vector(&types, optarg);
5910
shell_read_vector(&pref, optarg);
5912
case 4: /* edges_per_step */
5913
shell_read_integer(&edges_per_step, optarg);
5915
case 5: /* directed */
5916
shell_read_boolean(&directed, optarg);
5919
shell_igraph_cited_type_game_usage(argv);
5928
/* Check that we have all arguments */
5929
for (shell_index=0; shell_index<6; shell_index++) {
5930
if (!shell_seen[shell_index]) {
5931
fprintf(stderr, "Error, argument missing: `--%s'.\n",
5932
shell_options[shell_index].name);
5937
/* Do the operation */
5938
shell_result=igraph_cited_type_game(&graph, nodes, &types, &pref, edges_per_step, directed);
5940
/* Write the result */
5941
shell_write_graph(&graph, shell_arg_graph);
5942
igraph_destroy(&graph);
5943
igraph_vector_destroy(&types);
5944
igraph_vector_destroy(&pref);
5949
/*-------------------------------------------/
5950
/ igraph_citing_cited_type_game /
5951
/-------------------------------------------*/
5952
void shell_igraph_citing_cited_type_game_usage(char **argv) {
5953
printf("%s --graph=<graph> --nodes=<nodes> --types=<types> --pref=<pref> --edges_per_step=<edges_per_step> --directed=<directed>\n", basename(argv[0]));
5957
int shell_igraph_citing_cited_type_game(int argc, char **argv) {
5960
igraph_integer_t nodes;
5961
igraph_vector_t types;
5962
igraph_matrix_t pref;
5963
igraph_integer_t edges_per_step=1;
5964
igraph_bool_t directed=1;
5965
char* shell_arg_graph=0;
5971
struct option shell_options[]= { { "graph",required_argument,0,0 },
5972
{ "nodes",required_argument,0,1 },
5973
{ "types",required_argument,0,2 },
5974
{ "pref",required_argument,0,3 },
5975
{ "edges_per_step",required_argument,0,4 },
5976
{ "directed",required_argument,0,5 },
5977
{ "help",no_argument,0,6 },
5981
/* 0 - not seen, 1 - seen as argument, 2 - seen as default */
5982
memset(shell_seen, 0, 6*sizeof(int));
5986
/* Parse arguments and read input */
5987
while (getopt_long(argc, argv, "", shell_options, &shell_index) != -1) {
5989
if (shell_index==-1) {
5993
if (shell_seen[shell_index]==1) {
5994
fprintf(stderr, "Error, `--%s' argument given twice.\n",
5995
shell_options[shell_index].name);
5998
shell_seen[shell_index]=1;
6000
switch (shell_index) {
6002
shell_arg_graph=strdup(optarg);
6005
shell_read_integer(&nodes, optarg);
6008
shell_read_vector(&types, optarg);
6011
shell_read_matrix(&pref, optarg);
6013
case 4: /* edges_per_step */
6014
shell_read_integer(&edges_per_step, optarg);
6016
case 5: /* directed */
6017
shell_read_boolean(&directed, optarg);
6020
shell_igraph_citing_cited_type_game_usage(argv);
6029
/* Check that we have all arguments */
6030
for (shell_index=0; shell_index<6; shell_index++) {
6031
if (!shell_seen[shell_index]) {
6032
fprintf(stderr, "Error, argument missing: `--%s'.\n",
6033
shell_options[shell_index].name);
6038
/* Do the operation */
6039
shell_result=igraph_citing_cited_type_game(&graph, nodes, &types, &pref, edges_per_step, directed);
6041
/* Write the result */
6042
shell_write_graph(&graph, shell_arg_graph);
6043
igraph_destroy(&graph);
6044
igraph_vector_destroy(&types);
6045
igraph_matrix_destroy(&pref);
6050
/*-------------------------------------------/
6051
/ igraph_forest_fire_game /
6052
/-------------------------------------------*/
6053
void shell_igraph_forest_fire_game_usage(char **argv) {
6054
printf("%s --graph=<graph> --nodes=<nodes> --fw_prob=<fw_prob> --bw_factor=<bw_factor> --ambs=<ambs> --directed=<directed>\n", basename(argv[0]));
6058
int shell_igraph_forest_fire_game(int argc, char **argv) {
6061
igraph_integer_t nodes;
6062
igraph_real_t fw_prob;
6063
igraph_real_t bw_factor=1;
6064
igraph_integer_t ambs=1;
6065
igraph_bool_t directed=1;
6066
char* shell_arg_graph=0;
6072
struct option shell_options[]= { { "graph",required_argument,0,0 },
6073
{ "nodes",required_argument,0,1 },
6074
{ "fw_prob",required_argument,0,2 },
6075
{ "bw_factor",required_argument,0,3 },
6076
{ "ambs",required_argument,0,4 },
6077
{ "directed",required_argument,0,5 },
6078
{ "help",no_argument,0,6 },
6082
/* 0 - not seen, 1 - seen as argument, 2 - seen as default */
6083
memset(shell_seen, 0, 6*sizeof(int));
6088
/* Parse arguments and read input */
6089
while (getopt_long(argc, argv, "", shell_options, &shell_index) != -1) {
6091
if (shell_index==-1) {
6095
if (shell_seen[shell_index]==1) {
6096
fprintf(stderr, "Error, `--%s' argument given twice.\n",
6097
shell_options[shell_index].name);
6100
shell_seen[shell_index]=1;
6102
switch (shell_index) {
6104
shell_arg_graph=strdup(optarg);
6107
shell_read_integer(&nodes, optarg);
6109
case 2: /* fw_prob */
6110
shell_read_real(&fw_prob, optarg);
6112
case 3: /* bw_factor */
6113
shell_read_real(&bw_factor, optarg);
6116
shell_read_integer(&ambs, optarg);
6118
case 5: /* directed */
6119
shell_read_boolean(&directed, optarg);
6122
shell_igraph_forest_fire_game_usage(argv);
6131
/* Check that we have all arguments */
6132
for (shell_index=0; shell_index<6; shell_index++) {
6133
if (!shell_seen[shell_index]) {
6134
fprintf(stderr, "Error, argument missing: `--%s'.\n",
6135
shell_options[shell_index].name);
6140
/* Do the operation */
6141
shell_result=igraph_forest_fire_game(&graph, nodes, fw_prob, bw_factor, ambs, directed);
6143
/* Write the result */
6144
shell_write_graph(&graph, shell_arg_graph);
6145
igraph_destroy(&graph);
6150
/*-------------------------------------------/
6151
/ igraph_are_connected /
6152
/-------------------------------------------*/
6153
void shell_igraph_are_connected_usage(char **argv) {
6154
printf("%s --graph=<graph> --v1=<v1> --v2=<v2> --res=<res>\n", basename(argv[0]));
6158
int shell_igraph_are_connected(int argc, char **argv) {
6161
igraph_integer_t v1;
6162
igraph_integer_t v2;
6164
char* shell_arg_res=0;
6170
struct option shell_options[]= { { "graph",required_argument,0,0 },
6171
{ "v1",required_argument,0,1 },
6172
{ "v2",required_argument,0,2 },
6173
{ "res",required_argument,0,3 },
6174
{ "help",no_argument,0,4 },
6178
/* 0 - not seen, 1 - seen as argument, 2 - seen as default */
6179
memset(shell_seen, 0, 4*sizeof(int));
6182
/* Parse arguments and read input */
6183
while (getopt_long(argc, argv, "", shell_options, &shell_index) != -1) {
6185
if (shell_index==-1) {
6189
if (shell_seen[shell_index]==1) {
6190
fprintf(stderr, "Error, `--%s' argument given twice.\n",
6191
shell_options[shell_index].name);
6194
shell_seen[shell_index]=1;
6196
switch (shell_index) {
6198
shell_read_graph(&graph, optarg);
6201
shell_read_integer(&v1, optarg);
6204
shell_read_integer(&v2, optarg);
6210
shell_igraph_are_connected_usage(argv);
6219
/* Check that we have all arguments */
6220
for (shell_index=0; shell_index<4; shell_index++) {
6221
if (!shell_seen[shell_index]) {
6222
fprintf(stderr, "Error, argument missing: `--%s'.\n",
6223
shell_options[shell_index].name);
6228
/* Do the operation */
6229
shell_result=igraph_are_connected(&graph, v1, v2, &res);
6231
/* Write the result */
6232
igraph_destroy(&graph);
6233
shell_write_boolean(res, shell_arg_res);
6238
/*-------------------------------------------/
6240
/-------------------------------------------*/
6241
void shell_igraph_diameter_usage(char **argv) {
6242
printf("%s --graph=<graph> --res=<res> --from=<from> --to=<to> --path=<path> --directed=<directed> --unconnected=<unconnected>\n", basename(argv[0]));
6246
int shell_igraph_diameter(int argc, char **argv) {
6249
igraph_integer_t res;
6250
igraph_integer_t from;
6251
igraph_integer_t to;
6252
igraph_vector_t v_path; igraph_vector_t *path=0;
6253
igraph_bool_t directed=1;
6254
igraph_bool_t unconnected=1;
6255
char* shell_arg_res=0;
6256
char* shell_arg_from=0;
6257
char* shell_arg_to=0;
6258
char* shell_arg_path=0;
6264
struct option shell_options[]= { { "graph",required_argument,0,0 },
6265
{ "res",required_argument,0,1 },
6266
{ "from",required_argument,0,2 },
6267
{ "to",required_argument,0,3 },
6268
{ "path",required_argument,0,4 },
6269
{ "directed",required_argument,0,5 },
6270
{ "unconnected",required_argument,0,6 },
6271
{ "help",no_argument,0,7 },
6275
/* 0 - not seen, 1 - seen as argument, 2 - seen as default */
6276
memset(shell_seen, 0, 7*sizeof(int));
6280
/* Parse arguments and read input */
6281
while (getopt_long(argc, argv, "", shell_options, &shell_index) != -1) {
6283
if (shell_index==-1) {
6287
if (shell_seen[shell_index]==1) {
6288
fprintf(stderr, "Error, `--%s' argument given twice.\n",
6289
shell_options[shell_index].name);
6292
shell_seen[shell_index]=1;
6294
switch (shell_index) {
6296
shell_read_graph(&graph, optarg);
6299
shell_arg_res=strdup(optarg);
6302
shell_arg_from=strdup(optarg);
6305
shell_arg_to=strdup(optarg);
6308
path=&v_path; igraph_vector_init(path, 0);
6309
shell_arg_path=strdup(optarg);
6311
case 5: /* directed */
6312
shell_read_boolean(&directed, optarg);
6314
case 6: /* unconnected */
6315
shell_read_boolean(&unconnected, optarg);
6318
shell_igraph_diameter_usage(argv);
6327
/* Check that we have all arguments */
6328
for (shell_index=0; shell_index<7; shell_index++) {
6329
if (!shell_seen[shell_index]) {
6330
fprintf(stderr, "Error, argument missing: `--%s'.\n",
6331
shell_options[shell_index].name);
6336
/* Do the operation */
6337
shell_result=igraph_diameter(&graph, &res, &from, &to, path, directed, unconnected);
6339
/* Write the result */
6340
igraph_destroy(&graph);
6341
shell_write_integer(res, shell_arg_res);
6342
shell_write_integer(from, shell_arg_from);
6343
shell_write_integer(to, shell_arg_to);
6344
if (path) { shell_write_vector(path, shell_arg_path);
6345
igraph_vector_destroy(path); }
6350
/*-------------------------------------------/
6351
/ igraph_diameter_dijkstra /
6352
/-------------------------------------------*/
6353
void shell_igraph_diameter_dijkstra_usage(char **argv) {
6354
printf("%s --graph=<graph> --res=<res> --from=<from> --to=<to> --path=<path> --directed=<directed> --unconnected=<unconnected>\n", basename(argv[0]));
6358
int shell_igraph_diameter_dijkstra(int argc, char **argv) {
6362
igraph_integer_t res;
6363
igraph_integer_t from;
6364
igraph_integer_t to;
6365
igraph_vector_t v_path; igraph_vector_t *path=0;
6366
igraph_bool_t directed=1;
6367
igraph_bool_t unconnected=1;
6368
char* shell_arg_res=0;
6369
char* shell_arg_from=0;
6370
char* shell_arg_to=0;
6371
char* shell_arg_path=0;
6377
struct option shell_options[]= { { "graph",required_argument,0,0 },
6378
{ "res",required_argument,0,1 },
6379
{ "from",required_argument,0,2 },
6380
{ "to",required_argument,0,3 },
6381
{ "path",required_argument,0,4 },
6382
{ "directed",required_argument,0,5 },
6383
{ "unconnected",required_argument,0,6 },
6384
{ "help",no_argument,0,7 },
6388
/* 0 - not seen, 1 - seen as argument, 2 - seen as default */
6389
memset(shell_seen, 0, 7*sizeof(int));
6393
/* Parse arguments and read input */
6394
while (getopt_long(argc, argv, "", shell_options, &shell_index) != -1) {
6396
if (shell_index==-1) {
6400
if (shell_seen[shell_index]==1) {
6401
fprintf(stderr, "Error, `--%s' argument given twice.\n",
6402
shell_options[shell_index].name);
6405
shell_seen[shell_index]=1;
6407
switch (shell_index) {
6409
shell_read_graph(&graph, optarg);
6412
shell_arg_res=strdup(optarg);
6415
shell_arg_from=strdup(optarg);
6418
shell_arg_to=strdup(optarg);
6421
path=&v_path; igraph_vector_init(path, 0);
6422
shell_arg_path=strdup(optarg);
6424
case 5: /* directed */
6425
shell_read_boolean(&directed, optarg);
6427
case 6: /* unconnected */
6428
shell_read_boolean(&unconnected, optarg);
6431
shell_igraph_diameter_dijkstra_usage(argv);
6440
/* Check that we have all arguments */
6441
for (shell_index=0; shell_index<7; shell_index++) {
6442
if (!shell_seen[shell_index]) {
6443
fprintf(stderr, "Error, argument missing: `--%s'.\n",
6444
shell_options[shell_index].name);
6449
/* Do the operation */
6450
shell_result=igraph_diameter_dijkstra(&graph, 0, &res, &from, &to, path, directed, unconnected);
6452
/* Write the result */
6453
igraph_destroy(&graph);
6454
shell_write_integer(res, shell_arg_res);
6455
shell_write_integer(from, shell_arg_from);
6456
shell_write_integer(to, shell_arg_to);
6457
if (path) { shell_write_vector(path, shell_arg_path);
6458
igraph_vector_destroy(path); }
6463
/*-------------------------------------------/
6464
/ igraph_minimum_spanning_tree_unweighted /
6465
/-------------------------------------------*/
6466
void shell_igraph_minimum_spanning_tree_unweighted_usage(char **argv) {
6467
printf("%s --graph=<graph> --mst=<mst>\n", basename(argv[0]));
6471
int shell_igraph_minimum_spanning_tree_unweighted(int argc, char **argv) {
6475
char* shell_arg_mst=0;
6481
struct option shell_options[]= { { "graph",required_argument,0,0 },
6482
{ "mst",required_argument,0,1 },
6483
{ "help",no_argument,0,2 },
6487
/* 0 - not seen, 1 - seen as argument, 2 - seen as default */
6488
memset(shell_seen, 0, 2*sizeof(int));
6491
/* Parse arguments and read input */
6492
while (getopt_long(argc, argv, "", shell_options, &shell_index) != -1) {
6494
if (shell_index==-1) {
6498
if (shell_seen[shell_index]==1) {
6499
fprintf(stderr, "Error, `--%s' argument given twice.\n",
6500
shell_options[shell_index].name);
6503
shell_seen[shell_index]=1;
6505
switch (shell_index) {
6507
shell_read_graph(&graph, optarg);
6510
shell_arg_mst=strdup(optarg);
6513
shell_igraph_minimum_spanning_tree_unweighted_usage(argv);
6522
/* Check that we have all arguments */
6523
for (shell_index=0; shell_index<2; shell_index++) {
6524
if (!shell_seen[shell_index]) {
6525
fprintf(stderr, "Error, argument missing: `--%s'.\n",
6526
shell_options[shell_index].name);
6531
/* Do the operation */
6532
shell_result=igraph_minimum_spanning_tree_unweighted(&graph, &mst);
6534
/* Write the result */
6535
igraph_destroy(&graph);
6536
shell_write_graph(&mst, shell_arg_mst);
6537
igraph_destroy(&mst);
6542
/*-------------------------------------------/
6543
/ igraph_minimum_spanning_tree_prim /
6544
/-------------------------------------------*/
6545
void shell_igraph_minimum_spanning_tree_prim_usage(char **argv) {
6546
printf("%s --graph=<graph> --mst=<mst> --weights=<weights>\n", basename(argv[0]));
6550
int shell_igraph_minimum_spanning_tree_prim(int argc, char **argv) {
6554
igraph_vector_t weights;
6555
char* shell_arg_mst=0;
6561
struct option shell_options[]= { { "graph",required_argument,0,0 },
6562
{ "mst",required_argument,0,1 },
6563
{ "weights",required_argument,0,2 },
6564
{ "help",no_argument,0,3 },
6568
/* 0 - not seen, 1 - seen as argument, 2 - seen as default */
6569
memset(shell_seen, 0, 3*sizeof(int));
6572
/* Parse arguments and read input */
6573
while (getopt_long(argc, argv, "", shell_options, &shell_index) != -1) {
6575
if (shell_index==-1) {
6579
if (shell_seen[shell_index]==1) {
6580
fprintf(stderr, "Error, `--%s' argument given twice.\n",
6581
shell_options[shell_index].name);
6584
shell_seen[shell_index]=1;
6586
switch (shell_index) {
6588
shell_read_graph(&graph, optarg);
6591
shell_arg_mst=strdup(optarg);
6593
case 2: /* weights */
6594
shell_read_vector(&weights, optarg);
6597
shell_igraph_minimum_spanning_tree_prim_usage(argv);
6606
/* Check that we have all arguments */
6607
for (shell_index=0; shell_index<3; shell_index++) {
6608
if (!shell_seen[shell_index]) {
6609
fprintf(stderr, "Error, argument missing: `--%s'.\n",
6610
shell_options[shell_index].name);
6615
/* Do the operation */
6616
shell_result=igraph_minimum_spanning_tree_prim(&graph, &mst, &weights);
6618
/* Write the result */
6619
igraph_destroy(&graph);
6620
shell_write_graph(&mst, shell_arg_mst);
6621
igraph_destroy(&mst);
6622
igraph_vector_destroy(&weights);
6627
/*-------------------------------------------/
6628
/ igraph_closeness /
6629
/-------------------------------------------*/
6630
void shell_igraph_closeness_usage(char **argv) {
6631
printf("%s --graph=<graph> --res=<res> --vids=<vids> --mode=<mode>\n", basename(argv[0]));
6635
int shell_igraph_closeness(int argc, char **argv) {
6638
igraph_vector_t res;
6639
igraph_vector_t v_vids; igraph_vs_t vids=igraph_vss_all();
6640
igraph_neimode_t mode=IGRAPH_OUT;
6641
char* shell_arg_res=0;
6647
struct option shell_options[]= { { "graph",required_argument,0,0 },
6648
{ "res",required_argument,0,1 },
6649
{ "vids",required_argument,0,2 },
6650
{ "mode",required_argument,0,3 },
6651
{ "help",no_argument,0,4 },
6655
/* 0 - not seen, 1 - seen as argument, 2 - seen as default */
6656
memset(shell_seen, 0, 4*sizeof(int));
6660
/* Parse arguments and read input */
6661
while (getopt_long(argc, argv, "", shell_options, &shell_index) != -1) {
6663
if (shell_index==-1) {
6667
if (shell_seen[shell_index]==1) {
6668
fprintf(stderr, "Error, `--%s' argument given twice.\n",
6669
shell_options[shell_index].name);
6672
shell_seen[shell_index]=1;
6674
switch (shell_index) {
6676
shell_read_graph(&graph, optarg);
6679
shell_arg_res=strdup(optarg);
6680
igraph_vector_init(&res, 0);
6683
shell_read_vector(&v_vids, optarg); igraph_vs_vector(&vids, &v_vids);
6686
shell_read_enum(&mode, optarg, "out", 1, "in", 2, "all", 3, "total", 3, 0);
6689
shell_igraph_closeness_usage(argv);
6698
/* Check that we have all arguments */
6699
for (shell_index=0; shell_index<4; shell_index++) {
6700
if (!shell_seen[shell_index]) {
6701
fprintf(stderr, "Error, argument missing: `--%s'.\n",
6702
shell_options[shell_index].name);
6707
/* Do the operation */
6708
shell_result=igraph_closeness(&graph, &res, vids, mode);
6710
/* Write the result */
6711
igraph_destroy(&graph);
6712
shell_write_vector(&res, shell_arg_res);
6713
igraph_vector_destroy(&res);
6714
if (!igraph_vs_is_all(&vids)) { igraph_vector_destroy(&v_vids); }
6719
/*-------------------------------------------/
6720
/ igraph_closeness_estimate /
6721
/-------------------------------------------*/
6722
void shell_igraph_closeness_estimate_usage(char **argv) {
6723
printf("%s --graph=<graph> --res=<res> --vids=<vids> --mode=<mode> --cutoff=<cutoff>\n", basename(argv[0]));
6727
int shell_igraph_closeness_estimate(int argc, char **argv) {
6730
igraph_vector_t res;
6731
igraph_vector_t v_vids; igraph_vs_t vids=igraph_vss_all();
6732
igraph_neimode_t mode=IGRAPH_OUT;
6733
igraph_integer_t cutoff;
6734
char* shell_arg_res=0;
6740
struct option shell_options[]= { { "graph",required_argument,0,0 },
6741
{ "res",required_argument,0,1 },
6742
{ "vids",required_argument,0,2 },
6743
{ "mode",required_argument,0,3 },
6744
{ "cutoff",required_argument,0,4 },
6745
{ "help",no_argument,0,5 },
6749
/* 0 - not seen, 1 - seen as argument, 2 - seen as default */
6750
memset(shell_seen, 0, 5*sizeof(int));
6754
/* Parse arguments and read input */
6755
while (getopt_long(argc, argv, "", shell_options, &shell_index) != -1) {
6757
if (shell_index==-1) {
6761
if (shell_seen[shell_index]==1) {
6762
fprintf(stderr, "Error, `--%s' argument given twice.\n",
6763
shell_options[shell_index].name);
6766
shell_seen[shell_index]=1;
6768
switch (shell_index) {
6770
shell_read_graph(&graph, optarg);
6773
shell_arg_res=strdup(optarg);
6774
igraph_vector_init(&res, 0);
6777
shell_read_vector(&v_vids, optarg); igraph_vs_vector(&vids, &v_vids);
6780
shell_read_enum(&mode, optarg, "out", 1, "in", 2, "all", 3, "total", 3, 0);
6782
case 4: /* cutoff */
6783
shell_read_integer(&cutoff, optarg);
6786
shell_igraph_closeness_estimate_usage(argv);
6795
/* Check that we have all arguments */
6796
for (shell_index=0; shell_index<5; shell_index++) {
6797
if (!shell_seen[shell_index]) {
6798
fprintf(stderr, "Error, argument missing: `--%s'.\n",
6799
shell_options[shell_index].name);
6804
/* Do the operation */
6805
shell_result=igraph_closeness_estimate(&graph, &res, vids, mode, cutoff);
6807
/* Write the result */
6808
igraph_destroy(&graph);
6809
shell_write_vector(&res, shell_arg_res);
6810
igraph_vector_destroy(&res);
6811
if (!igraph_vs_is_all(&vids)) { igraph_vector_destroy(&v_vids); }
6816
/*-------------------------------------------/
6817
/ igraph_shortest_paths /
6818
/-------------------------------------------*/
6819
void shell_igraph_shortest_paths_usage(char **argv) {
6820
printf("%s --graph=<graph> --res=<res> --from=<from> --mode=<mode>\n", basename(argv[0]));
6824
int shell_igraph_shortest_paths(int argc, char **argv) {
6827
igraph_matrix_t res;
6828
igraph_vector_t v_from; igraph_vs_t from=igraph_vss_all();
6829
igraph_neimode_t mode=IGRAPH_OUT;
6830
char* shell_arg_res=0;
6836
struct option shell_options[]= { { "graph",required_argument,0,0 },
6837
{ "res",required_argument,0,1 },
6838
{ "from",required_argument,0,2 },
6839
{ "mode",required_argument,0,3 },
6840
{ "help",no_argument,0,4 },
6844
/* 0 - not seen, 1 - seen as argument, 2 - seen as default */
6845
memset(shell_seen, 0, 4*sizeof(int));
6849
/* Parse arguments and read input */
6850
while (getopt_long(argc, argv, "", shell_options, &shell_index) != -1) {
6852
if (shell_index==-1) {
6856
if (shell_seen[shell_index]==1) {
6857
fprintf(stderr, "Error, `--%s' argument given twice.\n",
6858
shell_options[shell_index].name);
6861
shell_seen[shell_index]=1;
6863
switch (shell_index) {
6865
shell_read_graph(&graph, optarg);
6868
shell_arg_res=strdup(optarg);
6869
igraph_matrix_init(&res, 0, 0);
6872
shell_read_vector(&v_from, optarg); igraph_vs_vector(&from, &v_from);
6875
shell_read_enum(&mode, optarg, "out", 1, "in", 2, "all", 3, "total", 3, 0);
6878
shell_igraph_shortest_paths_usage(argv);
6887
/* Check that we have all arguments */
6888
for (shell_index=0; shell_index<4; shell_index++) {
6889
if (!shell_seen[shell_index]) {
6890
fprintf(stderr, "Error, argument missing: `--%s'.\n",
6891
shell_options[shell_index].name);
6896
/* Do the operation */
6897
shell_result=igraph_shortest_paths(&graph, &res, from, mode);
6899
/* Write the result */
6900
igraph_destroy(&graph);
6901
shell_write_matrix(&res, shell_arg_res);
6902
igraph_matrix_destroy(&res);
6903
if (!igraph_vs_is_all(&from)) { igraph_vector_destroy(&v_from); }
6908
/*-------------------------------------------/
6909
/ igraph_get_shortest_paths /
6910
/-------------------------------------------*/
6911
void shell_igraph_get_shortest_paths_usage(char **argv) {
6912
printf("%s --graph=<graph> --res=<res> --from=<from> --to=<to> --mode=<mode>\n", basename(argv[0]));
6916
int shell_igraph_get_shortest_paths(int argc, char **argv) {
6919
igraph_vector_ptr_t res;
6920
igraph_integer_t from;
6921
igraph_vector_t v_to; igraph_vs_t to=igraph_vss_all();
6922
igraph_neimode_t mode=IGRAPH_OUT;
6923
char* shell_arg_res=0;
6929
struct option shell_options[]= { { "graph",required_argument,0,0 },
6930
{ "res",required_argument,0,1 },
6931
{ "from",required_argument,0,2 },
6932
{ "to",required_argument,0,3 },
6933
{ "mode",required_argument,0,4 },
6934
{ "help",no_argument,0,5 },
6938
/* 0 - not seen, 1 - seen as argument, 2 - seen as default */
6939
memset(shell_seen, 0, 5*sizeof(int));
6943
/* Parse arguments and read input */
6944
while (getopt_long(argc, argv, "", shell_options, &shell_index) != -1) {
6946
if (shell_index==-1) {
6950
if (shell_seen[shell_index]==1) {
6951
fprintf(stderr, "Error, `--%s' argument given twice.\n",
6952
shell_options[shell_index].name);
6955
shell_seen[shell_index]=1;
6957
switch (shell_index) {
6959
shell_read_graph(&graph, optarg);
6962
igraph_vector_ptr_init(&res, 0);
6965
shell_read_integer(&from, optarg);
6968
shell_read_vector(&v_to, optarg); igraph_vs_vector(&to, &v_to);
6971
shell_read_enum(&mode, optarg, "out", 1, "in", 2, "all", 3, "total", 3, 0);
6974
shell_igraph_get_shortest_paths_usage(argv);
6983
/* Check that we have all arguments */
6984
for (shell_index=0; shell_index<5; shell_index++) {
6985
if (!shell_seen[shell_index]) {
6986
fprintf(stderr, "Error, argument missing: `--%s'.\n",
6987
shell_options[shell_index].name);
6992
/* Do the operation */
6993
shell_result=igraph_get_shortest_paths(&graph, &res, from, to, mode);
6995
/* Write the result */
6996
igraph_destroy(&graph);
6997
shell_write_vectorlist(&res, shell_arg_res);
6998
shell_free_vectorlist(&res);
6999
igraph_vector_ptr_destroy(&res);
7000
if (!igraph_vs_is_all(&to)) { igraph_vector_destroy(&v_to); }
7005
/*-------------------------------------------/
7006
/ igraph_get_all_shortest_paths /
7007
/-------------------------------------------*/
7008
void shell_igraph_get_all_shortest_paths_usage(char **argv) {
7009
printf("%s --graph=<graph> --res=<res> --nrgeo=<nrgeo> --from=<from> --to=<to> --mode=<mode>\n", basename(argv[0]));
7013
int shell_igraph_get_all_shortest_paths(int argc, char **argv) {
7016
igraph_vector_ptr_t res;
7017
igraph_vector_t nrgeo;
7018
igraph_integer_t from;
7019
igraph_vector_t v_to; igraph_vs_t to;
7020
igraph_neimode_t mode=IGRAPH_OUT;
7021
char* shell_arg_res=0;
7022
char* shell_arg_nrgeo=0;
7028
struct option shell_options[]= { { "graph",required_argument,0,0 },
7029
{ "res",required_argument,0,1 },
7030
{ "nrgeo",required_argument,0,2 },
7031
{ "from",required_argument,0,3 },
7032
{ "to",required_argument,0,4 },
7033
{ "mode",required_argument,0,5 },
7034
{ "help",no_argument,0,6 },
7038
/* 0 - not seen, 1 - seen as argument, 2 - seen as default */
7039
memset(shell_seen, 0, 6*sizeof(int));
7042
/* Parse arguments and read input */
7043
while (getopt_long(argc, argv, "", shell_options, &shell_index) != -1) {
7045
if (shell_index==-1) {
7049
if (shell_seen[shell_index]==1) {
7050
fprintf(stderr, "Error, `--%s' argument given twice.\n",
7051
shell_options[shell_index].name);
7054
shell_seen[shell_index]=1;
7056
switch (shell_index) {
7058
shell_read_graph(&graph, optarg);
7061
igraph_vector_ptr_init(&res, 0);
7064
shell_arg_nrgeo=strdup(optarg);
7065
igraph_vector_init(&nrgeo, 0);
7068
shell_read_integer(&from, optarg);
7071
shell_read_vector(&v_to, optarg); igraph_vs_vector(&to, &v_to);
7074
shell_read_enum(&mode, optarg, "out", 1, "in", 2, "all", 3, "total", 3, 0);
7077
shell_igraph_get_all_shortest_paths_usage(argv);
7086
/* Check that we have all arguments */
7087
for (shell_index=0; shell_index<6; shell_index++) {
7088
if (!shell_seen[shell_index]) {
7089
fprintf(stderr, "Error, argument missing: `--%s'.\n",
7090
shell_options[shell_index].name);
7095
/* Do the operation */
7096
shell_result=igraph_get_all_shortest_paths(&graph, &res, &nrgeo, from, to, mode);
7098
/* Write the result */
7099
igraph_destroy(&graph);
7100
shell_write_vectorlist(&res, shell_arg_res);
7101
shell_free_vectorlist(&res);
7102
igraph_vector_ptr_destroy(&res);
7103
shell_write_vector(&nrgeo, shell_arg_nrgeo);
7104
igraph_vector_destroy(&nrgeo);
7105
if (!igraph_vs_is_all(&to)) { igraph_vector_destroy(&v_to); }
7110
/*-------------------------------------------/
7111
/ igraph_shortest_paths_dijkstra /
7112
/-------------------------------------------*/
7113
void shell_igraph_shortest_paths_dijkstra_usage(char **argv) {
7114
printf("%s --graph=<graph> --res=<res> --from=<from> --mode=<mode>\n", basename(argv[0]));
7118
int shell_igraph_shortest_paths_dijkstra(int argc, char **argv) {
7121
igraph_matrix_t res;
7122
igraph_vector_t v_from; igraph_vs_t from=igraph_vss_all();
7124
igraph_neimode_t mode=IGRAPH_OUT;
7125
char* shell_arg_res=0;
7131
struct option shell_options[]= { { "graph",required_argument,0,0 },
7132
{ "res",required_argument,0,1 },
7133
{ "from",required_argument,0,2 },
7134
{ "mode",required_argument,0,3 },
7135
{ "help",no_argument,0,4 },
7139
/* 0 - not seen, 1 - seen as argument, 2 - seen as default */
7140
memset(shell_seen, 0, 4*sizeof(int));
7144
/* Parse arguments and read input */
7145
while (getopt_long(argc, argv, "", shell_options, &shell_index) != -1) {
7147
if (shell_index==-1) {
7151
if (shell_seen[shell_index]==1) {
7152
fprintf(stderr, "Error, `--%s' argument given twice.\n",
7153
shell_options[shell_index].name);
7156
shell_seen[shell_index]=1;
7158
switch (shell_index) {
7160
shell_read_graph(&graph, optarg);
7163
shell_arg_res=strdup(optarg);
7164
igraph_matrix_init(&res, 0, 0);
7167
shell_read_vector(&v_from, optarg); igraph_vs_vector(&from, &v_from);
7170
shell_read_enum(&mode, optarg, "out", 1, "in", 2, "all", 3, "total", 3, 0);
7173
shell_igraph_shortest_paths_dijkstra_usage(argv);
7182
/* Check that we have all arguments */
7183
for (shell_index=0; shell_index<4; shell_index++) {
7184
if (!shell_seen[shell_index]) {
7185
fprintf(stderr, "Error, argument missing: `--%s'.\n",
7186
shell_options[shell_index].name);
7191
/* Do the operation */
7192
shell_result=igraph_shortest_paths_dijkstra(&graph, &res, from, 0, mode);
7194
/* Write the result */
7195
igraph_destroy(&graph);
7196
shell_write_matrix(&res, shell_arg_res);
7197
igraph_matrix_destroy(&res);
7198
if (!igraph_vs_is_all(&from)) { igraph_vector_destroy(&v_from); }
7203
/*-------------------------------------------/
7204
/ igraph_shortest_paths_bellman_ford /
7205
/-------------------------------------------*/
7206
void shell_igraph_shortest_paths_bellman_ford_usage(char **argv) {
7207
printf("%s --graph=<graph> --res=<res> --from=<from> --mode=<mode>\n", basename(argv[0]));
7211
int shell_igraph_shortest_paths_bellman_ford(int argc, char **argv) {
7214
igraph_matrix_t res;
7215
igraph_vector_t v_from; igraph_vs_t from=igraph_vss_all();
7217
igraph_neimode_t mode=IGRAPH_OUT;
7218
char* shell_arg_res=0;
7224
struct option shell_options[]= { { "graph",required_argument,0,0 },
7225
{ "res",required_argument,0,1 },
7226
{ "from",required_argument,0,2 },
7227
{ "mode",required_argument,0,3 },
7228
{ "help",no_argument,0,4 },
7232
/* 0 - not seen, 1 - seen as argument, 2 - seen as default */
7233
memset(shell_seen, 0, 4*sizeof(int));
7237
/* Parse arguments and read input */
7238
while (getopt_long(argc, argv, "", shell_options, &shell_index) != -1) {
7240
if (shell_index==-1) {
7244
if (shell_seen[shell_index]==1) {
7245
fprintf(stderr, "Error, `--%s' argument given twice.\n",
7246
shell_options[shell_index].name);
7249
shell_seen[shell_index]=1;
7251
switch (shell_index) {
7253
shell_read_graph(&graph, optarg);
7256
shell_arg_res=strdup(optarg);
7257
igraph_matrix_init(&res, 0, 0);
7260
shell_read_vector(&v_from, optarg); igraph_vs_vector(&from, &v_from);
7263
shell_read_enum(&mode, optarg, "out", 1, "in", 2, "all", 3, "total", 3, 0);
7266
shell_igraph_shortest_paths_bellman_ford_usage(argv);
7275
/* Check that we have all arguments */
7276
for (shell_index=0; shell_index<4; shell_index++) {
7277
if (!shell_seen[shell_index]) {
7278
fprintf(stderr, "Error, argument missing: `--%s'.\n",
7279
shell_options[shell_index].name);
7284
/* Do the operation */
7285
shell_result=igraph_shortest_paths_bellman_ford(&graph, &res, from, 0, mode);
7287
/* Write the result */
7288
igraph_destroy(&graph);
7289
shell_write_matrix(&res, shell_arg_res);
7290
igraph_matrix_destroy(&res);
7291
if (!igraph_vs_is_all(&from)) { igraph_vector_destroy(&v_from); }
7296
/*-------------------------------------------/
7297
/ igraph_subcomponent /
7298
/-------------------------------------------*/
7299
void shell_igraph_subcomponent_usage(char **argv) {
7300
printf("%s --graph=<graph> --res=<res> --vid=<vid> --mode=<mode>\n", basename(argv[0]));
7304
int shell_igraph_subcomponent(int argc, char **argv) {
7307
igraph_vector_t res;
7309
igraph_neimode_t mode=IGRAPH_ALL;
7310
char* shell_arg_res=0;
7316
struct option shell_options[]= { { "graph",required_argument,0,0 },
7317
{ "res",required_argument,0,1 },
7318
{ "vid",required_argument,0,2 },
7319
{ "mode",required_argument,0,3 },
7320
{ "help",no_argument,0,4 },
7324
/* 0 - not seen, 1 - seen as argument, 2 - seen as default */
7325
memset(shell_seen, 0, 4*sizeof(int));
7328
/* Parse arguments and read input */
7329
while (getopt_long(argc, argv, "", shell_options, &shell_index) != -1) {
7331
if (shell_index==-1) {
7335
if (shell_seen[shell_index]==1) {
7336
fprintf(stderr, "Error, `--%s' argument given twice.\n",
7337
shell_options[shell_index].name);
7340
shell_seen[shell_index]=1;
7342
switch (shell_index) {
7344
shell_read_graph(&graph, optarg);
7347
shell_arg_res=strdup(optarg);
7348
igraph_vector_init(&res, 0);
7351
shell_read_real(&vid, optarg);
7354
shell_read_enum(&mode, optarg, "out", 1, "in", 2, "all", 3, "total", 3, 0);
7357
shell_igraph_subcomponent_usage(argv);
7366
/* Check that we have all arguments */
7367
for (shell_index=0; shell_index<4; shell_index++) {
7368
if (!shell_seen[shell_index]) {
7369
fprintf(stderr, "Error, argument missing: `--%s'.\n",
7370
shell_options[shell_index].name);
7375
/* Do the operation */
7376
shell_result=igraph_subcomponent(&graph, &res, vid, mode);
7378
/* Write the result */
7379
igraph_destroy(&graph);
7380
shell_write_vector(&res, shell_arg_res);
7381
igraph_vector_destroy(&res);
7386
/*-------------------------------------------/
7387
/ igraph_betweenness /
7388
/-------------------------------------------*/
7389
void shell_igraph_betweenness_usage(char **argv) {
7390
printf("%s --graph=<graph> --res=<res> --vids=<vids> --directed=<directed>\n", basename(argv[0]));
7394
int shell_igraph_betweenness(int argc, char **argv) {
7397
igraph_vector_t res;
7398
igraph_vector_t v_vids; igraph_vs_t vids=igraph_vss_all();
7399
igraph_bool_t directed=1;
7400
char* shell_arg_res=0;
7406
struct option shell_options[]= { { "graph",required_argument,0,0 },
7407
{ "res",required_argument,0,1 },
7408
{ "vids",required_argument,0,2 },
7409
{ "directed",required_argument,0,3 },
7410
{ "help",no_argument,0,4 },
7414
/* 0 - not seen, 1 - seen as argument, 2 - seen as default */
7415
memset(shell_seen, 0, 4*sizeof(int));
7419
/* Parse arguments and read input */
7420
while (getopt_long(argc, argv, "", shell_options, &shell_index) != -1) {
7422
if (shell_index==-1) {
7426
if (shell_seen[shell_index]==1) {
7427
fprintf(stderr, "Error, `--%s' argument given twice.\n",
7428
shell_options[shell_index].name);
7431
shell_seen[shell_index]=1;
7433
switch (shell_index) {
7435
shell_read_graph(&graph, optarg);
7438
shell_arg_res=strdup(optarg);
7439
igraph_vector_init(&res, 0);
7442
shell_read_vector(&v_vids, optarg); igraph_vs_vector(&vids, &v_vids);
7444
case 3: /* directed */
7445
shell_read_boolean(&directed, optarg);
7448
shell_igraph_betweenness_usage(argv);
7457
/* Check that we have all arguments */
7458
for (shell_index=0; shell_index<4; shell_index++) {
7459
if (!shell_seen[shell_index]) {
7460
fprintf(stderr, "Error, argument missing: `--%s'.\n",
7461
shell_options[shell_index].name);
7466
/* Do the operation */
7467
shell_result=igraph_betweenness(&graph, &res, vids, directed);
7469
/* Write the result */
7470
igraph_destroy(&graph);
7471
shell_write_vector(&res, shell_arg_res);
7472
igraph_vector_destroy(&res);
7473
if (!igraph_vs_is_all(&vids)) { igraph_vector_destroy(&v_vids); }
7478
/*-------------------------------------------/
7479
/ igraph_betweenness_estimate /
7480
/-------------------------------------------*/
7481
void shell_igraph_betweenness_estimate_usage(char **argv) {
7482
printf("%s --graph=<graph> --res=<res> --vids=<vids> --directed=<directed> --cutoff=<cutoff>\n", basename(argv[0]));
7486
int shell_igraph_betweenness_estimate(int argc, char **argv) {
7489
igraph_vector_t res;
7490
igraph_vector_t v_vids; igraph_vs_t vids=igraph_vss_all();
7491
igraph_bool_t directed=1;
7492
igraph_integer_t cutoff;
7493
char* shell_arg_res=0;
7499
struct option shell_options[]= { { "graph",required_argument,0,0 },
7500
{ "res",required_argument,0,1 },
7501
{ "vids",required_argument,0,2 },
7502
{ "directed",required_argument,0,3 },
7503
{ "cutoff",required_argument,0,4 },
7504
{ "help",no_argument,0,5 },
7508
/* 0 - not seen, 1 - seen as argument, 2 - seen as default */
7509
memset(shell_seen, 0, 5*sizeof(int));
7513
/* Parse arguments and read input */
7514
while (getopt_long(argc, argv, "", shell_options, &shell_index) != -1) {
7516
if (shell_index==-1) {
7520
if (shell_seen[shell_index]==1) {
7521
fprintf(stderr, "Error, `--%s' argument given twice.\n",
7522
shell_options[shell_index].name);
7525
shell_seen[shell_index]=1;
7527
switch (shell_index) {
7529
shell_read_graph(&graph, optarg);
7532
shell_arg_res=strdup(optarg);
7533
igraph_vector_init(&res, 0);
7536
shell_read_vector(&v_vids, optarg); igraph_vs_vector(&vids, &v_vids);
7538
case 3: /* directed */
7539
shell_read_boolean(&directed, optarg);
7541
case 4: /* cutoff */
7542
shell_read_integer(&cutoff, optarg);
7545
shell_igraph_betweenness_estimate_usage(argv);
7554
/* Check that we have all arguments */
7555
for (shell_index=0; shell_index<5; shell_index++) {
7556
if (!shell_seen[shell_index]) {
7557
fprintf(stderr, "Error, argument missing: `--%s'.\n",
7558
shell_options[shell_index].name);
7563
/* Do the operation */
7564
shell_result=igraph_betweenness_estimate(&graph, &res, vids, directed, cutoff);
7566
/* Write the result */
7567
igraph_destroy(&graph);
7568
shell_write_vector(&res, shell_arg_res);
7569
igraph_vector_destroy(&res);
7570
if (!igraph_vs_is_all(&vids)) { igraph_vector_destroy(&v_vids); }
7575
/*-------------------------------------------/
7576
/ igraph_edge_betweenness /
7577
/-------------------------------------------*/
7578
void shell_igraph_edge_betweenness_usage(char **argv) {
7579
printf("%s --graph=<graph> --res=<res> --directed=<directed>\n", basename(argv[0]));
7583
int shell_igraph_edge_betweenness(int argc, char **argv) {
7586
igraph_vector_t res;
7587
igraph_bool_t directed=1;
7588
char* shell_arg_res=0;
7594
struct option shell_options[]= { { "graph",required_argument,0,0 },
7595
{ "res",required_argument,0,1 },
7596
{ "directed",required_argument,0,2 },
7597
{ "help",no_argument,0,3 },
7601
/* 0 - not seen, 1 - seen as argument, 2 - seen as default */
7602
memset(shell_seen, 0, 3*sizeof(int));
7605
/* Parse arguments and read input */
7606
while (getopt_long(argc, argv, "", shell_options, &shell_index) != -1) {
7608
if (shell_index==-1) {
7612
if (shell_seen[shell_index]==1) {
7613
fprintf(stderr, "Error, `--%s' argument given twice.\n",
7614
shell_options[shell_index].name);
7617
shell_seen[shell_index]=1;
7619
switch (shell_index) {
7621
shell_read_graph(&graph, optarg);
7624
shell_arg_res=strdup(optarg);
7625
igraph_vector_init(&res, 0);
7627
case 2: /* directed */
7628
shell_read_boolean(&directed, optarg);
7631
shell_igraph_edge_betweenness_usage(argv);
7640
/* Check that we have all arguments */
7641
for (shell_index=0; shell_index<3; shell_index++) {
7642
if (!shell_seen[shell_index]) {
7643
fprintf(stderr, "Error, argument missing: `--%s'.\n",
7644
shell_options[shell_index].name);
7649
/* Do the operation */
7650
shell_result=igraph_edge_betweenness(&graph, &res, directed);
7652
/* Write the result */
7653
igraph_destroy(&graph);
7654
shell_write_vector(&res, shell_arg_res);
7655
igraph_vector_destroy(&res);
7660
/*-------------------------------------------/
7661
/ igraph_edge_betweenness_estimate /
7662
/-------------------------------------------*/
7663
void shell_igraph_edge_betweenness_estimate_usage(char **argv) {
7664
printf("%s --graph=<graph> --res=<res> --directed=<directed> --cutoff=<cutoff>\n", basename(argv[0]));
7668
int shell_igraph_edge_betweenness_estimate(int argc, char **argv) {
7671
igraph_vector_t res;
7672
igraph_bool_t directed=1;
7673
igraph_integer_t cutoff;
7674
char* shell_arg_res=0;
7680
struct option shell_options[]= { { "graph",required_argument,0,0 },
7681
{ "res",required_argument,0,1 },
7682
{ "directed",required_argument,0,2 },
7683
{ "cutoff",required_argument,0,3 },
7684
{ "help",no_argument,0,4 },
7688
/* 0 - not seen, 1 - seen as argument, 2 - seen as default */
7689
memset(shell_seen, 0, 4*sizeof(int));
7692
/* Parse arguments and read input */
7693
while (getopt_long(argc, argv, "", shell_options, &shell_index) != -1) {
7695
if (shell_index==-1) {
7699
if (shell_seen[shell_index]==1) {
7700
fprintf(stderr, "Error, `--%s' argument given twice.\n",
7701
shell_options[shell_index].name);
7704
shell_seen[shell_index]=1;
7706
switch (shell_index) {
7708
shell_read_graph(&graph, optarg);
7711
shell_arg_res=strdup(optarg);
7712
igraph_vector_init(&res, 0);
7714
case 2: /* directed */
7715
shell_read_boolean(&directed, optarg);
7717
case 3: /* cutoff */
7718
shell_read_integer(&cutoff, optarg);
7721
shell_igraph_edge_betweenness_estimate_usage(argv);
7730
/* Check that we have all arguments */
7731
for (shell_index=0; shell_index<4; shell_index++) {
7732
if (!shell_seen[shell_index]) {
7733
fprintf(stderr, "Error, argument missing: `--%s'.\n",
7734
shell_options[shell_index].name);
7739
/* Do the operation */
7740
shell_result=igraph_edge_betweenness_estimate(&graph, &res, directed, cutoff);
7742
/* Write the result */
7743
igraph_destroy(&graph);
7744
shell_write_vector(&res, shell_arg_res);
7745
igraph_vector_destroy(&res);
7750
/*-------------------------------------------/
7751
/ igraph_pagerank_old /
7752
/-------------------------------------------*/
7753
void shell_igraph_pagerank_old_usage(char **argv) {
7754
printf("%s --graph=<graph> --res=<res> --vids=<vids> --directed=<directed> --niter=<niter> --eps=<eps> --damping=<damping> --old=<old>\n", basename(argv[0]));
7758
int shell_igraph_pagerank_old(int argc, char **argv) {
7761
igraph_vector_t res;
7762
igraph_vector_t v_vids; igraph_vs_t vids=igraph_vss_all();
7763
igraph_bool_t directed=1;
7764
igraph_integer_t niter=1000;
7765
igraph_real_t eps=0.001;
7766
igraph_real_t damping=0.85;
7767
igraph_bool_t old=0;
7768
char* shell_arg_res=0;
7774
struct option shell_options[]= { { "graph",required_argument,0,0 },
7775
{ "res",required_argument,0,1 },
7776
{ "vids",required_argument,0,2 },
7777
{ "directed",required_argument,0,3 },
7778
{ "niter",required_argument,0,4 },
7779
{ "eps",required_argument,0,5 },
7780
{ "damping",required_argument,0,6 },
7781
{ "old",required_argument,0,7 },
7782
{ "help",no_argument,0,8 },
7786
/* 0 - not seen, 1 - seen as argument, 2 - seen as default */
7787
memset(shell_seen, 0, 8*sizeof(int));
7795
/* Parse arguments and read input */
7796
while (getopt_long(argc, argv, "", shell_options, &shell_index) != -1) {
7798
if (shell_index==-1) {
7802
if (shell_seen[shell_index]==1) {
7803
fprintf(stderr, "Error, `--%s' argument given twice.\n",
7804
shell_options[shell_index].name);
7807
shell_seen[shell_index]=1;
7809
switch (shell_index) {
7811
shell_read_graph(&graph, optarg);
7814
shell_arg_res=strdup(optarg);
7815
igraph_vector_init(&res, 0);
7818
shell_read_vector(&v_vids, optarg); igraph_vs_vector(&vids, &v_vids);
7820
case 3: /* directed */
7821
shell_read_boolean(&directed, optarg);
7824
shell_read_integer(&niter, optarg);
7827
shell_read_real(&eps, optarg);
7829
case 6: /* damping */
7830
shell_read_real(&damping, optarg);
7833
shell_read_boolean(&old, optarg);
7836
shell_igraph_pagerank_old_usage(argv);
7845
/* Check that we have all arguments */
7846
for (shell_index=0; shell_index<8; shell_index++) {
7847
if (!shell_seen[shell_index]) {
7848
fprintf(stderr, "Error, argument missing: `--%s'.\n",
7849
shell_options[shell_index].name);
7854
/* Do the operation */
7855
shell_result=igraph_pagerank_old(&graph, &res, vids, directed, niter, eps, damping, old);
7857
/* Write the result */
7858
igraph_destroy(&graph);
7859
shell_write_vector(&res, shell_arg_res);
7860
igraph_vector_destroy(&res);
7861
if (!igraph_vs_is_all(&vids)) { igraph_vector_destroy(&v_vids); }
7866
/*-------------------------------------------/
7868
/-------------------------------------------*/
7869
void shell_igraph_pagerank_usage(char **argv) {
7870
printf("%s --graph=<graph> --vector=<vector> --value=<value> --vids=<vids> --directed=<directed> --damping=<damping>\n", basename(argv[0]));
7874
int shell_igraph_pagerank(int argc, char **argv) {
7877
igraph_vector_t vector;
7878
igraph_real_t value;
7879
igraph_vector_t v_vids; igraph_vs_t vids=igraph_vss_all();
7880
igraph_bool_t directed=1;
7881
igraph_real_t damping=0.85;
7884
char* shell_arg_vector=0;
7885
char* shell_arg_value=0;
7886
char* shell_arg_options=0;
7892
struct option shell_options[]= { { "graph",required_argument,0,0 },
7893
{ "vector",required_argument,0,1 },
7894
{ "value",required_argument,0,2 },
7895
{ "vids",required_argument,0,3 },
7896
{ "directed",required_argument,0,4 },
7897
{ "damping",required_argument,0,5 },
7898
{ "help",no_argument,0,6 },
7902
/* 0 - not seen, 1 - seen as argument, 2 - seen as default */
7903
memset(shell_seen, 0, 6*sizeof(int));
7908
/* Parse arguments and read input */
7909
while (getopt_long(argc, argv, "", shell_options, &shell_index) != -1) {
7911
if (shell_index==-1) {
7915
if (shell_seen[shell_index]==1) {
7916
fprintf(stderr, "Error, `--%s' argument given twice.\n",
7917
shell_options[shell_index].name);
7920
shell_seen[shell_index]=1;
7922
switch (shell_index) {
7924
shell_read_graph(&graph, optarg);
7926
case 1: /* vector */
7927
shell_arg_vector=strdup(optarg);
7928
igraph_vector_init(&vector, 0);
7931
shell_arg_value=strdup(optarg);
7934
shell_read_vector(&v_vids, optarg); igraph_vs_vector(&vids, &v_vids);
7936
case 4: /* directed */
7937
shell_read_boolean(&directed, optarg);
7939
case 5: /* damping */
7940
shell_read_real(&damping, optarg);
7943
shell_igraph_pagerank_usage(argv);
7952
/* Check that we have all arguments */
7953
for (shell_index=0; shell_index<6; shell_index++) {
7954
if (!shell_seen[shell_index]) {
7955
fprintf(stderr, "Error, argument missing: `--%s'.\n",
7956
shell_options[shell_index].name);
7961
/* Do the operation */
7962
shell_result=igraph_pagerank(&graph, &vector, &value, vids, directed, damping, 0, 0);
7964
/* Write the result */
7965
igraph_destroy(&graph);
7966
shell_write_vector(&vector, shell_arg_vector);
7967
igraph_vector_destroy(&vector);
7968
shell_write_real(value, shell_arg_value);
7969
if (!igraph_vs_is_all(&vids)) { igraph_vector_destroy(&v_vids); }
7974
/*-------------------------------------------/
7976
/-------------------------------------------*/
7977
void shell_igraph_rewire_usage(char **argv) {
7978
printf("%s --rewire=<rewire> --rewire-out=<rewire-out> --n=<n> --mode=<mode>\n", basename(argv[0]));
7982
int shell_igraph_rewire(int argc, char **argv) {
7986
igraph_rewiring_t mode=IGRAPH_REWIRING_SIMPLE;
7987
char* shell_arg_rewire=0;
7993
struct option shell_options[]= { { "rewire",required_argument,0,0 },
7994
{ "rewire-out",required_argument,0,1 },
7995
{ "n",required_argument,0,2 },
7996
{ "mode",required_argument,0,3 },
7997
{ "help",no_argument,0,4 },
8001
/* 0 - not seen, 1 - seen as argument, 2 - seen as default */
8002
memset(shell_seen, 0, 4*sizeof(int));
8005
/* Parse arguments and read input */
8006
while (getopt_long(argc, argv, "", shell_options, &shell_index) != -1) {
8008
if (shell_index==-1) {
8012
if (shell_seen[shell_index]==1) {
8013
fprintf(stderr, "Error, `--%s' argument given twice.\n",
8014
shell_options[shell_index].name);
8017
shell_seen[shell_index]=1;
8019
switch (shell_index) {
8020
case 0: /* rewire */
8021
shell_read_graph(&rewire, optarg);
8023
case 1: /* rewire-out */
8024
shell_arg_rewire=strdup(optarg);
8027
shell_read_integer(&n, optarg);
8030
shell_read_enum(&mode, optarg, "simple", 0, 0);
8033
shell_igraph_rewire_usage(argv);
8042
/* Check that we have all arguments */
8043
for (shell_index=0; shell_index<4; shell_index++) {
8044
if (!shell_seen[shell_index]) {
8045
fprintf(stderr, "Error, argument missing: `--%s'.\n",
8046
shell_options[shell_index].name);
8051
/* Do the operation */
8052
shell_result=igraph_rewire(&rewire, n, mode);
8054
/* Write the result */
8055
igraph_destroy(&rewire);
8056
shell_write_graph(&rewire, shell_arg_rewire);
8057
igraph_destroy(&rewire);
8062
/*-------------------------------------------/
8064
/-------------------------------------------*/
8065
void shell_igraph_subgraph_usage(char **argv) {
8066
printf("%s --graph=<graph> --res=<res> --vids=<vids>\n", basename(argv[0]));
8070
int shell_igraph_subgraph(int argc, char **argv) {
8074
igraph_vector_t v_vids; igraph_vs_t vids;
8075
char* shell_arg_res=0;
8081
struct option shell_options[]= { { "graph",required_argument,0,0 },
8082
{ "res",required_argument,0,1 },
8083
{ "vids",required_argument,0,2 },
8084
{ "help",no_argument,0,3 },
8088
/* 0 - not seen, 1 - seen as argument, 2 - seen as default */
8089
memset(shell_seen, 0, 3*sizeof(int));
8092
/* Parse arguments and read input */
8093
while (getopt_long(argc, argv, "", shell_options, &shell_index) != -1) {
8095
if (shell_index==-1) {
8099
if (shell_seen[shell_index]==1) {
8100
fprintf(stderr, "Error, `--%s' argument given twice.\n",
8101
shell_options[shell_index].name);
8104
shell_seen[shell_index]=1;
8106
switch (shell_index) {
8108
shell_read_graph(&graph, optarg);
8111
shell_arg_res=strdup(optarg);
8114
shell_read_vector(&v_vids, optarg); igraph_vs_vector(&vids, &v_vids);
8117
shell_igraph_subgraph_usage(argv);
8126
/* Check that we have all arguments */
8127
for (shell_index=0; shell_index<3; shell_index++) {
8128
if (!shell_seen[shell_index]) {
8129
fprintf(stderr, "Error, argument missing: `--%s'.\n",
8130
shell_options[shell_index].name);
8135
/* Do the operation */
8136
shell_result=igraph_subgraph(&graph, &res, vids);
8138
/* Write the result */
8139
igraph_destroy(&graph);
8140
shell_write_graph(&res, shell_arg_res);
8141
igraph_destroy(&res);
8142
if (!igraph_vs_is_all(&vids)) { igraph_vector_destroy(&v_vids); }
8147
/*-------------------------------------------/
8148
/ igraph_average_path_length /
8149
/-------------------------------------------*/
8150
void shell_igraph_average_path_length_usage(char **argv) {
8151
printf("%s --graph=<graph> --res=<res> --directed=<directed> --unconn=<unconn>\n", basename(argv[0]));
8155
int shell_igraph_average_path_length(int argc, char **argv) {
8159
igraph_bool_t directed=1;
8160
igraph_bool_t unconn=1;
8161
char* shell_arg_res=0;
8167
struct option shell_options[]= { { "graph",required_argument,0,0 },
8168
{ "res",required_argument,0,1 },
8169
{ "directed",required_argument,0,2 },
8170
{ "unconn",required_argument,0,3 },
8171
{ "help",no_argument,0,4 },
8175
/* 0 - not seen, 1 - seen as argument, 2 - seen as default */
8176
memset(shell_seen, 0, 4*sizeof(int));
8180
/* Parse arguments and read input */
8181
while (getopt_long(argc, argv, "", shell_options, &shell_index) != -1) {
8183
if (shell_index==-1) {
8187
if (shell_seen[shell_index]==1) {
8188
fprintf(stderr, "Error, `--%s' argument given twice.\n",
8189
shell_options[shell_index].name);
8192
shell_seen[shell_index]=1;
8194
switch (shell_index) {
8196
shell_read_graph(&graph, optarg);
8199
shell_arg_res=strdup(optarg);
8201
case 2: /* directed */
8202
shell_read_boolean(&directed, optarg);
8204
case 3: /* unconn */
8205
shell_read_boolean(&unconn, optarg);
8208
shell_igraph_average_path_length_usage(argv);
8217
/* Check that we have all arguments */
8218
for (shell_index=0; shell_index<4; shell_index++) {
8219
if (!shell_seen[shell_index]) {
8220
fprintf(stderr, "Error, argument missing: `--%s'.\n",
8221
shell_options[shell_index].name);
8226
/* Do the operation */
8227
shell_result=igraph_average_path_length(&graph, &res, directed, unconn);
8229
/* Write the result */
8230
igraph_destroy(&graph);
8231
shell_write_real(res, shell_arg_res);
8236
/*-------------------------------------------/
8237
/ igraph_path_length_hist /
8238
/-------------------------------------------*/
8239
void shell_igraph_path_length_hist_usage(char **argv) {
8240
printf("%s --graph=<graph> --res=<res> --unconnected=<unconnected> --directed=<directed>\n", basename(argv[0]));
8244
int shell_igraph_path_length_hist(int argc, char **argv) {
8247
igraph_vector_t res;
8248
igraph_real_t unconnected;
8249
igraph_bool_t directed=1;
8250
char* shell_arg_res=0;
8251
char* shell_arg_unconnected=0;
8257
struct option shell_options[]= { { "graph",required_argument,0,0 },
8258
{ "res",required_argument,0,1 },
8259
{ "unconnected",required_argument,0,2 },
8260
{ "directed",required_argument,0,3 },
8261
{ "help",no_argument,0,4 },
8265
/* 0 - not seen, 1 - seen as argument, 2 - seen as default */
8266
memset(shell_seen, 0, 4*sizeof(int));
8269
/* Parse arguments and read input */
8270
while (getopt_long(argc, argv, "", shell_options, &shell_index) != -1) {
8272
if (shell_index==-1) {
8276
if (shell_seen[shell_index]==1) {
8277
fprintf(stderr, "Error, `--%s' argument given twice.\n",
8278
shell_options[shell_index].name);
8281
shell_seen[shell_index]=1;
8283
switch (shell_index) {
8285
shell_read_graph(&graph, optarg);
8288
shell_arg_res=strdup(optarg);
8289
igraph_vector_init(&res, 0);
8291
case 2: /* unconnected */
8292
shell_arg_unconnected=strdup(optarg);
8294
case 3: /* directed */
8295
shell_read_boolean(&directed, optarg);
8298
shell_igraph_path_length_hist_usage(argv);
8307
/* Check that we have all arguments */
8308
for (shell_index=0; shell_index<4; shell_index++) {
8309
if (!shell_seen[shell_index]) {
8310
fprintf(stderr, "Error, argument missing: `--%s'.\n",
8311
shell_options[shell_index].name);
8316
/* Do the operation */
8317
shell_result=igraph_path_length_hist(&graph, &res, &unconnected, directed);
8319
/* Write the result */
8320
igraph_destroy(&graph);
8321
shell_write_vector(&res, shell_arg_res);
8322
igraph_vector_destroy(&res);
8323
shell_write_real(unconnected, shell_arg_unconnected);
8328
/*-------------------------------------------/
8330
/-------------------------------------------*/
8331
void shell_igraph_simplify_usage(char **argv) {
8332
printf("%s --graph=<graph> --graph-out=<graph-out> --multiple=<multiple> --loops=<loops>\n", basename(argv[0]));
8336
int shell_igraph_simplify(int argc, char **argv) {
8339
igraph_bool_t multiple=1;
8340
igraph_bool_t loops=1;
8341
char* shell_arg_graph=0;
8347
struct option shell_options[]= { { "graph",required_argument,0,0 },
8348
{ "graph-out",required_argument,0,1 },
8349
{ "multiple",required_argument,0,2 },
8350
{ "loops",required_argument,0,3 },
8351
{ "help",no_argument,0,4 },
8355
/* 0 - not seen, 1 - seen as argument, 2 - seen as default */
8356
memset(shell_seen, 0, 4*sizeof(int));
8360
/* Parse arguments and read input */
8361
while (getopt_long(argc, argv, "", shell_options, &shell_index) != -1) {
8363
if (shell_index==-1) {
8367
if (shell_seen[shell_index]==1) {
8368
fprintf(stderr, "Error, `--%s' argument given twice.\n",
8369
shell_options[shell_index].name);
8372
shell_seen[shell_index]=1;
8374
switch (shell_index) {
8376
shell_read_graph(&graph, optarg);
8378
case 1: /* graph-out */
8379
shell_arg_graph=strdup(optarg);
8381
case 2: /* multiple */
8382
shell_read_boolean(&multiple, optarg);
8385
shell_read_boolean(&loops, optarg);
8388
shell_igraph_simplify_usage(argv);
8397
/* Check that we have all arguments */
8398
for (shell_index=0; shell_index<4; shell_index++) {
8399
if (!shell_seen[shell_index]) {
8400
fprintf(stderr, "Error, argument missing: `--%s'.\n",
8401
shell_options[shell_index].name);
8406
/* Do the operation */
8407
shell_result=igraph_simplify(&graph, multiple, loops);
8409
/* Write the result */
8410
igraph_destroy(&graph);
8411
shell_write_graph(&graph, shell_arg_graph);
8412
igraph_destroy(&graph);
8417
/*-------------------------------------------/
8418
/ igraph_transitivity_undirected /
8419
/-------------------------------------------*/
8420
void shell_igraph_transitivity_undirected_usage(char **argv) {
8421
printf("%s --graph=<graph> --res=<res>\n", basename(argv[0]));
8425
int shell_igraph_transitivity_undirected(int argc, char **argv) {
8429
char* shell_arg_res=0;
8435
struct option shell_options[]= { { "graph",required_argument,0,0 },
8436
{ "res",required_argument,0,1 },
8437
{ "help",no_argument,0,2 },
8441
/* 0 - not seen, 1 - seen as argument, 2 - seen as default */
8442
memset(shell_seen, 0, 2*sizeof(int));
8445
/* Parse arguments and read input */
8446
while (getopt_long(argc, argv, "", shell_options, &shell_index) != -1) {
8448
if (shell_index==-1) {
8452
if (shell_seen[shell_index]==1) {
8453
fprintf(stderr, "Error, `--%s' argument given twice.\n",
8454
shell_options[shell_index].name);
8457
shell_seen[shell_index]=1;
8459
switch (shell_index) {
8461
shell_read_graph(&graph, optarg);
8464
shell_arg_res=strdup(optarg);
8467
shell_igraph_transitivity_undirected_usage(argv);
8476
/* Check that we have all arguments */
8477
for (shell_index=0; shell_index<2; shell_index++) {
8478
if (!shell_seen[shell_index]) {
8479
fprintf(stderr, "Error, argument missing: `--%s'.\n",
8480
shell_options[shell_index].name);
8485
/* Do the operation */
8486
shell_result=igraph_transitivity_undirected(&graph, &res);
8488
/* Write the result */
8489
igraph_destroy(&graph);
8490
shell_write_real(res, shell_arg_res);
8495
/*-------------------------------------------/
8496
/ igraph_transitivity_local_undirected /
8497
/-------------------------------------------*/
8498
void shell_igraph_transitivity_local_undirected_usage(char **argv) {
8499
printf("%s --graph=<graph> --res=<res> --vids=<vids>\n", basename(argv[0]));
8503
int shell_igraph_transitivity_local_undirected(int argc, char **argv) {
8506
igraph_vector_t res;
8507
igraph_vector_t v_vids; igraph_vs_t vids=igraph_vss_all();
8508
char* shell_arg_res=0;
8514
struct option shell_options[]= { { "graph",required_argument,0,0 },
8515
{ "res",required_argument,0,1 },
8516
{ "vids",required_argument,0,2 },
8517
{ "help",no_argument,0,3 },
8521
/* 0 - not seen, 1 - seen as argument, 2 - seen as default */
8522
memset(shell_seen, 0, 3*sizeof(int));
8525
/* Parse arguments and read input */
8526
while (getopt_long(argc, argv, "", shell_options, &shell_index) != -1) {
8528
if (shell_index==-1) {
8532
if (shell_seen[shell_index]==1) {
8533
fprintf(stderr, "Error, `--%s' argument given twice.\n",
8534
shell_options[shell_index].name);
8537
shell_seen[shell_index]=1;
8539
switch (shell_index) {
8541
shell_read_graph(&graph, optarg);
8544
shell_arg_res=strdup(optarg);
8545
igraph_vector_init(&res, 0);
8548
shell_read_vector(&v_vids, optarg); igraph_vs_vector(&vids, &v_vids);
8551
shell_igraph_transitivity_local_undirected_usage(argv);
8560
/* Check that we have all arguments */
8561
for (shell_index=0; shell_index<3; shell_index++) {
8562
if (!shell_seen[shell_index]) {
8563
fprintf(stderr, "Error, argument missing: `--%s'.\n",
8564
shell_options[shell_index].name);
8569
/* Do the operation */
8570
shell_result=igraph_transitivity_local_undirected(&graph, &res, vids);
8572
/* Write the result */
8573
igraph_destroy(&graph);
8574
shell_write_vector(&res, shell_arg_res);
8575
igraph_vector_destroy(&res);
8576
if (!igraph_vs_is_all(&vids)) { igraph_vector_destroy(&v_vids); }
8581
/*-------------------------------------------/
8582
/ igraph_transitivity_avglocal_undirected /
8583
/-------------------------------------------*/
8584
void shell_igraph_transitivity_avglocal_undirected_usage(char **argv) {
8585
printf("%s --graph=<graph> --res=<res>\n", basename(argv[0]));
8589
int shell_igraph_transitivity_avglocal_undirected(int argc, char **argv) {
8593
char* shell_arg_res=0;
8599
struct option shell_options[]= { { "graph",required_argument,0,0 },
8600
{ "res",required_argument,0,1 },
8601
{ "help",no_argument,0,2 },
8605
/* 0 - not seen, 1 - seen as argument, 2 - seen as default */
8606
memset(shell_seen, 0, 2*sizeof(int));
8609
/* Parse arguments and read input */
8610
while (getopt_long(argc, argv, "", shell_options, &shell_index) != -1) {
8612
if (shell_index==-1) {
8616
if (shell_seen[shell_index]==1) {
8617
fprintf(stderr, "Error, `--%s' argument given twice.\n",
8618
shell_options[shell_index].name);
8621
shell_seen[shell_index]=1;
8623
switch (shell_index) {
8625
shell_read_graph(&graph, optarg);
8628
shell_arg_res=strdup(optarg);
8631
shell_igraph_transitivity_avglocal_undirected_usage(argv);
8640
/* Check that we have all arguments */
8641
for (shell_index=0; shell_index<2; shell_index++) {
8642
if (!shell_seen[shell_index]) {
8643
fprintf(stderr, "Error, argument missing: `--%s'.\n",
8644
shell_options[shell_index].name);
8649
/* Do the operation */
8650
shell_result=igraph_transitivity_avglocal_undirected(&graph, &res);
8652
/* Write the result */
8653
igraph_destroy(&graph);
8654
shell_write_real(res, shell_arg_res);
8659
/*-------------------------------------------/
8660
/ igraph_reciprocity /
8661
/-------------------------------------------*/
8662
void shell_igraph_reciprocity_usage(char **argv) {
8663
printf("%s --graph=<graph> --res=<res> --ignore_loops=<ignore_loops>\n", basename(argv[0]));
8667
int shell_igraph_reciprocity(int argc, char **argv) {
8671
igraph_bool_t ignore_loops=1;
8672
char* shell_arg_res=0;
8678
struct option shell_options[]= { { "graph",required_argument,0,0 },
8679
{ "res",required_argument,0,1 },
8680
{ "ignore_loops",required_argument,0,2 },
8681
{ "help",no_argument,0,3 },
8685
/* 0 - not seen, 1 - seen as argument, 2 - seen as default */
8686
memset(shell_seen, 0, 3*sizeof(int));
8689
/* Parse arguments and read input */
8690
while (getopt_long(argc, argv, "", shell_options, &shell_index) != -1) {
8692
if (shell_index==-1) {
8696
if (shell_seen[shell_index]==1) {
8697
fprintf(stderr, "Error, `--%s' argument given twice.\n",
8698
shell_options[shell_index].name);
8701
shell_seen[shell_index]=1;
8703
switch (shell_index) {
8705
shell_read_graph(&graph, optarg);
8708
shell_arg_res=strdup(optarg);
8710
case 2: /* ignore_loops */
8711
shell_read_boolean(&ignore_loops, optarg);
8714
shell_igraph_reciprocity_usage(argv);
8723
/* Check that we have all arguments */
8724
for (shell_index=0; shell_index<3; shell_index++) {
8725
if (!shell_seen[shell_index]) {
8726
fprintf(stderr, "Error, argument missing: `--%s'.\n",
8727
shell_options[shell_index].name);
8732
/* Do the operation */
8733
shell_result=igraph_reciprocity(&graph, &res, ignore_loops);
8735
/* Write the result */
8736
igraph_destroy(&graph);
8737
shell_write_real(res, shell_arg_res);
8742
/*-------------------------------------------/
8743
/ igraph_constraint /
8744
/-------------------------------------------*/
8745
void shell_igraph_constraint_usage(char **argv) {
8746
printf("%s --graph=<graph> --res=<res> --vids=<vids> --weights=<weights>\n", basename(argv[0]));
8750
int shell_igraph_constraint(int argc, char **argv) {
8753
igraph_vector_t res;
8754
igraph_vector_t v_vids; igraph_vs_t vids=igraph_vss_all();
8755
igraph_vector_t v_weights; igraph_vector_t *weights=0;
8756
char* shell_arg_res=0;
8762
struct option shell_options[]= { { "graph",required_argument,0,0 },
8763
{ "res",required_argument,0,1 },
8764
{ "vids",required_argument,0,2 },
8765
{ "weights",required_argument,0,3 },
8766
{ "help",no_argument,0,4 },
8770
/* 0 - not seen, 1 - seen as argument, 2 - seen as default */
8771
memset(shell_seen, 0, 4*sizeof(int));
8774
/* Parse arguments and read input */
8775
while (getopt_long(argc, argv, "", shell_options, &shell_index) != -1) {
8777
if (shell_index==-1) {
8781
if (shell_seen[shell_index]==1) {
8782
fprintf(stderr, "Error, `--%s' argument given twice.\n",
8783
shell_options[shell_index].name);
8786
shell_seen[shell_index]=1;
8788
switch (shell_index) {
8790
shell_read_graph(&graph, optarg);
8793
shell_arg_res=strdup(optarg);
8794
igraph_vector_init(&res, 0);
8797
shell_read_vector(&v_vids, optarg); igraph_vs_vector(&vids, &v_vids);
8799
case 3: /* weights */
8800
weights=&v_weights; shell_read_vector(weights, optarg);
8803
shell_igraph_constraint_usage(argv);
8812
/* Check that we have all arguments */
8813
for (shell_index=0; shell_index<4; shell_index++) {
8814
if (!shell_seen[shell_index]) {
8815
fprintf(stderr, "Error, argument missing: `--%s'.\n",
8816
shell_options[shell_index].name);
8821
/* Do the operation */
8822
shell_result=igraph_constraint(&graph, &res, vids, weights);
8824
/* Write the result */
8825
igraph_destroy(&graph);
8826
shell_write_vector(&res, shell_arg_res);
8827
igraph_vector_destroy(&res);
8828
if (!igraph_vs_is_all(&vids)) { igraph_vector_destroy(&v_vids); }
8829
if (weights) { igraph_vector_destroy(weights); }
8834
/*-------------------------------------------/
8835
/ igraph_maxdegree /
8836
/-------------------------------------------*/
8837
void shell_igraph_maxdegree_usage(char **argv) {
8838
printf("%s --graph=<graph> --res=<res> --vids=<vids> --mode=<mode> --loops=<loops>\n", basename(argv[0]));
8842
int shell_igraph_maxdegree(int argc, char **argv) {
8845
igraph_integer_t res;
8846
igraph_vector_t v_vids; igraph_vs_t vids=igraph_vss_all();
8847
igraph_neimode_t mode=IGRAPH_ALL;
8848
igraph_bool_t loops=1;
8849
char* shell_arg_res=0;
8855
struct option shell_options[]= { { "graph",required_argument,0,0 },
8856
{ "res",required_argument,0,1 },
8857
{ "vids",required_argument,0,2 },
8858
{ "mode",required_argument,0,3 },
8859
{ "loops",required_argument,0,4 },
8860
{ "help",no_argument,0,5 },
8864
/* 0 - not seen, 1 - seen as argument, 2 - seen as default */
8865
memset(shell_seen, 0, 5*sizeof(int));
8870
/* Parse arguments and read input */
8871
while (getopt_long(argc, argv, "", shell_options, &shell_index) != -1) {
8873
if (shell_index==-1) {
8877
if (shell_seen[shell_index]==1) {
8878
fprintf(stderr, "Error, `--%s' argument given twice.\n",
8879
shell_options[shell_index].name);
8882
shell_seen[shell_index]=1;
8884
switch (shell_index) {
8886
shell_read_graph(&graph, optarg);
8889
shell_arg_res=strdup(optarg);
8892
shell_read_vector(&v_vids, optarg); igraph_vs_vector(&vids, &v_vids);
8895
shell_read_enum(&mode, optarg, "out", 1, "in", 2, "all", 3, "total", 3, 0);
8898
shell_read_boolean(&loops, optarg);
8901
shell_igraph_maxdegree_usage(argv);
8910
/* Check that we have all arguments */
8911
for (shell_index=0; shell_index<5; shell_index++) {
8912
if (!shell_seen[shell_index]) {
8913
fprintf(stderr, "Error, argument missing: `--%s'.\n",
8914
shell_options[shell_index].name);
8919
/* Do the operation */
8920
shell_result=igraph_maxdegree(&graph, &res, vids, mode, loops);
8922
/* Write the result */
8923
igraph_destroy(&graph);
8924
shell_write_integer(res, shell_arg_res);
8925
if (!igraph_vs_is_all(&vids)) { igraph_vector_destroy(&v_vids); }
8930
/*-------------------------------------------/
8932
/-------------------------------------------*/
8933
void shell_igraph_density_usage(char **argv) {
8934
printf("%s --graph=<graph> --res=<res> --loops=<loops>\n", basename(argv[0]));
8938
int shell_igraph_density(int argc, char **argv) {
8942
igraph_bool_t loops=0;
8943
char* shell_arg_res=0;
8949
struct option shell_options[]= { { "graph",required_argument,0,0 },
8950
{ "res",required_argument,0,1 },
8951
{ "loops",required_argument,0,2 },
8952
{ "help",no_argument,0,3 },
8956
/* 0 - not seen, 1 - seen as argument, 2 - seen as default */
8957
memset(shell_seen, 0, 3*sizeof(int));
8960
/* Parse arguments and read input */
8961
while (getopt_long(argc, argv, "", shell_options, &shell_index) != -1) {
8963
if (shell_index==-1) {
8967
if (shell_seen[shell_index]==1) {
8968
fprintf(stderr, "Error, `--%s' argument given twice.\n",
8969
shell_options[shell_index].name);
8972
shell_seen[shell_index]=1;
8974
switch (shell_index) {
8976
shell_read_graph(&graph, optarg);
8979
shell_arg_res=strdup(optarg);
8982
shell_read_boolean(&loops, optarg);
8985
shell_igraph_density_usage(argv);
8994
/* Check that we have all arguments */
8995
for (shell_index=0; shell_index<3; shell_index++) {
8996
if (!shell_seen[shell_index]) {
8997
fprintf(stderr, "Error, argument missing: `--%s'.\n",
8998
shell_options[shell_index].name);
9003
/* Do the operation */
9004
shell_result=igraph_density(&graph, &res, loops);
9006
/* Write the result */
9007
igraph_destroy(&graph);
9008
shell_write_real(res, shell_arg_res);
9013
/*-------------------------------------------/
9014
/ igraph_neighborhood_size /
9015
/-------------------------------------------*/
9016
void shell_igraph_neighborhood_size_usage(char **argv) {
9017
printf("%s --graph=<graph> --res=<res> --vids=<vids> --order=<order> --mode=<mode>\n", basename(argv[0]));
9021
int shell_igraph_neighborhood_size(int argc, char **argv) {
9024
igraph_vector_t res;
9025
igraph_vector_t v_vids; igraph_vs_t vids;
9026
igraph_integer_t order;
9027
igraph_neimode_t mode=IGRAPH_ALL;
9028
char* shell_arg_res=0;
9034
struct option shell_options[]= { { "graph",required_argument,0,0 },
9035
{ "res",required_argument,0,1 },
9036
{ "vids",required_argument,0,2 },
9037
{ "order",required_argument,0,3 },
9038
{ "mode",required_argument,0,4 },
9039
{ "help",no_argument,0,5 },
9043
/* 0 - not seen, 1 - seen as argument, 2 - seen as default */
9044
memset(shell_seen, 0, 5*sizeof(int));
9047
/* Parse arguments and read input */
9048
while (getopt_long(argc, argv, "", shell_options, &shell_index) != -1) {
9050
if (shell_index==-1) {
9054
if (shell_seen[shell_index]==1) {
9055
fprintf(stderr, "Error, `--%s' argument given twice.\n",
9056
shell_options[shell_index].name);
9059
shell_seen[shell_index]=1;
9061
switch (shell_index) {
9063
shell_read_graph(&graph, optarg);
9066
shell_arg_res=strdup(optarg);
9067
igraph_vector_init(&res, 0);
9070
shell_read_vector(&v_vids, optarg); igraph_vs_vector(&vids, &v_vids);
9073
shell_read_integer(&order, optarg);
9076
shell_read_enum(&mode, optarg, "out", 1, "in", 2, "all", 3, "total", 3, 0);
9079
shell_igraph_neighborhood_size_usage(argv);
9088
/* Check that we have all arguments */
9089
for (shell_index=0; shell_index<5; shell_index++) {
9090
if (!shell_seen[shell_index]) {
9091
fprintf(stderr, "Error, argument missing: `--%s'.\n",
9092
shell_options[shell_index].name);
9097
/* Do the operation */
9098
shell_result=igraph_neighborhood_size(&graph, &res, vids, order, mode);
9100
/* Write the result */
9101
igraph_destroy(&graph);
9102
shell_write_vector(&res, shell_arg_res);
9103
igraph_vector_destroy(&res);
9104
if (!igraph_vs_is_all(&vids)) { igraph_vector_destroy(&v_vids); }
9109
/*-------------------------------------------/
9110
/ igraph_neighborhood /
9111
/-------------------------------------------*/
9112
void shell_igraph_neighborhood_usage(char **argv) {
9113
printf("%s --graph=<graph> --res=<res> --vids=<vids> --order=<order> --mode=<mode>\n", basename(argv[0]));
9117
int shell_igraph_neighborhood(int argc, char **argv) {
9120
igraph_vector_ptr_t res;
9121
igraph_vector_t v_vids; igraph_vs_t vids;
9122
igraph_integer_t order;
9123
igraph_neimode_t mode=IGRAPH_ALL;
9124
char* shell_arg_res=0;
9130
struct option shell_options[]= { { "graph",required_argument,0,0 },
9131
{ "res",required_argument,0,1 },
9132
{ "vids",required_argument,0,2 },
9133
{ "order",required_argument,0,3 },
9134
{ "mode",required_argument,0,4 },
9135
{ "help",no_argument,0,5 },
9139
/* 0 - not seen, 1 - seen as argument, 2 - seen as default */
9140
memset(shell_seen, 0, 5*sizeof(int));
9143
/* Parse arguments and read input */
9144
while (getopt_long(argc, argv, "", shell_options, &shell_index) != -1) {
9146
if (shell_index==-1) {
9150
if (shell_seen[shell_index]==1) {
9151
fprintf(stderr, "Error, `--%s' argument given twice.\n",
9152
shell_options[shell_index].name);
9155
shell_seen[shell_index]=1;
9157
switch (shell_index) {
9159
shell_read_graph(&graph, optarg);
9162
igraph_vector_ptr_init(&res, 0);
9165
shell_read_vector(&v_vids, optarg); igraph_vs_vector(&vids, &v_vids);
9168
shell_read_integer(&order, optarg);
9171
shell_read_enum(&mode, optarg, "out", 1, "in", 2, "all", 3, "total", 3, 0);
9174
shell_igraph_neighborhood_usage(argv);
9183
/* Check that we have all arguments */
9184
for (shell_index=0; shell_index<5; shell_index++) {
9185
if (!shell_seen[shell_index]) {
9186
fprintf(stderr, "Error, argument missing: `--%s'.\n",
9187
shell_options[shell_index].name);
9192
/* Do the operation */
9193
shell_result=igraph_neighborhood(&graph, &res, vids, order, mode);
9195
/* Write the result */
9196
igraph_destroy(&graph);
9197
shell_write_vectorlist(&res, shell_arg_res);
9198
shell_free_vectorlist(&res);
9199
igraph_vector_ptr_destroy(&res);
9200
if (!igraph_vs_is_all(&vids)) { igraph_vector_destroy(&v_vids); }
9205
/*-------------------------------------------/
9206
/ igraph_neighborhood_graphs /
9207
/-------------------------------------------*/
9208
void shell_igraph_neighborhood_graphs_usage(char **argv) {
9209
printf("%s --graph=<graph> --res=<res> --vids=<vids> --order=<order> --mode=<mode>\n", basename(argv[0]));
9213
int shell_igraph_neighborhood_graphs(int argc, char **argv) {
9216
igraph_vector_ptr_t res;
9217
igraph_vector_t v_vids; igraph_vs_t vids;
9218
igraph_integer_t order;
9219
igraph_neimode_t mode=IGRAPH_ALL;
9220
char* shell_arg_res=0;
9226
struct option shell_options[]= { { "graph",required_argument,0,0 },
9227
{ "res",required_argument,0,1 },
9228
{ "vids",required_argument,0,2 },
9229
{ "order",required_argument,0,3 },
9230
{ "mode",required_argument,0,4 },
9231
{ "help",no_argument,0,5 },
9235
/* 0 - not seen, 1 - seen as argument, 2 - seen as default */
9236
memset(shell_seen, 0, 5*sizeof(int));
9239
/* Parse arguments and read input */
9240
while (getopt_long(argc, argv, "", shell_options, &shell_index) != -1) {
9242
if (shell_index==-1) {
9246
if (shell_seen[shell_index]==1) {
9247
fprintf(stderr, "Error, `--%s' argument given twice.\n",
9248
shell_options[shell_index].name);
9251
shell_seen[shell_index]=1;
9253
switch (shell_index) {
9255
shell_read_graph(&graph, optarg);
9258
igraph_vector_ptr_init(&res, 0);
9261
shell_read_vector(&v_vids, optarg); igraph_vs_vector(&vids, &v_vids);
9264
shell_read_integer(&order, optarg);
9267
shell_read_enum(&mode, optarg, "out", 1, "in", 2, "all", 3, "total", 3, 0);
9270
shell_igraph_neighborhood_graphs_usage(argv);
9279
/* Check that we have all arguments */
9280
for (shell_index=0; shell_index<5; shell_index++) {
9281
if (!shell_seen[shell_index]) {
9282
fprintf(stderr, "Error, argument missing: `--%s'.\n",
9283
shell_options[shell_index].name);
9288
/* Do the operation */
9289
shell_result=igraph_neighborhood_graphs(&graph, &res, vids, order, mode);
9291
/* Write the result */
9292
igraph_destroy(&graph);
9293
shell_write_graphlist(&res, shell_arg_res);
9294
shell_free_graphlist(&res);
9295
igraph_vector_ptr_destroy(&res);
9296
if (!igraph_vs_is_all(&vids)) { igraph_vector_destroy(&v_vids); }
9301
/*-------------------------------------------/
9302
/ igraph_topological_sorting /
9303
/-------------------------------------------*/
9304
void shell_igraph_topological_sorting_usage(char **argv) {
9305
printf("%s --graph=<graph> --res=<res> --mode=<mode>\n", basename(argv[0]));
9309
int shell_igraph_topological_sorting(int argc, char **argv) {
9312
igraph_vector_t res;
9313
igraph_neimode_t mode=IGRAPH_OUT;
9314
char* shell_arg_res=0;
9320
struct option shell_options[]= { { "graph",required_argument,0,0 },
9321
{ "res",required_argument,0,1 },
9322
{ "mode",required_argument,0,2 },
9323
{ "help",no_argument,0,3 },
9327
/* 0 - not seen, 1 - seen as argument, 2 - seen as default */
9328
memset(shell_seen, 0, 3*sizeof(int));
9331
/* Parse arguments and read input */
9332
while (getopt_long(argc, argv, "", shell_options, &shell_index) != -1) {
9334
if (shell_index==-1) {
9338
if (shell_seen[shell_index]==1) {
9339
fprintf(stderr, "Error, `--%s' argument given twice.\n",
9340
shell_options[shell_index].name);
9343
shell_seen[shell_index]=1;
9345
switch (shell_index) {
9347
shell_read_graph(&graph, optarg);
9350
shell_arg_res=strdup(optarg);
9351
igraph_vector_init(&res, 0);
9354
shell_read_enum(&mode, optarg, "out", 1, "in", 2, "all", 3, "total", 3, 0);
9357
shell_igraph_topological_sorting_usage(argv);
9366
/* Check that we have all arguments */
9367
for (shell_index=0; shell_index<3; shell_index++) {
9368
if (!shell_seen[shell_index]) {
9369
fprintf(stderr, "Error, argument missing: `--%s'.\n",
9370
shell_options[shell_index].name);
9375
/* Do the operation */
9376
shell_result=igraph_topological_sorting(&graph, &res, mode);
9378
/* Write the result */
9379
igraph_destroy(&graph);
9380
shell_write_vector(&res, shell_arg_res);
9381
igraph_vector_destroy(&res);
9386
/*-------------------------------------------/
9388
/-------------------------------------------*/
9389
void shell_igraph_is_loop_usage(char **argv) {
9390
printf("%s --graph=<graph> --res=<res> --es=<es>\n", basename(argv[0]));
9394
int shell_igraph_is_loop(int argc, char **argv) {
9397
igraph_vector_bool_t res;
9398
igraph_vector_t v_es; igraph_es_t es=igraph_ess_all(IGRAPH_EDGEORDER_ID);
9399
char* shell_arg_res=0;
9405
struct option shell_options[]= { { "graph",required_argument,0,0 },
9406
{ "res",required_argument,0,1 },
9407
{ "es",required_argument,0,2 },
9408
{ "help",no_argument,0,3 },
9412
/* 0 - not seen, 1 - seen as argument, 2 - seen as default */
9413
memset(shell_seen, 0, 3*sizeof(int));
9416
/* Parse arguments and read input */
9417
while (getopt_long(argc, argv, "", shell_options, &shell_index) != -1) {
9419
if (shell_index==-1) {
9423
if (shell_seen[shell_index]==1) {
9424
fprintf(stderr, "Error, `--%s' argument given twice.\n",
9425
shell_options[shell_index].name);
9428
shell_seen[shell_index]=1;
9430
switch (shell_index) {
9432
shell_read_graph(&graph, optarg);
9435
igraph_vector_bool_init(&res, 0);
9438
shell_read_vector(&v_es, optarg); igraph_es_vector(&es, &v_es);
9441
shell_igraph_is_loop_usage(argv);
9450
/* Check that we have all arguments */
9451
for (shell_index=0; shell_index<3; shell_index++) {
9452
if (!shell_seen[shell_index]) {
9453
fprintf(stderr, "Error, argument missing: `--%s'.\n",
9454
shell_options[shell_index].name);
9459
/* Do the operation */
9460
shell_result=igraph_is_loop(&graph, &res, es);
9462
/* Write the result */
9463
igraph_destroy(&graph);
9464
shell_write_vector_bool(&res, shell_arg_res);
9465
igraph_vector_bool_destroy(&res);
9466
if (!igraph_es_is_all(&es)) { igraph_es_destroy(&es); }
9471
/*-------------------------------------------/
9472
/ igraph_is_simple /
9473
/-------------------------------------------*/
9474
void shell_igraph_is_simple_usage(char **argv) {
9475
printf("%s --graph=<graph> --res=<res>\n", basename(argv[0]));
9479
int shell_igraph_is_simple(int argc, char **argv) {
9483
char* shell_arg_res=0;
9489
struct option shell_options[]= { { "graph",required_argument,0,0 },
9490
{ "res",required_argument,0,1 },
9491
{ "help",no_argument,0,2 },
9495
/* 0 - not seen, 1 - seen as argument, 2 - seen as default */
9496
memset(shell_seen, 0, 2*sizeof(int));
9499
/* Parse arguments and read input */
9500
while (getopt_long(argc, argv, "", shell_options, &shell_index) != -1) {
9502
if (shell_index==-1) {
9506
if (shell_seen[shell_index]==1) {
9507
fprintf(stderr, "Error, `--%s' argument given twice.\n",
9508
shell_options[shell_index].name);
9511
shell_seen[shell_index]=1;
9513
switch (shell_index) {
9515
shell_read_graph(&graph, optarg);
9521
shell_igraph_is_simple_usage(argv);
9530
/* Check that we have all arguments */
9531
for (shell_index=0; shell_index<2; shell_index++) {
9532
if (!shell_seen[shell_index]) {
9533
fprintf(stderr, "Error, argument missing: `--%s'.\n",
9534
shell_options[shell_index].name);
9539
/* Do the operation */
9540
shell_result=igraph_is_simple(&graph, &res);
9542
/* Write the result */
9543
igraph_destroy(&graph);
9544
shell_write_boolean(res, shell_arg_res);
9549
/*-------------------------------------------/
9550
/ igraph_is_multiple /
9551
/-------------------------------------------*/
9552
void shell_igraph_is_multiple_usage(char **argv) {
9553
printf("%s --graph=<graph> --res=<res> --es=<es>\n", basename(argv[0]));
9557
int shell_igraph_is_multiple(int argc, char **argv) {
9560
igraph_vector_bool_t res;
9561
igraph_vector_t v_es; igraph_es_t es=igraph_ess_all(IGRAPH_EDGEORDER_ID);
9562
char* shell_arg_res=0;
9568
struct option shell_options[]= { { "graph",required_argument,0,0 },
9569
{ "res",required_argument,0,1 },
9570
{ "es",required_argument,0,2 },
9571
{ "help",no_argument,0,3 },
9575
/* 0 - not seen, 1 - seen as argument, 2 - seen as default */
9576
memset(shell_seen, 0, 3*sizeof(int));
9579
/* Parse arguments and read input */
9580
while (getopt_long(argc, argv, "", shell_options, &shell_index) != -1) {
9582
if (shell_index==-1) {
9586
if (shell_seen[shell_index]==1) {
9587
fprintf(stderr, "Error, `--%s' argument given twice.\n",
9588
shell_options[shell_index].name);
9591
shell_seen[shell_index]=1;
9593
switch (shell_index) {
9595
shell_read_graph(&graph, optarg);
9598
igraph_vector_bool_init(&res, 0);
9601
shell_read_vector(&v_es, optarg); igraph_es_vector(&es, &v_es);
9604
shell_igraph_is_multiple_usage(argv);
9613
/* Check that we have all arguments */
9614
for (shell_index=0; shell_index<3; shell_index++) {
9615
if (!shell_seen[shell_index]) {
9616
fprintf(stderr, "Error, argument missing: `--%s'.\n",
9617
shell_options[shell_index].name);
9622
/* Do the operation */
9623
shell_result=igraph_is_multiple(&graph, &res, es);
9625
/* Write the result */
9626
igraph_destroy(&graph);
9627
shell_write_vector_bool(&res, shell_arg_res);
9628
igraph_vector_bool_destroy(&res);
9629
if (!igraph_es_is_all(&es)) { igraph_es_destroy(&es); }
9634
/*-------------------------------------------/
9635
/ igraph_count_multiple /
9636
/-------------------------------------------*/
9637
void shell_igraph_count_multiple_usage(char **argv) {
9638
printf("%s --graph=<graph> --res=<res> --es=<es>\n", basename(argv[0]));
9642
int shell_igraph_count_multiple(int argc, char **argv) {
9645
igraph_vector_t res;
9646
igraph_vector_t v_es; igraph_es_t es=igraph_ess_all(IGRAPH_EDGEORDER_ID);
9647
char* shell_arg_res=0;
9653
struct option shell_options[]= { { "graph",required_argument,0,0 },
9654
{ "res",required_argument,0,1 },
9655
{ "es",required_argument,0,2 },
9656
{ "help",no_argument,0,3 },
9660
/* 0 - not seen, 1 - seen as argument, 2 - seen as default */
9661
memset(shell_seen, 0, 3*sizeof(int));
9664
/* Parse arguments and read input */
9665
while (getopt_long(argc, argv, "", shell_options, &shell_index) != -1) {
9667
if (shell_index==-1) {
9671
if (shell_seen[shell_index]==1) {
9672
fprintf(stderr, "Error, `--%s' argument given twice.\n",
9673
shell_options[shell_index].name);
9676
shell_seen[shell_index]=1;
9678
switch (shell_index) {
9680
shell_read_graph(&graph, optarg);
9683
shell_arg_res=strdup(optarg);
9684
igraph_vector_init(&res, 0);
9687
shell_read_vector(&v_es, optarg); igraph_es_vector(&es, &v_es);
9690
shell_igraph_count_multiple_usage(argv);
9699
/* Check that we have all arguments */
9700
for (shell_index=0; shell_index<3; shell_index++) {
9701
if (!shell_seen[shell_index]) {
9702
fprintf(stderr, "Error, argument missing: `--%s'.\n",
9703
shell_options[shell_index].name);
9708
/* Do the operation */
9709
shell_result=igraph_count_multiple(&graph, &res, es);
9711
/* Write the result */
9712
igraph_destroy(&graph);
9713
shell_write_vector(&res, shell_arg_res);
9714
igraph_vector_destroy(&res);
9715
if (!igraph_es_is_all(&es)) { igraph_es_destroy(&es); }
9720
/*-------------------------------------------/
9722
/-------------------------------------------*/
9723
void shell_igraph_girth_usage(char **argv) {
9724
printf("%s --graph=<graph> --girth=<girth> --circle=<circle>\n", basename(argv[0]));
9728
int shell_igraph_girth(int argc, char **argv) {
9731
igraph_integer_t girth;
9732
igraph_vector_t circle;
9733
char* shell_arg_girth=0;
9734
char* shell_arg_circle=0;
9740
struct option shell_options[]= { { "graph",required_argument,0,0 },
9741
{ "girth",required_argument,0,1 },
9742
{ "circle",required_argument,0,2 },
9743
{ "help",no_argument,0,3 },
9747
/* 0 - not seen, 1 - seen as argument, 2 - seen as default */
9748
memset(shell_seen, 0, 3*sizeof(int));
9751
/* Parse arguments and read input */
9752
while (getopt_long(argc, argv, "", shell_options, &shell_index) != -1) {
9754
if (shell_index==-1) {
9758
if (shell_seen[shell_index]==1) {
9759
fprintf(stderr, "Error, `--%s' argument given twice.\n",
9760
shell_options[shell_index].name);
9763
shell_seen[shell_index]=1;
9765
switch (shell_index) {
9767
shell_read_graph(&graph, optarg);
9770
shell_arg_girth=strdup(optarg);
9772
case 2: /* circle */
9773
shell_arg_circle=strdup(optarg);
9774
igraph_vector_init(&circle, 0);
9777
shell_igraph_girth_usage(argv);
9786
/* Check that we have all arguments */
9787
for (shell_index=0; shell_index<3; shell_index++) {
9788
if (!shell_seen[shell_index]) {
9789
fprintf(stderr, "Error, argument missing: `--%s'.\n",
9790
shell_options[shell_index].name);
9795
/* Do the operation */
9796
shell_result=igraph_girth(&graph, &girth, &circle);
9798
/* Write the result */
9799
igraph_destroy(&graph);
9800
shell_write_integer(girth, shell_arg_girth);
9801
shell_write_vector(&circle, shell_arg_circle);
9802
igraph_vector_destroy(&circle);
9807
/*-------------------------------------------/
9809
/-------------------------------------------*/
9810
void shell_igraph_add_edge_usage(char **argv) {
9811
printf("%s --graph=<graph> --graph-out=<graph-out> --from=<from> --to=<to>\n", basename(argv[0]));
9815
int shell_igraph_add_edge(int argc, char **argv) {
9818
igraph_integer_t from;
9819
igraph_integer_t to;
9820
char* shell_arg_graph=0;
9826
struct option shell_options[]= { { "graph",required_argument,0,0 },
9827
{ "graph-out",required_argument,0,1 },
9828
{ "from",required_argument,0,2 },
9829
{ "to",required_argument,0,3 },
9830
{ "help",no_argument,0,4 },
9834
/* 0 - not seen, 1 - seen as argument, 2 - seen as default */
9835
memset(shell_seen, 0, 4*sizeof(int));
9838
/* Parse arguments and read input */
9839
while (getopt_long(argc, argv, "", shell_options, &shell_index) != -1) {
9841
if (shell_index==-1) {
9845
if (shell_seen[shell_index]==1) {
9846
fprintf(stderr, "Error, `--%s' argument given twice.\n",
9847
shell_options[shell_index].name);
9850
shell_seen[shell_index]=1;
9852
switch (shell_index) {
9854
shell_read_graph(&graph, optarg);
9856
case 1: /* graph-out */
9857
shell_arg_graph=strdup(optarg);
9860
shell_read_integer(&from, optarg);
9863
shell_read_integer(&to, optarg);
9866
shell_igraph_add_edge_usage(argv);
9875
/* Check that we have all arguments */
9876
for (shell_index=0; shell_index<4; shell_index++) {
9877
if (!shell_seen[shell_index]) {
9878
fprintf(stderr, "Error, argument missing: `--%s'.\n",
9879
shell_options[shell_index].name);
9884
/* Do the operation */
9885
shell_result=igraph_add_edge(&graph, from, to);
9887
/* Write the result */
9888
igraph_destroy(&graph);
9889
shell_write_graph(&graph, shell_arg_graph);
9890
igraph_destroy(&graph);
9895
/*-------------------------------------------/
9896
/ igraph_eigenvector_centrality /
9897
/-------------------------------------------*/
9898
void shell_igraph_eigenvector_centrality_usage(char **argv) {
9899
printf("%s --graph=<graph> --vector=<vector> --value=<value> --scale=<scale>\n", basename(argv[0]));
9903
int shell_igraph_eigenvector_centrality(int argc, char **argv) {
9906
igraph_vector_t vector;
9907
igraph_real_t value;
9908
igraph_bool_t scale=1;
9911
char* shell_arg_vector=0;
9912
char* shell_arg_value=0;
9913
char* shell_arg_options=0;
9919
struct option shell_options[]= { { "graph",required_argument,0,0 },
9920
{ "vector",required_argument,0,1 },
9921
{ "value",required_argument,0,2 },
9922
{ "scale",required_argument,0,3 },
9923
{ "help",no_argument,0,4 },
9927
/* 0 - not seen, 1 - seen as argument, 2 - seen as default */
9928
memset(shell_seen, 0, 4*sizeof(int));
9931
/* Parse arguments and read input */
9932
while (getopt_long(argc, argv, "", shell_options, &shell_index) != -1) {
9934
if (shell_index==-1) {
9938
if (shell_seen[shell_index]==1) {
9939
fprintf(stderr, "Error, `--%s' argument given twice.\n",
9940
shell_options[shell_index].name);
9943
shell_seen[shell_index]=1;
9945
switch (shell_index) {
9947
shell_read_graph(&graph, optarg);
9949
case 1: /* vector */
9950
shell_arg_vector=strdup(optarg);
9951
igraph_vector_init(&vector, 0);
9954
shell_arg_value=strdup(optarg);
9957
shell_read_boolean(&scale, optarg);
9960
shell_igraph_eigenvector_centrality_usage(argv);
9969
/* Check that we have all arguments */
9970
for (shell_index=0; shell_index<4; shell_index++) {
9971
if (!shell_seen[shell_index]) {
9972
fprintf(stderr, "Error, argument missing: `--%s'.\n",
9973
shell_options[shell_index].name);
9978
/* Do the operation */
9979
shell_result=igraph_eigenvector_centrality(&graph, &vector, &value, scale, 0, 0);
9981
/* Write the result */
9982
igraph_destroy(&graph);
9983
shell_write_vector(&vector, shell_arg_vector);
9984
igraph_vector_destroy(&vector);
9985
shell_write_real(value, shell_arg_value);
9990
/*-------------------------------------------/
9991
/ igraph_hub_score /
9992
/-------------------------------------------*/
9993
void shell_igraph_hub_score_usage(char **argv) {
9994
printf("%s --graph=<graph> --vector=<vector> --value=<value> --scale=<scale>\n", basename(argv[0]));
9998
int shell_igraph_hub_score(int argc, char **argv) {
10001
igraph_vector_t vector;
10002
igraph_real_t value;
10003
igraph_bool_t scale=1;
10005
char* shell_arg_vector=0;
10006
char* shell_arg_value=0;
10007
char* shell_arg_options=0;
10012
int shell_index=-1;
10013
struct option shell_options[]= { { "graph",required_argument,0,0 },
10014
{ "vector",required_argument,0,1 },
10015
{ "value",required_argument,0,2 },
10016
{ "scale",required_argument,0,3 },
10017
{ "help",no_argument,0,4 },
10021
/* 0 - not seen, 1 - seen as argument, 2 - seen as default */
10022
memset(shell_seen, 0, 4*sizeof(int));
10025
/* Parse arguments and read input */
10026
while (getopt_long(argc, argv, "", shell_options, &shell_index) != -1) {
10028
if (shell_index==-1) {
10032
if (shell_seen[shell_index]==1) {
10033
fprintf(stderr, "Error, `--%s' argument given twice.\n",
10034
shell_options[shell_index].name);
10037
shell_seen[shell_index]=1;
10039
switch (shell_index) {
10040
case 0: /* graph */
10041
shell_read_graph(&graph, optarg);
10043
case 1: /* vector */
10044
shell_arg_vector=strdup(optarg);
10045
igraph_vector_init(&vector, 0);
10047
case 2: /* value */
10048
shell_arg_value=strdup(optarg);
10050
case 3: /* scale */
10051
shell_read_boolean(&scale, optarg);
10054
shell_igraph_hub_score_usage(argv);
10063
/* Check that we have all arguments */
10064
for (shell_index=0; shell_index<4; shell_index++) {
10065
if (!shell_seen[shell_index]) {
10066
fprintf(stderr, "Error, argument missing: `--%s'.\n",
10067
shell_options[shell_index].name);
10072
/* Do the operation */
10073
shell_result=igraph_hub_score(&graph, &vector, &value, scale, 0);
10075
/* Write the result */
10076
igraph_destroy(&graph);
10077
shell_write_vector(&vector, shell_arg_vector);
10078
igraph_vector_destroy(&vector);
10079
shell_write_real(value, shell_arg_value);
10084
/*-------------------------------------------/
10085
/ igraph_authority_score /
10086
/-------------------------------------------*/
10087
void shell_igraph_authority_score_usage(char **argv) {
10088
printf("%s --graph=<graph> --vector=<vector> --value=<value> --scale=<scale>\n", basename(argv[0]));
10092
int shell_igraph_authority_score(int argc, char **argv) {
10095
igraph_vector_t vector;
10096
igraph_real_t value;
10097
igraph_bool_t scale=1;
10099
char* shell_arg_vector=0;
10100
char* shell_arg_value=0;
10101
char* shell_arg_options=0;
10106
int shell_index=-1;
10107
struct option shell_options[]= { { "graph",required_argument,0,0 },
10108
{ "vector",required_argument,0,1 },
10109
{ "value",required_argument,0,2 },
10110
{ "scale",required_argument,0,3 },
10111
{ "help",no_argument,0,4 },
10115
/* 0 - not seen, 1 - seen as argument, 2 - seen as default */
10116
memset(shell_seen, 0, 4*sizeof(int));
10119
/* Parse arguments and read input */
10120
while (getopt_long(argc, argv, "", shell_options, &shell_index) != -1) {
10122
if (shell_index==-1) {
10126
if (shell_seen[shell_index]==1) {
10127
fprintf(stderr, "Error, `--%s' argument given twice.\n",
10128
shell_options[shell_index].name);
10131
shell_seen[shell_index]=1;
10133
switch (shell_index) {
10134
case 0: /* graph */
10135
shell_read_graph(&graph, optarg);
10137
case 1: /* vector */
10138
shell_arg_vector=strdup(optarg);
10139
igraph_vector_init(&vector, 0);
10141
case 2: /* value */
10142
shell_arg_value=strdup(optarg);
10144
case 3: /* scale */
10145
shell_read_boolean(&scale, optarg);
10148
shell_igraph_authority_score_usage(argv);
10157
/* Check that we have all arguments */
10158
for (shell_index=0; shell_index<4; shell_index++) {
10159
if (!shell_seen[shell_index]) {
10160
fprintf(stderr, "Error, argument missing: `--%s'.\n",
10161
shell_options[shell_index].name);
10166
/* Do the operation */
10167
shell_result=igraph_authority_score(&graph, &vector, &value, scale, 0);
10169
/* Write the result */
10170
igraph_destroy(&graph);
10171
shell_write_vector(&vector, shell_arg_vector);
10172
igraph_vector_destroy(&vector);
10173
shell_write_real(value, shell_arg_value);
10178
/*-------------------------------------------/
10179
/ igraph_arpack_rssolve /
10180
/-------------------------------------------*/
10181
void shell_igraph_arpack_rssolve_usage(char **argv) {
10182
printf("%s --values=<values>\n", basename(argv[0]));
10186
int shell_igraph_arpack_rssolve(int argc, char **argv) {
10192
igraph_vector_t v_values; igraph_vector_t *values=0;
10194
char* shell_arg_options=0;
10195
char* shell_arg_values=0;
10196
char* shell_arg_vectors=0;
10201
int shell_index=-1;
10202
struct option shell_options[]= { { "values",required_argument,0,0 },
10203
{ "help",no_argument,0,1 },
10207
/* 0 - not seen, 1 - seen as argument, 2 - seen as default */
10208
memset(shell_seen, 0, 1*sizeof(int));
10211
/* Parse arguments and read input */
10212
while (getopt_long(argc, argv, "", shell_options, &shell_index) != -1) {
10214
if (shell_index==-1) {
10218
if (shell_seen[shell_index]==1) {
10219
fprintf(stderr, "Error, `--%s' argument given twice.\n",
10220
shell_options[shell_index].name);
10223
shell_seen[shell_index]=1;
10225
switch (shell_index) {
10226
case 0: /* values */
10227
values=&v_values; igraph_vector_init(values, 0);
10228
shell_arg_values=strdup(optarg);
10231
shell_igraph_arpack_rssolve_usage(argv);
10240
/* Check that we have all arguments */
10241
for (shell_index=0; shell_index<1; shell_index++) {
10242
if (!shell_seen[shell_index]) {
10243
fprintf(stderr, "Error, argument missing: `--%s'.\n",
10244
shell_options[shell_index].name);
10249
/* Do the operation */
10250
shell_result=igraph_arpack_rssolve(0, 0, 0, 0, values, 0);
10252
/* Write the result */
10253
if (values) { shell_write_vector(values, shell_arg_values);
10254
igraph_vector_destroy(values); }
10259
/*-------------------------------------------/
10260
/ igraph_arpack_rnsolve /
10261
/-------------------------------------------*/
10262
void shell_igraph_arpack_rnsolve_usage(char **argv) {
10263
printf("%s --values=<values>\n", basename(argv[0]));
10267
int shell_igraph_arpack_rnsolve(int argc, char **argv) {
10273
igraph_vector_t v_values; igraph_vector_t *values=0;
10275
char* shell_arg_options=0;
10276
char* shell_arg_values=0;
10277
char* shell_arg_vectors=0;
10282
int shell_index=-1;
10283
struct option shell_options[]= { { "values",required_argument,0,0 },
10284
{ "help",no_argument,0,1 },
10288
/* 0 - not seen, 1 - seen as argument, 2 - seen as default */
10289
memset(shell_seen, 0, 1*sizeof(int));
10292
/* Parse arguments and read input */
10293
while (getopt_long(argc, argv, "", shell_options, &shell_index) != -1) {
10295
if (shell_index==-1) {
10299
if (shell_seen[shell_index]==1) {
10300
fprintf(stderr, "Error, `--%s' argument given twice.\n",
10301
shell_options[shell_index].name);
10304
shell_seen[shell_index]=1;
10306
switch (shell_index) {
10307
case 0: /* values */
10308
values=&v_values; igraph_vector_init(values, 0);
10309
shell_arg_values=strdup(optarg);
10312
shell_igraph_arpack_rnsolve_usage(argv);
10321
/* Check that we have all arguments */
10322
for (shell_index=0; shell_index<1; shell_index++) {
10323
if (!shell_seen[shell_index]) {
10324
fprintf(stderr, "Error, argument missing: `--%s'.\n",
10325
shell_options[shell_index].name);
10330
/* Do the operation */
10331
shell_result=igraph_arpack_rnsolve(0, 0, 0, 0, values, 0);
10333
/* Write the result */
10334
if (values) { shell_write_vector(values, shell_arg_values);
10335
igraph_vector_destroy(values); }
10340
/*-------------------------------------------/
10341
/ igraph_arpack_unpack_complex /
10342
/-------------------------------------------*/
10343
void shell_igraph_arpack_unpack_complex_usage(char **argv) {
10344
printf("%s --vectors=<vectors> --vectors-out=<vectors-out> --values=<values> --values-out=<values-out> --nev=<nev>\n", basename(argv[0]));
10348
int shell_igraph_arpack_unpack_complex(int argc, char **argv) {
10350
igraph_matrix_t vectors;
10351
igraph_matrix_t values;
10353
char* shell_arg_vectors=0;
10354
char* shell_arg_values=0;
10359
int shell_index=-1;
10360
struct option shell_options[]= { { "vectors",required_argument,0,0 },
10361
{ "vectors-out",required_argument,0,1 },
10362
{ "values",required_argument,0,2 },
10363
{ "values-out",required_argument,0,3 },
10364
{ "nev",required_argument,0,4 },
10365
{ "help",no_argument,0,5 },
10369
/* 0 - not seen, 1 - seen as argument, 2 - seen as default */
10370
memset(shell_seen, 0, 5*sizeof(int));
10373
/* Parse arguments and read input */
10374
while (getopt_long(argc, argv, "", shell_options, &shell_index) != -1) {
10376
if (shell_index==-1) {
10380
if (shell_seen[shell_index]==1) {
10381
fprintf(stderr, "Error, `--%s' argument given twice.\n",
10382
shell_options[shell_index].name);
10385
shell_seen[shell_index]=1;
10387
switch (shell_index) {
10388
case 0: /* vectors */
10389
shell_read_matrix(&vectors, optarg);
10391
case 1: /* vectors-out */
10392
shell_arg_vectors=strdup(optarg);
10393
igraph_matrix_init(&vectors, 0, 0);
10395
case 2: /* values */
10396
shell_read_matrix(&values, optarg);
10398
case 3: /* values-out */
10399
shell_arg_values=strdup(optarg);
10400
igraph_matrix_init(&values, 0, 0);
10403
shell_read_real(&nev, optarg);
10406
shell_igraph_arpack_unpack_complex_usage(argv);
10415
/* Check that we have all arguments */
10416
for (shell_index=0; shell_index<5; shell_index++) {
10417
if (!shell_seen[shell_index]) {
10418
fprintf(stderr, "Error, argument missing: `--%s'.\n",
10419
shell_options[shell_index].name);
10424
/* Do the operation */
10425
shell_result=igraph_arpack_unpack_complex(&vectors, &values, nev);
10427
/* Write the result */
10428
igraph_matrix_destroy(&vectors);
10429
shell_write_matrix(&vectors, shell_arg_vectors);
10430
igraph_matrix_destroy(&vectors);
10431
igraph_matrix_destroy(&values);
10432
shell_write_matrix(&values, shell_arg_values);
10433
igraph_matrix_destroy(&values);
10438
/*-------------------------------------------/
10439
/ igraph_unfold_tree /
10440
/-------------------------------------------*/
10441
void shell_igraph_unfold_tree_usage(char **argv) {
10442
printf("%s --graph=<graph> --tree=<tree> --mode=<mode> --roots=<roots> --vertex_index=<vertex_index>\n", basename(argv[0]));
10446
int shell_igraph_unfold_tree(int argc, char **argv) {
10450
igraph_neimode_t mode=IGRAPH_ALL;
10451
igraph_vector_t roots;
10452
igraph_vector_t v_vertex_index; igraph_vector_t *vertex_index=0;
10453
char* shell_arg_tree=0;
10454
char* shell_arg_vertex_index=0;
10459
int shell_index=-1;
10460
struct option shell_options[]= { { "graph",required_argument,0,0 },
10461
{ "tree",required_argument,0,1 },
10462
{ "mode",required_argument,0,2 },
10463
{ "roots",required_argument,0,3 },
10464
{ "vertex_index",required_argument,0,4 },
10465
{ "help",no_argument,0,5 },
10469
/* 0 - not seen, 1 - seen as argument, 2 - seen as default */
10470
memset(shell_seen, 0, 5*sizeof(int));
10473
/* Parse arguments and read input */
10474
while (getopt_long(argc, argv, "", shell_options, &shell_index) != -1) {
10476
if (shell_index==-1) {
10480
if (shell_seen[shell_index]==1) {
10481
fprintf(stderr, "Error, `--%s' argument given twice.\n",
10482
shell_options[shell_index].name);
10485
shell_seen[shell_index]=1;
10487
switch (shell_index) {
10488
case 0: /* graph */
10489
shell_read_graph(&graph, optarg);
10492
shell_arg_tree=strdup(optarg);
10495
shell_read_enum(&mode, optarg, "out", 1, "in", 2, "all", 3, "total", 3, 0);
10497
case 3: /* roots */
10498
shell_read_vector(&roots, optarg);
10500
case 4: /* vertex_index */
10501
vertex_index=&v_vertex_index; igraph_vector_init(vertex_index, 0);
10502
shell_arg_vertex_index=strdup(optarg);
10505
shell_igraph_unfold_tree_usage(argv);
10514
/* Check that we have all arguments */
10515
for (shell_index=0; shell_index<5; shell_index++) {
10516
if (!shell_seen[shell_index]) {
10517
fprintf(stderr, "Error, argument missing: `--%s'.\n",
10518
shell_options[shell_index].name);
10523
/* Do the operation */
10524
shell_result=igraph_unfold_tree(&graph, &tree, mode, &roots, vertex_index);
10526
/* Write the result */
10527
igraph_destroy(&graph);
10528
shell_write_graph(&tree, shell_arg_tree);
10529
igraph_destroy(&tree);
10530
igraph_vector_destroy(&roots);
10531
if (vertex_index) { shell_write_vector(vertex_index, shell_arg_vertex_index);
10532
igraph_vector_destroy(vertex_index); }
10537
/*-------------------------------------------/
10538
/ igraph_laplacian /
10539
/-------------------------------------------*/
10540
void shell_igraph_laplacian_usage(char **argv) {
10541
printf("%s --graph=<graph> --res=<res> --normalized=<normalized>\n", basename(argv[0]));
10545
int shell_igraph_laplacian(int argc, char **argv) {
10548
igraph_matrix_t res;
10549
igraph_bool_t normalized=0;
10550
char* shell_arg_res=0;
10555
int shell_index=-1;
10556
struct option shell_options[]= { { "graph",required_argument,0,0 },
10557
{ "res",required_argument,0,1 },
10558
{ "normalized",required_argument,0,2 },
10559
{ "help",no_argument,0,3 },
10563
/* 0 - not seen, 1 - seen as argument, 2 - seen as default */
10564
memset(shell_seen, 0, 3*sizeof(int));
10567
/* Parse arguments and read input */
10568
while (getopt_long(argc, argv, "", shell_options, &shell_index) != -1) {
10570
if (shell_index==-1) {
10574
if (shell_seen[shell_index]==1) {
10575
fprintf(stderr, "Error, `--%s' argument given twice.\n",
10576
shell_options[shell_index].name);
10579
shell_seen[shell_index]=1;
10581
switch (shell_index) {
10582
case 0: /* graph */
10583
shell_read_graph(&graph, optarg);
10586
shell_arg_res=strdup(optarg);
10587
igraph_matrix_init(&res, 0, 0);
10589
case 2: /* normalized */
10590
shell_read_boolean(&normalized, optarg);
10593
shell_igraph_laplacian_usage(argv);
10602
/* Check that we have all arguments */
10603
for (shell_index=0; shell_index<3; shell_index++) {
10604
if (!shell_seen[shell_index]) {
10605
fprintf(stderr, "Error, argument missing: `--%s'.\n",
10606
shell_options[shell_index].name);
10611
/* Do the operation */
10612
shell_result=igraph_laplacian(&graph, &res, normalized);
10614
/* Write the result */
10615
igraph_destroy(&graph);
10616
shell_write_matrix(&res, shell_arg_res);
10617
igraph_matrix_destroy(&res);
10622
/*-------------------------------------------/
10623
/ igraph_is_mutual /
10624
/-------------------------------------------*/
10625
void shell_igraph_is_mutual_usage(char **argv) {
10626
printf("%s --graph=<graph> --res=<res> --es=<es>\n", basename(argv[0]));
10630
int shell_igraph_is_mutual(int argc, char **argv) {
10633
igraph_vector_bool_t res;
10634
igraph_vector_t v_es; igraph_es_t es=igraph_ess_all(IGRAPH_EDGEORDER_ID);
10635
char* shell_arg_res=0;
10640
int shell_index=-1;
10641
struct option shell_options[]= { { "graph",required_argument,0,0 },
10642
{ "res",required_argument,0,1 },
10643
{ "es",required_argument,0,2 },
10644
{ "help",no_argument,0,3 },
10648
/* 0 - not seen, 1 - seen as argument, 2 - seen as default */
10649
memset(shell_seen, 0, 3*sizeof(int));
10652
/* Parse arguments and read input */
10653
while (getopt_long(argc, argv, "", shell_options, &shell_index) != -1) {
10655
if (shell_index==-1) {
10659
if (shell_seen[shell_index]==1) {
10660
fprintf(stderr, "Error, `--%s' argument given twice.\n",
10661
shell_options[shell_index].name);
10664
shell_seen[shell_index]=1;
10666
switch (shell_index) {
10667
case 0: /* graph */
10668
shell_read_graph(&graph, optarg);
10671
igraph_vector_bool_init(&res, 0);
10674
shell_read_vector(&v_es, optarg); igraph_es_vector(&es, &v_es);
10677
shell_igraph_is_mutual_usage(argv);
10686
/* Check that we have all arguments */
10687
for (shell_index=0; shell_index<3; shell_index++) {
10688
if (!shell_seen[shell_index]) {
10689
fprintf(stderr, "Error, argument missing: `--%s'.\n",
10690
shell_options[shell_index].name);
10695
/* Do the operation */
10696
shell_result=igraph_is_mutual(&graph, &res, es);
10698
/* Write the result */
10699
igraph_destroy(&graph);
10700
shell_write_vector_bool(&res, shell_arg_res);
10701
igraph_vector_bool_destroy(&res);
10702
if (!igraph_es_is_all(&es)) { igraph_es_destroy(&es); }
10707
/*-------------------------------------------/
10708
/ igraph_avg_nearest_neighbor_degree /
10709
/-------------------------------------------*/
10710
void shell_igraph_avg_nearest_neighbor_degree_usage(char **argv) {
10711
printf("%s --graph=<graph> --vids=<vids> --knn=<knn> --knnk=<knnk>\n", basename(argv[0]));
10715
int shell_igraph_avg_nearest_neighbor_degree(int argc, char **argv) {
10718
igraph_vector_t v_vids; igraph_vs_t vids=igraph_vss_all();
10719
igraph_vector_t v_knn; igraph_vector_t *knn=0;
10720
igraph_vector_t v_knnk; igraph_vector_t *knnk=0;
10722
char* shell_arg_knn=0;
10723
char* shell_arg_knnk=0;
10728
int shell_index=-1;
10729
struct option shell_options[]= { { "graph",required_argument,0,0 },
10730
{ "vids",required_argument,0,1 },
10731
{ "knn",required_argument,0,2 },
10732
{ "knnk",required_argument,0,3 },
10733
{ "help",no_argument,0,4 },
10737
/* 0 - not seen, 1 - seen as argument, 2 - seen as default */
10738
memset(shell_seen, 0, 4*sizeof(int));
10741
/* Parse arguments and read input */
10742
while (getopt_long(argc, argv, "", shell_options, &shell_index) != -1) {
10744
if (shell_index==-1) {
10748
if (shell_seen[shell_index]==1) {
10749
fprintf(stderr, "Error, `--%s' argument given twice.\n",
10750
shell_options[shell_index].name);
10753
shell_seen[shell_index]=1;
10755
switch (shell_index) {
10756
case 0: /* graph */
10757
shell_read_graph(&graph, optarg);
10760
shell_read_vector(&v_vids, optarg); igraph_vs_vector(&vids, &v_vids);
10763
knn=&v_knn; igraph_vector_init(knn, 0);
10764
shell_arg_knn=strdup(optarg);
10767
knnk=&v_knnk; igraph_vector_init(knnk, 0);
10768
shell_arg_knnk=strdup(optarg);
10771
shell_igraph_avg_nearest_neighbor_degree_usage(argv);
10780
/* Check that we have all arguments */
10781
for (shell_index=0; shell_index<4; shell_index++) {
10782
if (!shell_seen[shell_index]) {
10783
fprintf(stderr, "Error, argument missing: `--%s'.\n",
10784
shell_options[shell_index].name);
10789
/* Do the operation */
10790
shell_result=igraph_avg_nearest_neighbor_degree(&graph, vids, knn, knnk, 0);
10792
/* Write the result */
10793
igraph_destroy(&graph);
10794
if (!igraph_vs_is_all(&vids)) { igraph_vector_destroy(&v_vids); }
10795
if (knn) { shell_write_vector(knn, shell_arg_knn);
10796
igraph_vector_destroy(knn); }
10797
if (knnk) { shell_write_vector(knnk, shell_arg_knnk);
10798
igraph_vector_destroy(knnk); }
10803
/*-------------------------------------------/
10804
/ igraph_strength /
10805
/-------------------------------------------*/
10806
void shell_igraph_strength_usage(char **argv) {
10807
printf("%s --graph=<graph> --res=<res> --vids=<vids> --mode=<mode> --loops=<loops>\n", basename(argv[0]));
10811
int shell_igraph_strength(int argc, char **argv) {
10814
igraph_vector_t res;
10815
igraph_vector_t v_vids; igraph_vs_t vids=igraph_vss_all();
10816
igraph_neimode_t mode=IGRAPH_ALL;
10817
igraph_bool_t loops=1;
10819
char* shell_arg_res=0;
10824
int shell_index=-1;
10825
struct option shell_options[]= { { "graph",required_argument,0,0 },
10826
{ "res",required_argument,0,1 },
10827
{ "vids",required_argument,0,2 },
10828
{ "mode",required_argument,0,3 },
10829
{ "loops",required_argument,0,4 },
10830
{ "help",no_argument,0,5 },
10834
/* 0 - not seen, 1 - seen as argument, 2 - seen as default */
10835
memset(shell_seen, 0, 5*sizeof(int));
10840
/* Parse arguments and read input */
10841
while (getopt_long(argc, argv, "", shell_options, &shell_index) != -1) {
10843
if (shell_index==-1) {
10847
if (shell_seen[shell_index]==1) {
10848
fprintf(stderr, "Error, `--%s' argument given twice.\n",
10849
shell_options[shell_index].name);
10852
shell_seen[shell_index]=1;
10854
switch (shell_index) {
10855
case 0: /* graph */
10856
shell_read_graph(&graph, optarg);
10859
shell_arg_res=strdup(optarg);
10860
igraph_vector_init(&res, 0);
10863
shell_read_vector(&v_vids, optarg); igraph_vs_vector(&vids, &v_vids);
10866
shell_read_enum(&mode, optarg, "out", 1, "in", 2, "all", 3, "total", 3, 0);
10868
case 4: /* loops */
10869
shell_read_boolean(&loops, optarg);
10872
shell_igraph_strength_usage(argv);
10881
/* Check that we have all arguments */
10882
for (shell_index=0; shell_index<5; shell_index++) {
10883
if (!shell_seen[shell_index]) {
10884
fprintf(stderr, "Error, argument missing: `--%s'.\n",
10885
shell_options[shell_index].name);
10890
/* Do the operation */
10891
shell_result=igraph_strength(&graph, &res, vids, mode, loops, 0);
10893
/* Write the result */
10894
igraph_destroy(&graph);
10895
shell_write_vector(&res, shell_arg_res);
10896
igraph_vector_destroy(&res);
10897
if (!igraph_vs_is_all(&vids)) { igraph_vector_destroy(&v_vids); }
10902
/*-------------------------------------------/
10903
/ igraph_bipartite_projection_size /
10904
/-------------------------------------------*/
10905
void shell_igraph_bipartite_projection_size_usage(char **argv) {
10906
printf("%s --graph=<graph> --vcount1=<vcount1> --ecount1=<ecount1> --vcount2=<vcount2> --ecount2=<ecount2>\n", basename(argv[0]));
10910
int shell_igraph_bipartite_projection_size(int argc, char **argv) {
10914
igraph_integer_t vcount1;
10915
igraph_integer_t ecount1;
10916
igraph_integer_t vcount2;
10917
igraph_integer_t ecount2;
10918
char* shell_arg_vcount1=0;
10919
char* shell_arg_ecount1=0;
10920
char* shell_arg_vcount2=0;
10921
char* shell_arg_ecount2=0;
10926
int shell_index=-1;
10927
struct option shell_options[]= { { "graph",required_argument,0,0 },
10928
{ "vcount1",required_argument,0,1 },
10929
{ "ecount1",required_argument,0,2 },
10930
{ "vcount2",required_argument,0,3 },
10931
{ "ecount2",required_argument,0,4 },
10932
{ "help",no_argument,0,5 },
10936
/* 0 - not seen, 1 - seen as argument, 2 - seen as default */
10937
memset(shell_seen, 0, 5*sizeof(int));
10940
/* Parse arguments and read input */
10941
while (getopt_long(argc, argv, "", shell_options, &shell_index) != -1) {
10943
if (shell_index==-1) {
10947
if (shell_seen[shell_index]==1) {
10948
fprintf(stderr, "Error, `--%s' argument given twice.\n",
10949
shell_options[shell_index].name);
10952
shell_seen[shell_index]=1;
10954
switch (shell_index) {
10955
case 0: /* graph */
10956
shell_read_graph(&graph, optarg);
10958
case 1: /* vcount1 */
10959
shell_arg_vcount1=strdup(optarg);
10961
case 2: /* ecount1 */
10962
shell_arg_ecount1=strdup(optarg);
10964
case 3: /* vcount2 */
10965
shell_arg_vcount2=strdup(optarg);
10967
case 4: /* ecount2 */
10968
shell_arg_ecount2=strdup(optarg);
10971
shell_igraph_bipartite_projection_size_usage(argv);
10980
/* Check that we have all arguments */
10981
for (shell_index=0; shell_index<5; shell_index++) {
10982
if (!shell_seen[shell_index]) {
10983
fprintf(stderr, "Error, argument missing: `--%s'.\n",
10984
shell_options[shell_index].name);
10989
/* Do the operation */
10990
shell_result=igraph_bipartite_projection_size(&graph, types, &vcount1, &ecount1, &vcount2, &ecount2);
10992
/* Write the result */
10993
igraph_destroy(&graph);
10994
shell_write_integer(vcount1, shell_arg_vcount1);
10995
shell_write_integer(ecount1, shell_arg_ecount1);
10996
shell_write_integer(vcount2, shell_arg_vcount2);
10997
shell_write_integer(ecount2, shell_arg_ecount2);
11002
/*-------------------------------------------/
11003
/ igraph_bipartite_projection /
11004
/-------------------------------------------*/
11005
void shell_igraph_bipartite_projection_usage(char **argv) {
11006
printf("%s --graph=<graph> --proj1=<proj1> --proj2=<proj2> --probe1=<probe1>\n", basename(argv[0]));
11010
int shell_igraph_bipartite_projection(int argc, char **argv) {
11016
igraph_integer_t probe1=-1;
11017
char* shell_arg_proj1=0;
11018
char* shell_arg_proj2=0;
11023
int shell_index=-1;
11024
struct option shell_options[]= { { "graph",required_argument,0,0 },
11025
{ "proj1",required_argument,0,1 },
11026
{ "proj2",required_argument,0,2 },
11027
{ "probe1",required_argument,0,3 },
11028
{ "help",no_argument,0,4 },
11032
/* 0 - not seen, 1 - seen as argument, 2 - seen as default */
11033
memset(shell_seen, 0, 4*sizeof(int));
11036
/* Parse arguments and read input */
11037
while (getopt_long(argc, argv, "", shell_options, &shell_index) != -1) {
11039
if (shell_index==-1) {
11043
if (shell_seen[shell_index]==1) {
11044
fprintf(stderr, "Error, `--%s' argument given twice.\n",
11045
shell_options[shell_index].name);
11048
shell_seen[shell_index]=1;
11050
switch (shell_index) {
11051
case 0: /* graph */
11052
shell_read_graph(&graph, optarg);
11054
case 1: /* proj1 */
11055
shell_arg_proj1=strdup(optarg);
11057
case 2: /* proj2 */
11058
shell_arg_proj2=strdup(optarg);
11060
case 3: /* probe1 */
11061
shell_read_integer(&probe1, optarg);
11064
shell_igraph_bipartite_projection_usage(argv);
11073
/* Check that we have all arguments */
11074
for (shell_index=0; shell_index<4; shell_index++) {
11075
if (!shell_seen[shell_index]) {
11076
fprintf(stderr, "Error, argument missing: `--%s'.\n",
11077
shell_options[shell_index].name);
11082
/* Do the operation */
11083
shell_result=igraph_bipartite_projection(&graph, types, &proj1, &proj2, probe1);
11085
/* Write the result */
11086
igraph_destroy(&graph);
11087
shell_write_graph(&proj1, shell_arg_proj1);
11088
igraph_destroy(&proj1);
11089
shell_write_graph(&proj2, shell_arg_proj2);
11090
igraph_destroy(&proj2);
11095
/*-------------------------------------------/
11096
/ igraph_create_bipartite /
11097
/-------------------------------------------*/
11098
void shell_igraph_create_bipartite_usage(char **argv) {
11099
printf("%s --graph=<graph> --types=<types> --edges=<edges> --directed=<directed>\n", basename(argv[0]));
11103
int shell_igraph_create_bipartite(int argc, char **argv) {
11106
igraph_vector_bool_t types;
11107
igraph_vector_t edges;
11108
igraph_bool_t directed=0;
11109
char* shell_arg_graph=0;
11114
int shell_index=-1;
11115
struct option shell_options[]= { { "graph",required_argument,0,0 },
11116
{ "types",required_argument,0,1 },
11117
{ "edges",required_argument,0,2 },
11118
{ "directed",required_argument,0,3 },
11119
{ "help",no_argument,0,4 },
11123
/* 0 - not seen, 1 - seen as argument, 2 - seen as default */
11124
memset(shell_seen, 0, 4*sizeof(int));
11127
/* Parse arguments and read input */
11128
while (getopt_long(argc, argv, "", shell_options, &shell_index) != -1) {
11130
if (shell_index==-1) {
11134
if (shell_seen[shell_index]==1) {
11135
fprintf(stderr, "Error, `--%s' argument given twice.\n",
11136
shell_options[shell_index].name);
11139
shell_seen[shell_index]=1;
11141
switch (shell_index) {
11142
case 0: /* graph */
11143
shell_arg_graph=strdup(optarg);
11145
case 1: /* types */
11148
case 2: /* edges */
11149
shell_read_vector(&edges, optarg);
11151
case 3: /* directed */
11152
shell_read_boolean(&directed, optarg);
11155
shell_igraph_create_bipartite_usage(argv);
11164
/* Check that we have all arguments */
11165
for (shell_index=0; shell_index<4; shell_index++) {
11166
if (!shell_seen[shell_index]) {
11167
fprintf(stderr, "Error, argument missing: `--%s'.\n",
11168
shell_options[shell_index].name);
11173
/* Do the operation */
11174
shell_result=igraph_create_bipartite(&graph, &types, &edges, directed);
11176
/* Write the result */
11177
shell_write_graph(&graph, shell_arg_graph);
11178
igraph_destroy(&graph);
11179
igraph_vector_destroy(&edges);
11184
/*-------------------------------------------/
11185
/ igraph_incidence /
11186
/-------------------------------------------*/
11187
void shell_igraph_incidence_usage(char **argv) {
11188
printf("%s --graph=<graph> --types=<types> --incidence=<incidence> --directed=<directed> --mode=<mode> --multiple=<multiple>\n", basename(argv[0]));
11192
int shell_igraph_incidence(int argc, char **argv) {
11195
igraph_vector_bool_t types;
11196
igraph_matrix_t incidence;
11197
igraph_bool_t directed=0;
11198
igraph_neimode_t mode=IGRAPH_ALL;
11199
igraph_bool_t multiple=0;
11200
char* shell_arg_graph=0;
11201
char* shell_arg_types=0;
11206
int shell_index=-1;
11207
struct option shell_options[]= { { "graph",required_argument,0,0 },
11208
{ "types",required_argument,0,1 },
11209
{ "incidence",required_argument,0,2 },
11210
{ "directed",required_argument,0,3 },
11211
{ "mode",required_argument,0,4 },
11212
{ "multiple",required_argument,0,5 },
11213
{ "help",no_argument,0,6 },
11217
/* 0 - not seen, 1 - seen as argument, 2 - seen as default */
11218
memset(shell_seen, 0, 6*sizeof(int));
11223
/* Parse arguments and read input */
11224
while (getopt_long(argc, argv, "", shell_options, &shell_index) != -1) {
11226
if (shell_index==-1) {
11230
if (shell_seen[shell_index]==1) {
11231
fprintf(stderr, "Error, `--%s' argument given twice.\n",
11232
shell_options[shell_index].name);
11235
shell_seen[shell_index]=1;
11237
switch (shell_index) {
11238
case 0: /* graph */
11239
shell_arg_graph=strdup(optarg);
11241
case 1: /* types */
11242
igraph_vector_bool_init(&types, 0);
11244
case 2: /* incidence */
11245
shell_read_matrix(&incidence, optarg);
11247
case 3: /* directed */
11248
shell_read_boolean(&directed, optarg);
11251
shell_read_enum(&mode, optarg, "out", 1, "in", 2, "all", 3, "total", 3, 0);
11253
case 5: /* multiple */
11254
shell_read_boolean(&multiple, optarg);
11257
shell_igraph_incidence_usage(argv);
11266
/* Check that we have all arguments */
11267
for (shell_index=0; shell_index<6; shell_index++) {
11268
if (!shell_seen[shell_index]) {
11269
fprintf(stderr, "Error, argument missing: `--%s'.\n",
11270
shell_options[shell_index].name);
11275
/* Do the operation */
11276
shell_result=igraph_incidence(&graph, &types, &incidence, directed, mode, multiple);
11278
/* Write the result */
11279
shell_write_graph(&graph, shell_arg_graph);
11280
igraph_destroy(&graph);
11281
shell_write_vector_bool(&types, shell_arg_types);
11282
igraph_vector_bool_destroy(&types);
11283
igraph_matrix_destroy(&incidence);
11288
/*-------------------------------------------/
11289
/ igraph_get_incidence /
11290
/-------------------------------------------*/
11291
void shell_igraph_get_incidence_usage(char **argv) {
11292
printf("%s --graph=<graph> --res=<res> --row_ids=<row_ids> --col_ids=<col_ids>\n", basename(argv[0]));
11296
int shell_igraph_get_incidence(int argc, char **argv) {
11300
igraph_matrix_t res;
11301
igraph_vector_t v_row_ids; igraph_vector_t *row_ids=0;
11302
igraph_vector_t v_col_ids; igraph_vector_t *col_ids=0;
11303
char* shell_arg_res=0;
11304
char* shell_arg_row_ids=0;
11305
char* shell_arg_col_ids=0;
11310
int shell_index=-1;
11311
struct option shell_options[]= { { "graph",required_argument,0,0 },
11312
{ "res",required_argument,0,1 },
11313
{ "row_ids",required_argument,0,2 },
11314
{ "col_ids",required_argument,0,3 },
11315
{ "help",no_argument,0,4 },
11319
/* 0 - not seen, 1 - seen as argument, 2 - seen as default */
11320
memset(shell_seen, 0, 4*sizeof(int));
11323
/* Parse arguments and read input */
11324
while (getopt_long(argc, argv, "", shell_options, &shell_index) != -1) {
11326
if (shell_index==-1) {
11330
if (shell_seen[shell_index]==1) {
11331
fprintf(stderr, "Error, `--%s' argument given twice.\n",
11332
shell_options[shell_index].name);
11335
shell_seen[shell_index]=1;
11337
switch (shell_index) {
11338
case 0: /* graph */
11339
shell_read_graph(&graph, optarg);
11342
shell_arg_res=strdup(optarg);
11343
igraph_matrix_init(&res, 0, 0);
11345
case 2: /* row_ids */
11346
row_ids=&v_row_ids; igraph_vector_init(row_ids, 0);
11347
shell_arg_row_ids=strdup(optarg);
11349
case 3: /* col_ids */
11350
col_ids=&v_col_ids; igraph_vector_init(col_ids, 0);
11351
shell_arg_col_ids=strdup(optarg);
11354
shell_igraph_get_incidence_usage(argv);
11363
/* Check that we have all arguments */
11364
for (shell_index=0; shell_index<4; shell_index++) {
11365
if (!shell_seen[shell_index]) {
11366
fprintf(stderr, "Error, argument missing: `--%s'.\n",
11367
shell_options[shell_index].name);
11372
/* Do the operation */
11373
shell_result=igraph_get_incidence(&graph, types, &res, row_ids, col_ids);
11375
/* Write the result */
11376
igraph_destroy(&graph);
11377
shell_write_matrix(&res, shell_arg_res);
11378
igraph_matrix_destroy(&res);
11379
if (row_ids) { shell_write_vector(row_ids, shell_arg_row_ids);
11380
igraph_vector_destroy(row_ids); }
11381
if (col_ids) { shell_write_vector(col_ids, shell_arg_col_ids);
11382
igraph_vector_destroy(col_ids); }
11387
/*-------------------------------------------/
11388
/ igraph_is_bipartite /
11389
/-------------------------------------------*/
11390
void shell_igraph_is_bipartite_usage(char **argv) {
11391
printf("%s --graph=<graph> --res=<res>\n", basename(argv[0]));
11395
int shell_igraph_is_bipartite(int argc, char **argv) {
11400
char* shell_arg_res=0;
11401
char* shell_arg_type=0;
11406
int shell_index=-1;
11407
struct option shell_options[]= { { "graph",required_argument,0,0 },
11408
{ "res",required_argument,0,1 },
11409
{ "help",no_argument,0,2 },
11413
/* 0 - not seen, 1 - seen as argument, 2 - seen as default */
11414
memset(shell_seen, 0, 2*sizeof(int));
11417
/* Parse arguments and read input */
11418
while (getopt_long(argc, argv, "", shell_options, &shell_index) != -1) {
11420
if (shell_index==-1) {
11424
if (shell_seen[shell_index]==1) {
11425
fprintf(stderr, "Error, `--%s' argument given twice.\n",
11426
shell_options[shell_index].name);
11429
shell_seen[shell_index]=1;
11431
switch (shell_index) {
11432
case 0: /* graph */
11433
shell_read_graph(&graph, optarg);
11439
shell_igraph_is_bipartite_usage(argv);
11448
/* Check that we have all arguments */
11449
for (shell_index=0; shell_index<2; shell_index++) {
11450
if (!shell_seen[shell_index]) {
11451
fprintf(stderr, "Error, argument missing: `--%s'.\n",
11452
shell_options[shell_index].name);
11457
/* Do the operation */
11458
shell_result=igraph_is_bipartite(&graph, &res, type);
11460
/* Write the result */
11461
igraph_destroy(&graph);
11462
shell_write_boolean(res, shell_arg_res);
11467
/*-------------------------------------------/
11468
/ igraph_clusters /
11469
/-------------------------------------------*/
11470
void shell_igraph_clusters_usage(char **argv) {
11471
printf("%s --graph=<graph> --membership=<membership> --csize=<csize> --no=<no> --mode=<mode>\n", basename(argv[0]));
11475
int shell_igraph_clusters(int argc, char **argv) {
11478
igraph_vector_t membership;
11479
igraph_vector_t csize;
11480
igraph_integer_t no;
11481
igraph_connectedness_t mode=IGRAPH_WEAK;
11482
char* shell_arg_membership=0;
11483
char* shell_arg_csize=0;
11484
char* shell_arg_no=0;
11489
int shell_index=-1;
11490
struct option shell_options[]= { { "graph",required_argument,0,0 },
11491
{ "membership",required_argument,0,1 },
11492
{ "csize",required_argument,0,2 },
11493
{ "no",required_argument,0,3 },
11494
{ "mode",required_argument,0,4 },
11495
{ "help",no_argument,0,5 },
11499
/* 0 - not seen, 1 - seen as argument, 2 - seen as default */
11500
memset(shell_seen, 0, 5*sizeof(int));
11503
/* Parse arguments and read input */
11504
while (getopt_long(argc, argv, "", shell_options, &shell_index) != -1) {
11506
if (shell_index==-1) {
11510
if (shell_seen[shell_index]==1) {
11511
fprintf(stderr, "Error, `--%s' argument given twice.\n",
11512
shell_options[shell_index].name);
11515
shell_seen[shell_index]=1;
11517
switch (shell_index) {
11518
case 0: /* graph */
11519
shell_read_graph(&graph, optarg);
11521
case 1: /* membership */
11522
shell_arg_membership=strdup(optarg);
11523
igraph_vector_init(&membership, 0);
11525
case 2: /* csize */
11526
shell_arg_csize=strdup(optarg);
11527
igraph_vector_init(&csize, 0);
11530
shell_arg_no=strdup(optarg);
11533
shell_read_enum(&mode, optarg, "weak", 1, "strong", 2, 0);
11536
shell_igraph_clusters_usage(argv);
11545
/* Check that we have all arguments */
11546
for (shell_index=0; shell_index<5; shell_index++) {
11547
if (!shell_seen[shell_index]) {
11548
fprintf(stderr, "Error, argument missing: `--%s'.\n",
11549
shell_options[shell_index].name);
11554
/* Do the operation */
11555
shell_result=igraph_clusters(&graph, &membership, &csize, &no, mode);
11557
/* Write the result */
11558
igraph_destroy(&graph);
11559
shell_write_vector(&membership, shell_arg_membership);
11560
igraph_vector_destroy(&membership);
11561
shell_write_vector(&csize, shell_arg_csize);
11562
igraph_vector_destroy(&csize);
11563
shell_write_integer(no, shell_arg_no);
11568
/*-------------------------------------------/
11569
/ igraph_is_connected /
11570
/-------------------------------------------*/
11571
void shell_igraph_is_connected_usage(char **argv) {
11572
printf("%s --graph=<graph> --res=<res> --mode=<mode>\n", basename(argv[0]));
11576
int shell_igraph_is_connected(int argc, char **argv) {
11580
igraph_connectedness_t mode=IGRAPH_WEAK;
11581
char* shell_arg_res=0;
11586
int shell_index=-1;
11587
struct option shell_options[]= { { "graph",required_argument,0,0 },
11588
{ "res",required_argument,0,1 },
11589
{ "mode",required_argument,0,2 },
11590
{ "help",no_argument,0,3 },
11594
/* 0 - not seen, 1 - seen as argument, 2 - seen as default */
11595
memset(shell_seen, 0, 3*sizeof(int));
11598
/* Parse arguments and read input */
11599
while (getopt_long(argc, argv, "", shell_options, &shell_index) != -1) {
11601
if (shell_index==-1) {
11605
if (shell_seen[shell_index]==1) {
11606
fprintf(stderr, "Error, `--%s' argument given twice.\n",
11607
shell_options[shell_index].name);
11610
shell_seen[shell_index]=1;
11612
switch (shell_index) {
11613
case 0: /* graph */
11614
shell_read_graph(&graph, optarg);
11620
shell_read_enum(&mode, optarg, "weak", 1, "strong", 2, 0);
11623
shell_igraph_is_connected_usage(argv);
11632
/* Check that we have all arguments */
11633
for (shell_index=0; shell_index<3; shell_index++) {
11634
if (!shell_seen[shell_index]) {
11635
fprintf(stderr, "Error, argument missing: `--%s'.\n",
11636
shell_options[shell_index].name);
11641
/* Do the operation */
11642
shell_result=igraph_is_connected(&graph, &res, mode);
11644
/* Write the result */
11645
igraph_destroy(&graph);
11646
shell_write_boolean(res, shell_arg_res);
11651
/*-------------------------------------------/
11652
/ igraph_decompose /
11653
/-------------------------------------------*/
11654
void shell_igraph_decompose_usage(char **argv) {
11655
printf("%s --graph=<graph> --components=<components> --mode=<mode> --maxcompno=<maxcompno> --minelements=<minelements>\n", basename(argv[0]));
11659
int shell_igraph_decompose(int argc, char **argv) {
11662
igraph_vector_ptr_t components;
11663
igraph_connectedness_t mode=IGRAPH_WEAK;
11664
long int maxcompno=-1;
11665
long int minelements=1;
11666
char* shell_arg_components=0;
11671
int shell_index=-1;
11672
struct option shell_options[]= { { "graph",required_argument,0,0 },
11673
{ "components",required_argument,0,1 },
11674
{ "mode",required_argument,0,2 },
11675
{ "maxcompno",required_argument,0,3 },
11676
{ "minelements",required_argument,0,4 },
11677
{ "help",no_argument,0,5 },
11681
/* 0 - not seen, 1 - seen as argument, 2 - seen as default */
11682
memset(shell_seen, 0, 5*sizeof(int));
11687
/* Parse arguments and read input */
11688
while (getopt_long(argc, argv, "", shell_options, &shell_index) != -1) {
11690
if (shell_index==-1) {
11694
if (shell_seen[shell_index]==1) {
11695
fprintf(stderr, "Error, `--%s' argument given twice.\n",
11696
shell_options[shell_index].name);
11699
shell_seen[shell_index]=1;
11701
switch (shell_index) {
11702
case 0: /* graph */
11703
shell_read_graph(&graph, optarg);
11705
case 1: /* components */
11706
igraph_vector_ptr_init(&components, 0);
11709
shell_read_enum(&mode, optarg, "weak", 1, "strong", 2, 0);
11711
case 3: /* maxcompno */
11712
shell_read_longint(&maxcompno, optarg);
11714
case 4: /* minelements */
11715
shell_read_longint(&minelements, optarg);
11718
shell_igraph_decompose_usage(argv);
11727
/* Check that we have all arguments */
11728
for (shell_index=0; shell_index<5; shell_index++) {
11729
if (!shell_seen[shell_index]) {
11730
fprintf(stderr, "Error, argument missing: `--%s'.\n",
11731
shell_options[shell_index].name);
11736
/* Do the operation */
11737
shell_result=igraph_decompose(&graph, &components, mode, maxcompno, minelements);
11739
/* Write the result */
11740
igraph_destroy(&graph);
11741
shell_write_graphlist(&components, shell_arg_components);
11742
shell_free_graphlist(&components);
11743
igraph_vector_ptr_destroy(&components);
11748
/*-------------------------------------------/
11749
/ igraph_articulation_points /
11750
/-------------------------------------------*/
11751
void shell_igraph_articulation_points_usage(char **argv) {
11752
printf("%s --graph=<graph> --res=<res>\n", basename(argv[0]));
11756
int shell_igraph_articulation_points(int argc, char **argv) {
11759
igraph_vector_t res;
11760
char* shell_arg_res=0;
11765
int shell_index=-1;
11766
struct option shell_options[]= { { "graph",required_argument,0,0 },
11767
{ "res",required_argument,0,1 },
11768
{ "help",no_argument,0,2 },
11772
/* 0 - not seen, 1 - seen as argument, 2 - seen as default */
11773
memset(shell_seen, 0, 2*sizeof(int));
11776
/* Parse arguments and read input */
11777
while (getopt_long(argc, argv, "", shell_options, &shell_index) != -1) {
11779
if (shell_index==-1) {
11783
if (shell_seen[shell_index]==1) {
11784
fprintf(stderr, "Error, `--%s' argument given twice.\n",
11785
shell_options[shell_index].name);
11788
shell_seen[shell_index]=1;
11790
switch (shell_index) {
11791
case 0: /* graph */
11792
shell_read_graph(&graph, optarg);
11795
shell_arg_res=strdup(optarg);
11796
igraph_vector_init(&res, 0);
11799
shell_igraph_articulation_points_usage(argv);
11808
/* Check that we have all arguments */
11809
for (shell_index=0; shell_index<2; shell_index++) {
11810
if (!shell_seen[shell_index]) {
11811
fprintf(stderr, "Error, argument missing: `--%s'.\n",
11812
shell_options[shell_index].name);
11817
/* Do the operation */
11818
shell_result=igraph_articulation_points(&graph, &res);
11820
/* Write the result */
11821
igraph_destroy(&graph);
11822
shell_write_vector(&res, shell_arg_res);
11823
igraph_vector_destroy(&res);
11828
/*-------------------------------------------/
11829
/ igraph_biconnected_components /
11830
/-------------------------------------------*/
11831
void shell_igraph_biconnected_components_usage(char **argv) {
11832
printf("%s --graph=<graph> --no=<no> --components=<components> --articulation_points=<articulation_points>\n", basename(argv[0]));
11836
int shell_igraph_biconnected_components(int argc, char **argv) {
11839
igraph_integer_t no;
11840
igraph_vector_ptr_t components;
11841
igraph_vector_t articulation_points;
11842
char* shell_arg_no=0;
11843
char* shell_arg_components=0;
11844
char* shell_arg_articulation_points=0;
11849
int shell_index=-1;
11850
struct option shell_options[]= { { "graph",required_argument,0,0 },
11851
{ "no",required_argument,0,1 },
11852
{ "components",required_argument,0,2 },
11853
{ "articulation_points",required_argument,0,3 },
11854
{ "help",no_argument,0,4 },
11858
/* 0 - not seen, 1 - seen as argument, 2 - seen as default */
11859
memset(shell_seen, 0, 4*sizeof(int));
11862
/* Parse arguments and read input */
11863
while (getopt_long(argc, argv, "", shell_options, &shell_index) != -1) {
11865
if (shell_index==-1) {
11869
if (shell_seen[shell_index]==1) {
11870
fprintf(stderr, "Error, `--%s' argument given twice.\n",
11871
shell_options[shell_index].name);
11874
shell_seen[shell_index]=1;
11876
switch (shell_index) {
11877
case 0: /* graph */
11878
shell_read_graph(&graph, optarg);
11881
shell_arg_no=strdup(optarg);
11883
case 2: /* components */
11884
igraph_vector_ptr_init(&components, 0);
11886
case 3: /* articulation_points */
11887
shell_arg_articulation_points=strdup(optarg);
11888
igraph_vector_init(&articulation_points, 0);
11891
shell_igraph_biconnected_components_usage(argv);
11900
/* Check that we have all arguments */
11901
for (shell_index=0; shell_index<4; shell_index++) {
11902
if (!shell_seen[shell_index]) {
11903
fprintf(stderr, "Error, argument missing: `--%s'.\n",
11904
shell_options[shell_index].name);
11909
/* Do the operation */
11910
shell_result=igraph_biconnected_components(&graph, &no, &components, &articulation_points);
11912
/* Write the result */
11913
igraph_destroy(&graph);
11914
shell_write_integer(no, shell_arg_no);
11915
shell_write_vectorlist(&components, shell_arg_components);
11916
shell_free_vectorlist(&components);
11917
igraph_vector_ptr_destroy(&components);
11918
shell_write_vector(&articulation_points, shell_arg_articulation_points);
11919
igraph_vector_destroy(&articulation_points);
11924
/*-------------------------------------------/
11926
/-------------------------------------------*/
11927
void shell_igraph_cliques_usage(char **argv) {
11928
printf("%s --graph=<graph> --res=<res> --min_size=<min_size> --max_size=<max_size>\n", basename(argv[0]));
11932
int shell_igraph_cliques(int argc, char **argv) {
11935
igraph_vector_ptr_t res;
11936
igraph_integer_t min_size=0;
11937
igraph_integer_t max_size=0;
11938
char* shell_arg_res=0;
11943
int shell_index=-1;
11944
struct option shell_options[]= { { "graph",required_argument,0,0 },
11945
{ "res",required_argument,0,1 },
11946
{ "min_size",required_argument,0,2 },
11947
{ "max_size",required_argument,0,3 },
11948
{ "help",no_argument,0,4 },
11952
/* 0 - not seen, 1 - seen as argument, 2 - seen as default */
11953
memset(shell_seen, 0, 4*sizeof(int));
11957
/* Parse arguments and read input */
11958
while (getopt_long(argc, argv, "", shell_options, &shell_index) != -1) {
11960
if (shell_index==-1) {
11964
if (shell_seen[shell_index]==1) {
11965
fprintf(stderr, "Error, `--%s' argument given twice.\n",
11966
shell_options[shell_index].name);
11969
shell_seen[shell_index]=1;
11971
switch (shell_index) {
11972
case 0: /* graph */
11973
shell_read_graph(&graph, optarg);
11976
igraph_vector_ptr_init(&res, 0);
11978
case 2: /* min_size */
11979
shell_read_integer(&min_size, optarg);
11981
case 3: /* max_size */
11982
shell_read_integer(&max_size, optarg);
11985
shell_igraph_cliques_usage(argv);
11994
/* Check that we have all arguments */
11995
for (shell_index=0; shell_index<4; shell_index++) {
11996
if (!shell_seen[shell_index]) {
11997
fprintf(stderr, "Error, argument missing: `--%s'.\n",
11998
shell_options[shell_index].name);
12003
/* Do the operation */
12004
shell_result=igraph_cliques(&graph, &res, min_size, max_size);
12006
/* Write the result */
12007
igraph_destroy(&graph);
12008
shell_write_vectorlist(&res, shell_arg_res);
12009
shell_free_vectorlist(&res);
12010
igraph_vector_ptr_destroy(&res);
12015
/*-------------------------------------------/
12016
/ igraph_largest_cliques /
12017
/-------------------------------------------*/
12018
void shell_igraph_largest_cliques_usage(char **argv) {
12019
printf("%s --graph=<graph> --res=<res>\n", basename(argv[0]));
12023
int shell_igraph_largest_cliques(int argc, char **argv) {
12026
igraph_vector_ptr_t res;
12027
char* shell_arg_res=0;
12032
int shell_index=-1;
12033
struct option shell_options[]= { { "graph",required_argument,0,0 },
12034
{ "res",required_argument,0,1 },
12035
{ "help",no_argument,0,2 },
12039
/* 0 - not seen, 1 - seen as argument, 2 - seen as default */
12040
memset(shell_seen, 0, 2*sizeof(int));
12043
/* Parse arguments and read input */
12044
while (getopt_long(argc, argv, "", shell_options, &shell_index) != -1) {
12046
if (shell_index==-1) {
12050
if (shell_seen[shell_index]==1) {
12051
fprintf(stderr, "Error, `--%s' argument given twice.\n",
12052
shell_options[shell_index].name);
12055
shell_seen[shell_index]=1;
12057
switch (shell_index) {
12058
case 0: /* graph */
12059
shell_read_graph(&graph, optarg);
12062
igraph_vector_ptr_init(&res, 0);
12065
shell_igraph_largest_cliques_usage(argv);
12074
/* Check that we have all arguments */
12075
for (shell_index=0; shell_index<2; shell_index++) {
12076
if (!shell_seen[shell_index]) {
12077
fprintf(stderr, "Error, argument missing: `--%s'.\n",
12078
shell_options[shell_index].name);
12083
/* Do the operation */
12084
shell_result=igraph_largest_cliques(&graph, &res);
12086
/* Write the result */
12087
igraph_destroy(&graph);
12088
shell_write_vectorlist(&res, shell_arg_res);
12089
shell_free_vectorlist(&res);
12090
igraph_vector_ptr_destroy(&res);
12095
/*-------------------------------------------/
12096
/ igraph_maximal_cliques /
12097
/-------------------------------------------*/
12098
void shell_igraph_maximal_cliques_usage(char **argv) {
12099
printf("%s --graph=<graph> --res=<res>\n", basename(argv[0]));
12103
int shell_igraph_maximal_cliques(int argc, char **argv) {
12106
igraph_vector_ptr_t res;
12107
char* shell_arg_res=0;
12112
int shell_index=-1;
12113
struct option shell_options[]= { { "graph",required_argument,0,0 },
12114
{ "res",required_argument,0,1 },
12115
{ "help",no_argument,0,2 },
12119
/* 0 - not seen, 1 - seen as argument, 2 - seen as default */
12120
memset(shell_seen, 0, 2*sizeof(int));
12123
/* Parse arguments and read input */
12124
while (getopt_long(argc, argv, "", shell_options, &shell_index) != -1) {
12126
if (shell_index==-1) {
12130
if (shell_seen[shell_index]==1) {
12131
fprintf(stderr, "Error, `--%s' argument given twice.\n",
12132
shell_options[shell_index].name);
12135
shell_seen[shell_index]=1;
12137
switch (shell_index) {
12138
case 0: /* graph */
12139
shell_read_graph(&graph, optarg);
12142
igraph_vector_ptr_init(&res, 0);
12145
shell_igraph_maximal_cliques_usage(argv);
12154
/* Check that we have all arguments */
12155
for (shell_index=0; shell_index<2; shell_index++) {
12156
if (!shell_seen[shell_index]) {
12157
fprintf(stderr, "Error, argument missing: `--%s'.\n",
12158
shell_options[shell_index].name);
12163
/* Do the operation */
12164
shell_result=igraph_maximal_cliques(&graph, &res);
12166
/* Write the result */
12167
igraph_destroy(&graph);
12168
shell_write_vectorlist(&res, shell_arg_res);
12169
shell_free_vectorlist(&res);
12170
igraph_vector_ptr_destroy(&res);
12175
/*-------------------------------------------/
12176
/ igraph_clique_number /
12177
/-------------------------------------------*/
12178
void shell_igraph_clique_number_usage(char **argv) {
12179
printf("%s --graph=<graph> --no=<no>\n", basename(argv[0]));
12183
int shell_igraph_clique_number(int argc, char **argv) {
12186
igraph_integer_t no;
12187
char* shell_arg_no=0;
12192
int shell_index=-1;
12193
struct option shell_options[]= { { "graph",required_argument,0,0 },
12194
{ "no",required_argument,0,1 },
12195
{ "help",no_argument,0,2 },
12199
/* 0 - not seen, 1 - seen as argument, 2 - seen as default */
12200
memset(shell_seen, 0, 2*sizeof(int));
12203
/* Parse arguments and read input */
12204
while (getopt_long(argc, argv, "", shell_options, &shell_index) != -1) {
12206
if (shell_index==-1) {
12210
if (shell_seen[shell_index]==1) {
12211
fprintf(stderr, "Error, `--%s' argument given twice.\n",
12212
shell_options[shell_index].name);
12215
shell_seen[shell_index]=1;
12217
switch (shell_index) {
12218
case 0: /* graph */
12219
shell_read_graph(&graph, optarg);
12222
shell_arg_no=strdup(optarg);
12225
shell_igraph_clique_number_usage(argv);
12234
/* Check that we have all arguments */
12235
for (shell_index=0; shell_index<2; shell_index++) {
12236
if (!shell_seen[shell_index]) {
12237
fprintf(stderr, "Error, argument missing: `--%s'.\n",
12238
shell_options[shell_index].name);
12243
/* Do the operation */
12244
shell_result=igraph_clique_number(&graph, &no);
12246
/* Write the result */
12247
igraph_destroy(&graph);
12248
shell_write_integer(no, shell_arg_no);
12253
/*-------------------------------------------/
12254
/ igraph_independent_vertex_sets /
12255
/-------------------------------------------*/
12256
void shell_igraph_independent_vertex_sets_usage(char **argv) {
12257
printf("%s --graph=<graph> --res=<res> --min_size=<min_size> --max_size=<max_size>\n", basename(argv[0]));
12261
int shell_igraph_independent_vertex_sets(int argc, char **argv) {
12264
igraph_vector_ptr_t res;
12265
igraph_integer_t min_size=0;
12266
igraph_integer_t max_size=0;
12267
char* shell_arg_res=0;
12272
int shell_index=-1;
12273
struct option shell_options[]= { { "graph",required_argument,0,0 },
12274
{ "res",required_argument,0,1 },
12275
{ "min_size",required_argument,0,2 },
12276
{ "max_size",required_argument,0,3 },
12277
{ "help",no_argument,0,4 },
12281
/* 0 - not seen, 1 - seen as argument, 2 - seen as default */
12282
memset(shell_seen, 0, 4*sizeof(int));
12286
/* Parse arguments and read input */
12287
while (getopt_long(argc, argv, "", shell_options, &shell_index) != -1) {
12289
if (shell_index==-1) {
12293
if (shell_seen[shell_index]==1) {
12294
fprintf(stderr, "Error, `--%s' argument given twice.\n",
12295
shell_options[shell_index].name);
12298
shell_seen[shell_index]=1;
12300
switch (shell_index) {
12301
case 0: /* graph */
12302
shell_read_graph(&graph, optarg);
12305
igraph_vector_ptr_init(&res, 0);
12307
case 2: /* min_size */
12308
shell_read_integer(&min_size, optarg);
12310
case 3: /* max_size */
12311
shell_read_integer(&max_size, optarg);
12314
shell_igraph_independent_vertex_sets_usage(argv);
12323
/* Check that we have all arguments */
12324
for (shell_index=0; shell_index<4; shell_index++) {
12325
if (!shell_seen[shell_index]) {
12326
fprintf(stderr, "Error, argument missing: `--%s'.\n",
12327
shell_options[shell_index].name);
12332
/* Do the operation */
12333
shell_result=igraph_independent_vertex_sets(&graph, &res, min_size, max_size);
12335
/* Write the result */
12336
igraph_destroy(&graph);
12337
shell_write_vectorlist(&res, shell_arg_res);
12338
shell_free_vectorlist(&res);
12339
igraph_vector_ptr_destroy(&res);
12344
/*-------------------------------------------/
12345
/ igraph_largest_independent_vertex_sets /
12346
/-------------------------------------------*/
12347
void shell_igraph_largest_independent_vertex_sets_usage(char **argv) {
12348
printf("%s --graph=<graph> --res=<res>\n", basename(argv[0]));
12352
int shell_igraph_largest_independent_vertex_sets(int argc, char **argv) {
12355
igraph_vector_ptr_t res;
12356
char* shell_arg_res=0;
12361
int shell_index=-1;
12362
struct option shell_options[]= { { "graph",required_argument,0,0 },
12363
{ "res",required_argument,0,1 },
12364
{ "help",no_argument,0,2 },
12368
/* 0 - not seen, 1 - seen as argument, 2 - seen as default */
12369
memset(shell_seen, 0, 2*sizeof(int));
12372
/* Parse arguments and read input */
12373
while (getopt_long(argc, argv, "", shell_options, &shell_index) != -1) {
12375
if (shell_index==-1) {
12379
if (shell_seen[shell_index]==1) {
12380
fprintf(stderr, "Error, `--%s' argument given twice.\n",
12381
shell_options[shell_index].name);
12384
shell_seen[shell_index]=1;
12386
switch (shell_index) {
12387
case 0: /* graph */
12388
shell_read_graph(&graph, optarg);
12391
igraph_vector_ptr_init(&res, 0);
12394
shell_igraph_largest_independent_vertex_sets_usage(argv);
12403
/* Check that we have all arguments */
12404
for (shell_index=0; shell_index<2; shell_index++) {
12405
if (!shell_seen[shell_index]) {
12406
fprintf(stderr, "Error, argument missing: `--%s'.\n",
12407
shell_options[shell_index].name);
12412
/* Do the operation */
12413
shell_result=igraph_largest_independent_vertex_sets(&graph, &res);
12415
/* Write the result */
12416
igraph_destroy(&graph);
12417
shell_write_vectorlist(&res, shell_arg_res);
12418
shell_free_vectorlist(&res);
12419
igraph_vector_ptr_destroy(&res);
12424
/*-------------------------------------------/
12425
/ igraph_maximal_independent_vertex_sets /
12426
/-------------------------------------------*/
12427
void shell_igraph_maximal_independent_vertex_sets_usage(char **argv) {
12428
printf("%s --graph=<graph> --res=<res>\n", basename(argv[0]));
12432
int shell_igraph_maximal_independent_vertex_sets(int argc, char **argv) {
12435
igraph_vector_ptr_t res;
12436
char* shell_arg_res=0;
12441
int shell_index=-1;
12442
struct option shell_options[]= { { "graph",required_argument,0,0 },
12443
{ "res",required_argument,0,1 },
12444
{ "help",no_argument,0,2 },
12448
/* 0 - not seen, 1 - seen as argument, 2 - seen as default */
12449
memset(shell_seen, 0, 2*sizeof(int));
12452
/* Parse arguments and read input */
12453
while (getopt_long(argc, argv, "", shell_options, &shell_index) != -1) {
12455
if (shell_index==-1) {
12459
if (shell_seen[shell_index]==1) {
12460
fprintf(stderr, "Error, `--%s' argument given twice.\n",
12461
shell_options[shell_index].name);
12464
shell_seen[shell_index]=1;
12466
switch (shell_index) {
12467
case 0: /* graph */
12468
shell_read_graph(&graph, optarg);
12471
igraph_vector_ptr_init(&res, 0);
12474
shell_igraph_maximal_independent_vertex_sets_usage(argv);
12483
/* Check that we have all arguments */
12484
for (shell_index=0; shell_index<2; shell_index++) {
12485
if (!shell_seen[shell_index]) {
12486
fprintf(stderr, "Error, argument missing: `--%s'.\n",
12487
shell_options[shell_index].name);
12492
/* Do the operation */
12493
shell_result=igraph_maximal_independent_vertex_sets(&graph, &res);
12495
/* Write the result */
12496
igraph_destroy(&graph);
12497
shell_write_vectorlist(&res, shell_arg_res);
12498
shell_free_vectorlist(&res);
12499
igraph_vector_ptr_destroy(&res);
12504
/*-------------------------------------------/
12505
/ igraph_independence_number /
12506
/-------------------------------------------*/
12507
void shell_igraph_independence_number_usage(char **argv) {
12508
printf("%s --graph=<graph> --no=<no>\n", basename(argv[0]));
12512
int shell_igraph_independence_number(int argc, char **argv) {
12515
igraph_integer_t no;
12516
char* shell_arg_no=0;
12521
int shell_index=-1;
12522
struct option shell_options[]= { { "graph",required_argument,0,0 },
12523
{ "no",required_argument,0,1 },
12524
{ "help",no_argument,0,2 },
12528
/* 0 - not seen, 1 - seen as argument, 2 - seen as default */
12529
memset(shell_seen, 0, 2*sizeof(int));
12532
/* Parse arguments and read input */
12533
while (getopt_long(argc, argv, "", shell_options, &shell_index) != -1) {
12535
if (shell_index==-1) {
12539
if (shell_seen[shell_index]==1) {
12540
fprintf(stderr, "Error, `--%s' argument given twice.\n",
12541
shell_options[shell_index].name);
12544
shell_seen[shell_index]=1;
12546
switch (shell_index) {
12547
case 0: /* graph */
12548
shell_read_graph(&graph, optarg);
12551
shell_arg_no=strdup(optarg);
12554
shell_igraph_independence_number_usage(argv);
12563
/* Check that we have all arguments */
12564
for (shell_index=0; shell_index<2; shell_index++) {
12565
if (!shell_seen[shell_index]) {
12566
fprintf(stderr, "Error, argument missing: `--%s'.\n",
12567
shell_options[shell_index].name);
12572
/* Do the operation */
12573
shell_result=igraph_independence_number(&graph, &no);
12575
/* Write the result */
12576
igraph_destroy(&graph);
12577
shell_write_integer(no, shell_arg_no);
12582
/*-------------------------------------------/
12583
/ igraph_layout_random /
12584
/-------------------------------------------*/
12585
void shell_igraph_layout_random_usage(char **argv) {
12586
printf("%s --graph=<graph> --res=<res>\n", basename(argv[0]));
12590
int shell_igraph_layout_random(int argc, char **argv) {
12593
igraph_matrix_t res;
12594
char* shell_arg_res=0;
12599
int shell_index=-1;
12600
struct option shell_options[]= { { "graph",required_argument,0,0 },
12601
{ "res",required_argument,0,1 },
12602
{ "help",no_argument,0,2 },
12606
/* 0 - not seen, 1 - seen as argument, 2 - seen as default */
12607
memset(shell_seen, 0, 2*sizeof(int));
12610
/* Parse arguments and read input */
12611
while (getopt_long(argc, argv, "", shell_options, &shell_index) != -1) {
12613
if (shell_index==-1) {
12617
if (shell_seen[shell_index]==1) {
12618
fprintf(stderr, "Error, `--%s' argument given twice.\n",
12619
shell_options[shell_index].name);
12622
shell_seen[shell_index]=1;
12624
switch (shell_index) {
12625
case 0: /* graph */
12626
shell_read_graph(&graph, optarg);
12629
shell_arg_res=strdup(optarg);
12630
igraph_matrix_init(&res, 0, 0);
12633
shell_igraph_layout_random_usage(argv);
12642
/* Check that we have all arguments */
12643
for (shell_index=0; shell_index<2; shell_index++) {
12644
if (!shell_seen[shell_index]) {
12645
fprintf(stderr, "Error, argument missing: `--%s'.\n",
12646
shell_options[shell_index].name);
12651
/* Do the operation */
12652
shell_result=igraph_layout_random(&graph, &res);
12654
/* Write the result */
12655
igraph_destroy(&graph);
12656
shell_write_matrix(&res, shell_arg_res);
12657
igraph_matrix_destroy(&res);
12662
/*-------------------------------------------/
12663
/ igraph_layout_circle /
12664
/-------------------------------------------*/
12665
void shell_igraph_layout_circle_usage(char **argv) {
12666
printf("%s --graph=<graph> --res=<res>\n", basename(argv[0]));
12670
int shell_igraph_layout_circle(int argc, char **argv) {
12673
igraph_matrix_t res;
12674
char* shell_arg_res=0;
12679
int shell_index=-1;
12680
struct option shell_options[]= { { "graph",required_argument,0,0 },
12681
{ "res",required_argument,0,1 },
12682
{ "help",no_argument,0,2 },
12686
/* 0 - not seen, 1 - seen as argument, 2 - seen as default */
12687
memset(shell_seen, 0, 2*sizeof(int));
12690
/* Parse arguments and read input */
12691
while (getopt_long(argc, argv, "", shell_options, &shell_index) != -1) {
12693
if (shell_index==-1) {
12697
if (shell_seen[shell_index]==1) {
12698
fprintf(stderr, "Error, `--%s' argument given twice.\n",
12699
shell_options[shell_index].name);
12702
shell_seen[shell_index]=1;
12704
switch (shell_index) {
12705
case 0: /* graph */
12706
shell_read_graph(&graph, optarg);
12709
shell_arg_res=strdup(optarg);
12710
igraph_matrix_init(&res, 0, 0);
12713
shell_igraph_layout_circle_usage(argv);
12722
/* Check that we have all arguments */
12723
for (shell_index=0; shell_index<2; shell_index++) {
12724
if (!shell_seen[shell_index]) {
12725
fprintf(stderr, "Error, argument missing: `--%s'.\n",
12726
shell_options[shell_index].name);
12731
/* Do the operation */
12732
shell_result=igraph_layout_circle(&graph, &res);
12734
/* Write the result */
12735
igraph_destroy(&graph);
12736
shell_write_matrix(&res, shell_arg_res);
12737
igraph_matrix_destroy(&res);
12742
/*-------------------------------------------/
12743
/ igraph_layout_fruchterman_reingold /
12744
/-------------------------------------------*/
12745
void shell_igraph_layout_fruchterman_reingold_usage(char **argv) {
12746
printf("%s --graph=<graph> --res=<res> --niter=<niter> --maxdelta=<maxdelta> --area=<area> --coolexp=<coolexp> --repulserad=<repulserad> --weight=<weight>\n", basename(argv[0]));
12750
int shell_igraph_layout_fruchterman_reingold(int argc, char **argv) {
12753
igraph_matrix_t res;
12754
igraph_integer_t niter=500;
12755
igraph_real_t maxdelta=100;
12756
igraph_real_t area=1000;
12757
igraph_real_t coolexp=1.5;
12758
igraph_real_t repulserad=10000;
12760
igraph_vector_t v_weight; igraph_vector_t *weight=0;
12761
char* shell_arg_res=0;
12766
int shell_index=-1;
12767
struct option shell_options[]= { { "graph",required_argument,0,0 },
12768
{ "res",required_argument,0,1 },
12769
{ "niter",required_argument,0,2 },
12770
{ "maxdelta",required_argument,0,3 },
12771
{ "area",required_argument,0,4 },
12772
{ "coolexp",required_argument,0,5 },
12773
{ "repulserad",required_argument,0,6 },
12774
{ "weight",required_argument,0,7 },
12775
{ "help",no_argument,0,8 },
12779
/* 0 - not seen, 1 - seen as argument, 2 - seen as default */
12780
memset(shell_seen, 0, 8*sizeof(int));
12787
/* Parse arguments and read input */
12788
while (getopt_long(argc, argv, "", shell_options, &shell_index) != -1) {
12790
if (shell_index==-1) {
12794
if (shell_seen[shell_index]==1) {
12795
fprintf(stderr, "Error, `--%s' argument given twice.\n",
12796
shell_options[shell_index].name);
12799
shell_seen[shell_index]=1;
12801
switch (shell_index) {
12802
case 0: /* graph */
12803
shell_read_graph(&graph, optarg);
12806
shell_arg_res=strdup(optarg);
12807
igraph_matrix_init(&res, 0, 0);
12809
case 2: /* niter */
12810
shell_read_integer(&niter, optarg);
12812
case 3: /* maxdelta */
12813
shell_read_real(&maxdelta, optarg);
12816
shell_read_real(&area, optarg);
12818
case 5: /* coolexp */
12819
shell_read_real(&coolexp, optarg);
12821
case 6: /* repulserad */
12822
shell_read_real(&repulserad, optarg);
12824
case 7: /* weight */
12825
weight=&v_weight; shell_read_vector(weight, optarg);
12828
shell_igraph_layout_fruchterman_reingold_usage(argv);
12837
/* Check that we have all arguments */
12838
for (shell_index=0; shell_index<8; shell_index++) {
12839
if (!shell_seen[shell_index]) {
12840
fprintf(stderr, "Error, argument missing: `--%s'.\n",
12841
shell_options[shell_index].name);
12846
/* Do the operation */
12847
shell_result=igraph_layout_fruchterman_reingold(&graph, &res, niter, maxdelta, area, coolexp, repulserad, 0, weight);
12849
/* Write the result */
12850
igraph_destroy(&graph);
12851
shell_write_matrix(&res, shell_arg_res);
12852
igraph_matrix_destroy(&res);
12853
if (weight) { igraph_vector_destroy(weight); }
12858
/*-------------------------------------------/
12859
/ igraph_layout_grid_fruchterman_reingold /
12860
/-------------------------------------------*/
12861
void shell_igraph_layout_grid_fruchterman_reingold_usage(char **argv) {
12862
printf("%s --graph=<graph> --res=<res> --niter=<niter> --maxdelta=<maxdelta> --area=<area> --coolexp=<coolexp> --repulserad=<repulserad> --cellsize=<cellsize>\n", basename(argv[0]));
12866
int shell_igraph_layout_grid_fruchterman_reingold(int argc, char **argv) {
12869
igraph_matrix_t res;
12870
igraph_integer_t niter=500;
12871
igraph_real_t maxdelta=100;
12872
igraph_real_t area=1000;
12873
igraph_real_t coolexp=1.5;
12874
igraph_real_t repulserad=10000;
12875
igraph_real_t cellsize=100;
12877
char* shell_arg_res=0;
12882
int shell_index=-1;
12883
struct option shell_options[]= { { "graph",required_argument,0,0 },
12884
{ "res",required_argument,0,1 },
12885
{ "niter",required_argument,0,2 },
12886
{ "maxdelta",required_argument,0,3 },
12887
{ "area",required_argument,0,4 },
12888
{ "coolexp",required_argument,0,5 },
12889
{ "repulserad",required_argument,0,6 },
12890
{ "cellsize",required_argument,0,7 },
12891
{ "help",no_argument,0,8 },
12895
/* 0 - not seen, 1 - seen as argument, 2 - seen as default */
12896
memset(shell_seen, 0, 8*sizeof(int));
12904
/* Parse arguments and read input */
12905
while (getopt_long(argc, argv, "", shell_options, &shell_index) != -1) {
12907
if (shell_index==-1) {
12911
if (shell_seen[shell_index]==1) {
12912
fprintf(stderr, "Error, `--%s' argument given twice.\n",
12913
shell_options[shell_index].name);
12916
shell_seen[shell_index]=1;
12918
switch (shell_index) {
12919
case 0: /* graph */
12920
shell_read_graph(&graph, optarg);
12923
shell_arg_res=strdup(optarg);
12924
igraph_matrix_init(&res, 0, 0);
12926
case 2: /* niter */
12927
shell_read_integer(&niter, optarg);
12929
case 3: /* maxdelta */
12930
shell_read_real(&maxdelta, optarg);
12933
shell_read_real(&area, optarg);
12935
case 5: /* coolexp */
12936
shell_read_real(&coolexp, optarg);
12938
case 6: /* repulserad */
12939
shell_read_real(&repulserad, optarg);
12941
case 7: /* cellsize */
12942
shell_read_real(&cellsize, optarg);
12945
shell_igraph_layout_grid_fruchterman_reingold_usage(argv);
12954
/* Check that we have all arguments */
12955
for (shell_index=0; shell_index<8; shell_index++) {
12956
if (!shell_seen[shell_index]) {
12957
fprintf(stderr, "Error, argument missing: `--%s'.\n",
12958
shell_options[shell_index].name);
12963
/* Do the operation */
12964
shell_result=igraph_layout_grid_fruchterman_reingold(&graph, &res, niter, maxdelta, area, coolexp, repulserad, cellsize, 0);
12966
/* Write the result */
12967
igraph_destroy(&graph);
12968
shell_write_matrix(&res, shell_arg_res);
12969
igraph_matrix_destroy(&res);
12974
/*-------------------------------------------/
12975
/ igraph_layout_kamada_kawai /
12976
/-------------------------------------------*/
12977
void shell_igraph_layout_kamada_kawai_usage(char **argv) {
12978
printf("%s --graph=<graph> --res=<res> --niter=<niter> --sigma=<sigma> --initemp=<initemp> --coolexp=<coolexp> --kkconst=<kkconst>\n", basename(argv[0]));
12982
int shell_igraph_layout_kamada_kawai(int argc, char **argv) {
12985
igraph_matrix_t res;
12986
igraph_integer_t niter=1000;
12987
igraph_real_t sigma=10;
12988
igraph_real_t initemp=10;
12989
igraph_real_t coolexp=0.99;
12990
igraph_real_t kkconst=1000;
12991
char* shell_arg_res=0;
12996
int shell_index=-1;
12997
struct option shell_options[]= { { "graph",required_argument,0,0 },
12998
{ "res",required_argument,0,1 },
12999
{ "niter",required_argument,0,2 },
13000
{ "sigma",required_argument,0,3 },
13001
{ "initemp",required_argument,0,4 },
13002
{ "coolexp",required_argument,0,5 },
13003
{ "kkconst",required_argument,0,6 },
13004
{ "help",no_argument,0,7 },
13008
/* 0 - not seen, 1 - seen as argument, 2 - seen as default */
13009
memset(shell_seen, 0, 7*sizeof(int));
13016
/* Parse arguments and read input */
13017
while (getopt_long(argc, argv, "", shell_options, &shell_index) != -1) {
13019
if (shell_index==-1) {
13023
if (shell_seen[shell_index]==1) {
13024
fprintf(stderr, "Error, `--%s' argument given twice.\n",
13025
shell_options[shell_index].name);
13028
shell_seen[shell_index]=1;
13030
switch (shell_index) {
13031
case 0: /* graph */
13032
shell_read_graph(&graph, optarg);
13035
shell_arg_res=strdup(optarg);
13036
igraph_matrix_init(&res, 0, 0);
13038
case 2: /* niter */
13039
shell_read_integer(&niter, optarg);
13041
case 3: /* sigma */
13042
shell_read_real(&sigma, optarg);
13044
case 4: /* initemp */
13045
shell_read_real(&initemp, optarg);
13047
case 5: /* coolexp */
13048
shell_read_real(&coolexp, optarg);
13050
case 6: /* kkconst */
13051
shell_read_real(&kkconst, optarg);
13054
shell_igraph_layout_kamada_kawai_usage(argv);
13063
/* Check that we have all arguments */
13064
for (shell_index=0; shell_index<7; shell_index++) {
13065
if (!shell_seen[shell_index]) {
13066
fprintf(stderr, "Error, argument missing: `--%s'.\n",
13067
shell_options[shell_index].name);
13072
/* Do the operation */
13073
shell_result=igraph_layout_kamada_kawai(&graph, &res, niter, sigma, initemp, coolexp, kkconst);
13075
/* Write the result */
13076
igraph_destroy(&graph);
13077
shell_write_matrix(&res, shell_arg_res);
13078
igraph_matrix_destroy(&res);
13083
/*-------------------------------------------/
13084
/ igraph_layout_lgl /
13085
/-------------------------------------------*/
13086
void shell_igraph_layout_lgl_usage(char **argv) {
13087
printf("%s --graph=<graph> --res=<res> --maxiter=<maxiter> --maxdelta=<maxdelta> --area=<area> --coolexp=<coolexp> --repulserad=<repulserad> --cellsize=<cellsize> --root=<root>\n", basename(argv[0]));
13091
int shell_igraph_layout_lgl(int argc, char **argv) {
13094
igraph_matrix_t res;
13095
igraph_integer_t maxiter=150;
13096
igraph_real_t maxdelta=100;
13097
igraph_real_t area=1000;
13098
igraph_real_t coolexp=1.5;
13099
igraph_real_t repulserad=10000;
13100
igraph_real_t cellsize=100;
13101
igraph_integer_t root=-1;
13102
char* shell_arg_res=0;
13107
int shell_index=-1;
13108
struct option shell_options[]= { { "graph",required_argument,0,0 },
13109
{ "res",required_argument,0,1 },
13110
{ "maxiter",required_argument,0,2 },
13111
{ "maxdelta",required_argument,0,3 },
13112
{ "area",required_argument,0,4 },
13113
{ "coolexp",required_argument,0,5 },
13114
{ "repulserad",required_argument,0,6 },
13115
{ "cellsize",required_argument,0,7 },
13116
{ "root",required_argument,0,8 },
13117
{ "help",no_argument,0,9 },
13121
/* 0 - not seen, 1 - seen as argument, 2 - seen as default */
13122
memset(shell_seen, 0, 9*sizeof(int));
13131
/* Parse arguments and read input */
13132
while (getopt_long(argc, argv, "", shell_options, &shell_index) != -1) {
13134
if (shell_index==-1) {
13138
if (shell_seen[shell_index]==1) {
13139
fprintf(stderr, "Error, `--%s' argument given twice.\n",
13140
shell_options[shell_index].name);
13143
shell_seen[shell_index]=1;
13145
switch (shell_index) {
13146
case 0: /* graph */
13147
shell_read_graph(&graph, optarg);
13150
shell_arg_res=strdup(optarg);
13151
igraph_matrix_init(&res, 0, 0);
13153
case 2: /* maxiter */
13154
shell_read_integer(&maxiter, optarg);
13156
case 3: /* maxdelta */
13157
shell_read_real(&maxdelta, optarg);
13160
shell_read_real(&area, optarg);
13162
case 5: /* coolexp */
13163
shell_read_real(&coolexp, optarg);
13165
case 6: /* repulserad */
13166
shell_read_real(&repulserad, optarg);
13168
case 7: /* cellsize */
13169
shell_read_real(&cellsize, optarg);
13172
shell_read_integer(&root, optarg);
13175
shell_igraph_layout_lgl_usage(argv);
13184
/* Check that we have all arguments */
13185
for (shell_index=0; shell_index<9; shell_index++) {
13186
if (!shell_seen[shell_index]) {
13187
fprintf(stderr, "Error, argument missing: `--%s'.\n",
13188
shell_options[shell_index].name);
13193
/* Do the operation */
13194
shell_result=igraph_layout_lgl(&graph, &res, maxiter, maxdelta, area, coolexp, repulserad, cellsize, root);
13196
/* Write the result */
13197
igraph_destroy(&graph);
13198
shell_write_matrix(&res, shell_arg_res);
13199
igraph_matrix_destroy(&res);
13204
/*-------------------------------------------/
13205
/ igraph_layout_reingold_tilford /
13206
/-------------------------------------------*/
13207
void shell_igraph_layout_reingold_tilford_usage(char **argv) {
13208
printf("%s --graph=<graph> --res=<res> --root=<root>\n", basename(argv[0]));
13212
int shell_igraph_layout_reingold_tilford(int argc, char **argv) {
13215
igraph_matrix_t res;
13217
char* shell_arg_res=0;
13222
int shell_index=-1;
13223
struct option shell_options[]= { { "graph",required_argument,0,0 },
13224
{ "res",required_argument,0,1 },
13225
{ "root",required_argument,0,2 },
13226
{ "help",no_argument,0,3 },
13230
/* 0 - not seen, 1 - seen as argument, 2 - seen as default */
13231
memset(shell_seen, 0, 3*sizeof(int));
13234
/* Parse arguments and read input */
13235
while (getopt_long(argc, argv, "", shell_options, &shell_index) != -1) {
13237
if (shell_index==-1) {
13241
if (shell_seen[shell_index]==1) {
13242
fprintf(stderr, "Error, `--%s' argument given twice.\n",
13243
shell_options[shell_index].name);
13246
shell_seen[shell_index]=1;
13248
switch (shell_index) {
13249
case 0: /* graph */
13250
shell_read_graph(&graph, optarg);
13253
shell_arg_res=strdup(optarg);
13254
igraph_matrix_init(&res, 0, 0);
13257
shell_read_longint(&root, optarg);
13260
shell_igraph_layout_reingold_tilford_usage(argv);
13269
/* Check that we have all arguments */
13270
for (shell_index=0; shell_index<3; shell_index++) {
13271
if (!shell_seen[shell_index]) {
13272
fprintf(stderr, "Error, argument missing: `--%s'.\n",
13273
shell_options[shell_index].name);
13278
/* Do the operation */
13279
shell_result=igraph_layout_reingold_tilford(&graph, &res, root);
13281
/* Write the result */
13282
igraph_destroy(&graph);
13283
shell_write_matrix(&res, shell_arg_res);
13284
igraph_matrix_destroy(&res);
13289
/*-------------------------------------------/
13290
/ igraph_layout_reingold_tilford_circular /
13291
/-------------------------------------------*/
13292
void shell_igraph_layout_reingold_tilford_circular_usage(char **argv) {
13293
printf("%s --graph=<graph> --res=<res> --root=<root>\n", basename(argv[0]));
13297
int shell_igraph_layout_reingold_tilford_circular(int argc, char **argv) {
13300
igraph_matrix_t res;
13302
char* shell_arg_res=0;
13307
int shell_index=-1;
13308
struct option shell_options[]= { { "graph",required_argument,0,0 },
13309
{ "res",required_argument,0,1 },
13310
{ "root",required_argument,0,2 },
13311
{ "help",no_argument,0,3 },
13315
/* 0 - not seen, 1 - seen as argument, 2 - seen as default */
13316
memset(shell_seen, 0, 3*sizeof(int));
13319
/* Parse arguments and read input */
13320
while (getopt_long(argc, argv, "", shell_options, &shell_index) != -1) {
13322
if (shell_index==-1) {
13326
if (shell_seen[shell_index]==1) {
13327
fprintf(stderr, "Error, `--%s' argument given twice.\n",
13328
shell_options[shell_index].name);
13331
shell_seen[shell_index]=1;
13333
switch (shell_index) {
13334
case 0: /* graph */
13335
shell_read_graph(&graph, optarg);
13338
shell_arg_res=strdup(optarg);
13339
igraph_matrix_init(&res, 0, 0);
13342
shell_read_longint(&root, optarg);
13345
shell_igraph_layout_reingold_tilford_circular_usage(argv);
13354
/* Check that we have all arguments */
13355
for (shell_index=0; shell_index<3; shell_index++) {
13356
if (!shell_seen[shell_index]) {
13357
fprintf(stderr, "Error, argument missing: `--%s'.\n",
13358
shell_options[shell_index].name);
13363
/* Do the operation */
13364
shell_result=igraph_layout_reingold_tilford_circular(&graph, &res, root);
13366
/* Write the result */
13367
igraph_destroy(&graph);
13368
shell_write_matrix(&res, shell_arg_res);
13369
igraph_matrix_destroy(&res);
13374
/*-------------------------------------------/
13375
/ igraph_layout_random_3d /
13376
/-------------------------------------------*/
13377
void shell_igraph_layout_random_3d_usage(char **argv) {
13378
printf("%s --graph=<graph> --res=<res>\n", basename(argv[0]));
13382
int shell_igraph_layout_random_3d(int argc, char **argv) {
13385
igraph_matrix_t res;
13386
char* shell_arg_res=0;
13391
int shell_index=-1;
13392
struct option shell_options[]= { { "graph",required_argument,0,0 },
13393
{ "res",required_argument,0,1 },
13394
{ "help",no_argument,0,2 },
13398
/* 0 - not seen, 1 - seen as argument, 2 - seen as default */
13399
memset(shell_seen, 0, 2*sizeof(int));
13402
/* Parse arguments and read input */
13403
while (getopt_long(argc, argv, "", shell_options, &shell_index) != -1) {
13405
if (shell_index==-1) {
13409
if (shell_seen[shell_index]==1) {
13410
fprintf(stderr, "Error, `--%s' argument given twice.\n",
13411
shell_options[shell_index].name);
13414
shell_seen[shell_index]=1;
13416
switch (shell_index) {
13417
case 0: /* graph */
13418
shell_read_graph(&graph, optarg);
13421
shell_arg_res=strdup(optarg);
13422
igraph_matrix_init(&res, 0, 0);
13425
shell_igraph_layout_random_3d_usage(argv);
13434
/* Check that we have all arguments */
13435
for (shell_index=0; shell_index<2; shell_index++) {
13436
if (!shell_seen[shell_index]) {
13437
fprintf(stderr, "Error, argument missing: `--%s'.\n",
13438
shell_options[shell_index].name);
13443
/* Do the operation */
13444
shell_result=igraph_layout_random_3d(&graph, &res);
13446
/* Write the result */
13447
igraph_destroy(&graph);
13448
shell_write_matrix(&res, shell_arg_res);
13449
igraph_matrix_destroy(&res);
13454
/*-------------------------------------------/
13455
/ igraph_layout_sphere /
13456
/-------------------------------------------*/
13457
void shell_igraph_layout_sphere_usage(char **argv) {
13458
printf("%s --graph=<graph> --res=<res>\n", basename(argv[0]));
13462
int shell_igraph_layout_sphere(int argc, char **argv) {
13465
igraph_matrix_t res;
13466
char* shell_arg_res=0;
13471
int shell_index=-1;
13472
struct option shell_options[]= { { "graph",required_argument,0,0 },
13473
{ "res",required_argument,0,1 },
13474
{ "help",no_argument,0,2 },
13478
/* 0 - not seen, 1 - seen as argument, 2 - seen as default */
13479
memset(shell_seen, 0, 2*sizeof(int));
13482
/* Parse arguments and read input */
13483
while (getopt_long(argc, argv, "", shell_options, &shell_index) != -1) {
13485
if (shell_index==-1) {
13489
if (shell_seen[shell_index]==1) {
13490
fprintf(stderr, "Error, `--%s' argument given twice.\n",
13491
shell_options[shell_index].name);
13494
shell_seen[shell_index]=1;
13496
switch (shell_index) {
13497
case 0: /* graph */
13498
shell_read_graph(&graph, optarg);
13501
shell_arg_res=strdup(optarg);
13502
igraph_matrix_init(&res, 0, 0);
13505
shell_igraph_layout_sphere_usage(argv);
13514
/* Check that we have all arguments */
13515
for (shell_index=0; shell_index<2; shell_index++) {
13516
if (!shell_seen[shell_index]) {
13517
fprintf(stderr, "Error, argument missing: `--%s'.\n",
13518
shell_options[shell_index].name);
13523
/* Do the operation */
13524
shell_result=igraph_layout_sphere(&graph, &res);
13526
/* Write the result */
13527
igraph_destroy(&graph);
13528
shell_write_matrix(&res, shell_arg_res);
13529
igraph_matrix_destroy(&res);
13534
/*-------------------------------------------/
13535
/ igraph_layout_fruchterman_reingold_3d /
13536
/-------------------------------------------*/
13537
void shell_igraph_layout_fruchterman_reingold_3d_usage(char **argv) {
13538
printf("%s --graph=<graph> --res=<res> --niter=<niter> --maxdelta=<maxdelta> --volume=<volume> --coolexp=<coolexp> --repulserad=<repulserad> --weight=<weight>\n", basename(argv[0]));
13542
int shell_igraph_layout_fruchterman_reingold_3d(int argc, char **argv) {
13545
igraph_matrix_t res;
13546
igraph_integer_t niter=500;
13547
igraph_real_t maxdelta=100;
13548
igraph_real_t volume=1000;
13549
igraph_real_t coolexp=1.5;
13550
igraph_real_t repulserad=10000;
13552
igraph_vector_t v_weight; igraph_vector_t *weight=0;
13553
char* shell_arg_res=0;
13558
int shell_index=-1;
13559
struct option shell_options[]= { { "graph",required_argument,0,0 },
13560
{ "res",required_argument,0,1 },
13561
{ "niter",required_argument,0,2 },
13562
{ "maxdelta",required_argument,0,3 },
13563
{ "volume",required_argument,0,4 },
13564
{ "coolexp",required_argument,0,5 },
13565
{ "repulserad",required_argument,0,6 },
13566
{ "weight",required_argument,0,7 },
13567
{ "help",no_argument,0,8 },
13571
/* 0 - not seen, 1 - seen as argument, 2 - seen as default */
13572
memset(shell_seen, 0, 8*sizeof(int));
13579
/* Parse arguments and read input */
13580
while (getopt_long(argc, argv, "", shell_options, &shell_index) != -1) {
13582
if (shell_index==-1) {
13586
if (shell_seen[shell_index]==1) {
13587
fprintf(stderr, "Error, `--%s' argument given twice.\n",
13588
shell_options[shell_index].name);
13591
shell_seen[shell_index]=1;
13593
switch (shell_index) {
13594
case 0: /* graph */
13595
shell_read_graph(&graph, optarg);
13598
shell_arg_res=strdup(optarg);
13599
igraph_matrix_init(&res, 0, 0);
13601
case 2: /* niter */
13602
shell_read_integer(&niter, optarg);
13604
case 3: /* maxdelta */
13605
shell_read_real(&maxdelta, optarg);
13607
case 4: /* volume */
13608
shell_read_real(&volume, optarg);
13610
case 5: /* coolexp */
13611
shell_read_real(&coolexp, optarg);
13613
case 6: /* repulserad */
13614
shell_read_real(&repulserad, optarg);
13616
case 7: /* weight */
13617
weight=&v_weight; shell_read_vector(weight, optarg);
13620
shell_igraph_layout_fruchterman_reingold_3d_usage(argv);
13629
/* Check that we have all arguments */
13630
for (shell_index=0; shell_index<8; shell_index++) {
13631
if (!shell_seen[shell_index]) {
13632
fprintf(stderr, "Error, argument missing: `--%s'.\n",
13633
shell_options[shell_index].name);
13638
/* Do the operation */
13639
shell_result=igraph_layout_fruchterman_reingold_3d(&graph, &res, niter, maxdelta, volume, coolexp, repulserad, 0, weight);
13641
/* Write the result */
13642
igraph_destroy(&graph);
13643
shell_write_matrix(&res, shell_arg_res);
13644
igraph_matrix_destroy(&res);
13645
if (weight) { igraph_vector_destroy(weight); }
13650
/*-------------------------------------------/
13651
/ igraph_layout_kamada_kawai_3d /
13652
/-------------------------------------------*/
13653
void shell_igraph_layout_kamada_kawai_3d_usage(char **argv) {
13654
printf("%s --graph=<graph> --res=<res> --niter=<niter> --sigma=<sigma> --initemp=<initemp> --coolexp=<coolexp> --kkconst=<kkconst>\n", basename(argv[0]));
13658
int shell_igraph_layout_kamada_kawai_3d(int argc, char **argv) {
13661
igraph_matrix_t res;
13662
igraph_integer_t niter=1000;
13663
igraph_real_t sigma=10;
13664
igraph_real_t initemp=10;
13665
igraph_real_t coolexp=0.99;
13666
igraph_real_t kkconst=1000;
13667
char* shell_arg_res=0;
13672
int shell_index=-1;
13673
struct option shell_options[]= { { "graph",required_argument,0,0 },
13674
{ "res",required_argument,0,1 },
13675
{ "niter",required_argument,0,2 },
13676
{ "sigma",required_argument,0,3 },
13677
{ "initemp",required_argument,0,4 },
13678
{ "coolexp",required_argument,0,5 },
13679
{ "kkconst",required_argument,0,6 },
13680
{ "help",no_argument,0,7 },
13684
/* 0 - not seen, 1 - seen as argument, 2 - seen as default */
13685
memset(shell_seen, 0, 7*sizeof(int));
13692
/* Parse arguments and read input */
13693
while (getopt_long(argc, argv, "", shell_options, &shell_index) != -1) {
13695
if (shell_index==-1) {
13699
if (shell_seen[shell_index]==1) {
13700
fprintf(stderr, "Error, `--%s' argument given twice.\n",
13701
shell_options[shell_index].name);
13704
shell_seen[shell_index]=1;
13706
switch (shell_index) {
13707
case 0: /* graph */
13708
shell_read_graph(&graph, optarg);
13711
shell_arg_res=strdup(optarg);
13712
igraph_matrix_init(&res, 0, 0);
13714
case 2: /* niter */
13715
shell_read_integer(&niter, optarg);
13717
case 3: /* sigma */
13718
shell_read_real(&sigma, optarg);
13720
case 4: /* initemp */
13721
shell_read_real(&initemp, optarg);
13723
case 5: /* coolexp */
13724
shell_read_real(&coolexp, optarg);
13726
case 6: /* kkconst */
13727
shell_read_real(&kkconst, optarg);
13730
shell_igraph_layout_kamada_kawai_3d_usage(argv);
13739
/* Check that we have all arguments */
13740
for (shell_index=0; shell_index<7; shell_index++) {
13741
if (!shell_seen[shell_index]) {
13742
fprintf(stderr, "Error, argument missing: `--%s'.\n",
13743
shell_options[shell_index].name);
13748
/* Do the operation */
13749
shell_result=igraph_layout_kamada_kawai_3d(&graph, &res, niter, sigma, initemp, coolexp, kkconst);
13751
/* Write the result */
13752
igraph_destroy(&graph);
13753
shell_write_matrix(&res, shell_arg_res);
13754
igraph_matrix_destroy(&res);
13759
/*-------------------------------------------/
13760
/ igraph_layout_graphopt /
13761
/-------------------------------------------*/
13762
void shell_igraph_layout_graphopt_usage(char **argv) {
13763
printf("%s --graph=<graph> --res=<res> --niter=<niter> --node_charge=<node_charge> --node_mass=<node_mass> --spring_length=<spring_length> --spring_constant=<spring_constant> --max_sa_movement=<max_sa_movement>\n", basename(argv[0]));
13767
int shell_igraph_layout_graphopt(int argc, char **argv) {
13770
igraph_matrix_t res;
13771
igraph_integer_t niter=500;
13772
igraph_real_t node_charge=0.001;
13773
igraph_real_t node_mass=30;
13774
igraph_integer_t spring_length=0;
13775
igraph_real_t spring_constant=1;
13776
igraph_real_t max_sa_movement=5;
13778
char* shell_arg_res=0;
13783
int shell_index=-1;
13784
struct option shell_options[]= { { "graph",required_argument,0,0 },
13785
{ "res",required_argument,0,1 },
13786
{ "niter",required_argument,0,2 },
13787
{ "node_charge",required_argument,0,3 },
13788
{ "node_mass",required_argument,0,4 },
13789
{ "spring_length",required_argument,0,5 },
13790
{ "spring_constant",required_argument,0,6 },
13791
{ "max_sa_movement",required_argument,0,7 },
13792
{ "help",no_argument,0,8 },
13796
/* 0 - not seen, 1 - seen as argument, 2 - seen as default */
13797
memset(shell_seen, 0, 8*sizeof(int));
13805
/* Parse arguments and read input */
13806
while (getopt_long(argc, argv, "", shell_options, &shell_index) != -1) {
13808
if (shell_index==-1) {
13812
if (shell_seen[shell_index]==1) {
13813
fprintf(stderr, "Error, `--%s' argument given twice.\n",
13814
shell_options[shell_index].name);
13817
shell_seen[shell_index]=1;
13819
switch (shell_index) {
13820
case 0: /* graph */
13821
shell_read_graph(&graph, optarg);
13824
shell_arg_res=strdup(optarg);
13825
igraph_matrix_init(&res, 0, 0);
13827
case 2: /* niter */
13828
shell_read_integer(&niter, optarg);
13830
case 3: /* node_charge */
13831
shell_read_real(&node_charge, optarg);
13833
case 4: /* node_mass */
13834
shell_read_real(&node_mass, optarg);
13836
case 5: /* spring_length */
13837
shell_read_integer(&spring_length, optarg);
13839
case 6: /* spring_constant */
13840
shell_read_real(&spring_constant, optarg);
13842
case 7: /* max_sa_movement */
13843
shell_read_real(&max_sa_movement, optarg);
13846
shell_igraph_layout_graphopt_usage(argv);
13855
/* Check that we have all arguments */
13856
for (shell_index=0; shell_index<8; shell_index++) {
13857
if (!shell_seen[shell_index]) {
13858
fprintf(stderr, "Error, argument missing: `--%s'.\n",
13859
shell_options[shell_index].name);
13864
/* Do the operation */
13865
shell_result=igraph_layout_graphopt(&graph, &res, niter, node_charge, node_mass, spring_length, spring_constant, max_sa_movement, 0);
13867
/* Write the result */
13868
igraph_destroy(&graph);
13869
shell_write_matrix(&res, shell_arg_res);
13870
igraph_matrix_destroy(&res);
13875
/*-------------------------------------------/
13876
/ igraph_layout_drl /
13877
/-------------------------------------------*/
13878
void shell_igraph_layout_drl_usage(char **argv) {
13879
printf("%s --graph=<graph> --res=<res> --res-out=<res-out> --use_seed=<use_seed> --weights=<weights>\n", basename(argv[0]));
13883
int shell_igraph_layout_drl(int argc, char **argv) {
13886
igraph_matrix_t res;
13887
igraph_bool_t use_seed=0;
13889
igraph_vector_t v_weights; igraph_vector_t *weights=0=NULL;
13891
char* shell_arg_res=0;
13896
int shell_index=-1;
13897
struct option shell_options[]= { { "graph",required_argument,0,0 },
13898
{ "res",required_argument,0,1 },
13899
{ "res-out",required_argument,0,2 },
13900
{ "use_seed",required_argument,0,3 },
13901
{ "weights",required_argument,0,4 },
13902
{ "help",no_argument,0,5 },
13906
/* 0 - not seen, 1 - seen as argument, 2 - seen as default */
13907
memset(shell_seen, 0, 5*sizeof(int));
13911
/* Parse arguments and read input */
13912
while (getopt_long(argc, argv, "", shell_options, &shell_index) != -1) {
13914
if (shell_index==-1) {
13918
if (shell_seen[shell_index]==1) {
13919
fprintf(stderr, "Error, `--%s' argument given twice.\n",
13920
shell_options[shell_index].name);
13923
shell_seen[shell_index]=1;
13925
switch (shell_index) {
13926
case 0: /* graph */
13927
shell_read_graph(&graph, optarg);
13930
shell_read_matrix(&res, optarg);
13932
case 2: /* res-out */
13933
shell_arg_res=strdup(optarg);
13934
igraph_matrix_init(&res, 0, 0);
13936
case 3: /* use_seed */
13937
shell_read_boolean(&use_seed, optarg);
13939
case 4: /* weights */
13940
weights=&v_weights; shell_read_vector(weights, optarg);
13943
shell_igraph_layout_drl_usage(argv);
13952
/* Check that we have all arguments */
13953
for (shell_index=0; shell_index<5; shell_index++) {
13954
if (!shell_seen[shell_index]) {
13955
fprintf(stderr, "Error, argument missing: `--%s'.\n",
13956
shell_options[shell_index].name);
13961
/* Do the operation */
13962
shell_result=igraph_layout_drl(&graph, &res, use_seed, options, weights, fixed);
13964
/* Write the result */
13965
igraph_destroy(&graph);
13966
igraph_matrix_destroy(&res);
13967
shell_write_matrix(&res, shell_arg_res);
13968
igraph_matrix_destroy(&res);
13969
if (weights) { igraph_vector_destroy(weights); }
13974
/*-------------------------------------------/
13975
/ igraph_layout_drl_3d /
13976
/-------------------------------------------*/
13977
void shell_igraph_layout_drl_3d_usage(char **argv) {
13978
printf("%s --graph=<graph> --res=<res> --res-out=<res-out> --use_seed=<use_seed> --weights=<weights>\n", basename(argv[0]));
13982
int shell_igraph_layout_drl_3d(int argc, char **argv) {
13985
igraph_matrix_t res;
13986
igraph_bool_t use_seed=0;
13988
igraph_vector_t v_weights; igraph_vector_t *weights=0=NULL;
13990
char* shell_arg_res=0;
13995
int shell_index=-1;
13996
struct option shell_options[]= { { "graph",required_argument,0,0 },
13997
{ "res",required_argument,0,1 },
13998
{ "res-out",required_argument,0,2 },
13999
{ "use_seed",required_argument,0,3 },
14000
{ "weights",required_argument,0,4 },
14001
{ "help",no_argument,0,5 },
14005
/* 0 - not seen, 1 - seen as argument, 2 - seen as default */
14006
memset(shell_seen, 0, 5*sizeof(int));
14010
/* Parse arguments and read input */
14011
while (getopt_long(argc, argv, "", shell_options, &shell_index) != -1) {
14013
if (shell_index==-1) {
14017
if (shell_seen[shell_index]==1) {
14018
fprintf(stderr, "Error, `--%s' argument given twice.\n",
14019
shell_options[shell_index].name);
14022
shell_seen[shell_index]=1;
14024
switch (shell_index) {
14025
case 0: /* graph */
14026
shell_read_graph(&graph, optarg);
14029
shell_read_matrix(&res, optarg);
14031
case 2: /* res-out */
14032
shell_arg_res=strdup(optarg);
14033
igraph_matrix_init(&res, 0, 0);
14035
case 3: /* use_seed */
14036
shell_read_boolean(&use_seed, optarg);
14038
case 4: /* weights */
14039
weights=&v_weights; shell_read_vector(weights, optarg);
14042
shell_igraph_layout_drl_3d_usage(argv);
14051
/* Check that we have all arguments */
14052
for (shell_index=0; shell_index<5; shell_index++) {
14053
if (!shell_seen[shell_index]) {
14054
fprintf(stderr, "Error, argument missing: `--%s'.\n",
14055
shell_options[shell_index].name);
14060
/* Do the operation */
14061
shell_result=igraph_layout_drl_3d(&graph, &res, use_seed, options, weights, fixed);
14063
/* Write the result */
14064
igraph_destroy(&graph);
14065
igraph_matrix_destroy(&res);
14066
shell_write_matrix(&res, shell_arg_res);
14067
igraph_matrix_destroy(&res);
14068
if (weights) { igraph_vector_destroy(weights); }
14073
/*-------------------------------------------/
14074
/ igraph_layout_merge_dla /
14075
/-------------------------------------------*/
14076
void shell_igraph_layout_merge_dla_usage(char **argv) {
14077
printf("%s --graphs=<graphs> --coords=<coords> --res=<res>\n", basename(argv[0]));
14081
int shell_igraph_layout_merge_dla(int argc, char **argv) {
14083
igraph_vector_ptr_t graphs;
14084
igraph_vector_ptr_t coords;
14085
igraph_matrix_t res;
14086
char* shell_arg_res=0;
14091
int shell_index=-1;
14092
struct option shell_options[]= { { "graphs",required_argument,0,0 },
14093
{ "coords",required_argument,0,1 },
14094
{ "res",required_argument,0,2 },
14095
{ "help",no_argument,0,3 },
14099
/* 0 - not seen, 1 - seen as argument, 2 - seen as default */
14100
memset(shell_seen, 0, 3*sizeof(int));
14103
/* Parse arguments and read input */
14104
while (getopt_long(argc, argv, "", shell_options, &shell_index) != -1) {
14106
if (shell_index==-1) {
14110
if (shell_seen[shell_index]==1) {
14111
fprintf(stderr, "Error, `--%s' argument given twice.\n",
14112
shell_options[shell_index].name);
14115
shell_seen[shell_index]=1;
14117
switch (shell_index) {
14118
case 0: /* graphs */
14119
shell_read_graphlist(&graphs, optarg);
14121
case 1: /* coords */
14122
shell_read_matrixlist(&coords, optarg);
14125
shell_arg_res=strdup(optarg);
14126
igraph_matrix_init(&res, 0, 0);
14129
shell_igraph_layout_merge_dla_usage(argv);
14138
/* Check that we have all arguments */
14139
for (shell_index=0; shell_index<3; shell_index++) {
14140
if (!shell_seen[shell_index]) {
14141
fprintf(stderr, "Error, argument missing: `--%s'.\n",
14142
shell_options[shell_index].name);
14147
/* Do the operation */
14148
shell_result=igraph_layout_merge_dla(&graphs, &coords, &res);
14150
/* Write the result */
14151
shell_free_graphlist(&graphs);
14152
igraph_vector_ptr_destroy(&graphs);
14153
shell_free_matrixlist(&coords);
14154
igraph_vector_ptr_destroy(&coords);
14155
shell_write_matrix(&res, shell_arg_res);
14156
igraph_matrix_destroy(&res);
14161
/*-------------------------------------------/
14162
/ igraph_cocitation /
14163
/-------------------------------------------*/
14164
void shell_igraph_cocitation_usage(char **argv) {
14165
printf("%s --graph=<graph> --res=<res> --vids=<vids>\n", basename(argv[0]));
14169
int shell_igraph_cocitation(int argc, char **argv) {
14172
igraph_matrix_t res;
14173
igraph_vector_t v_vids; igraph_vs_t vids=igraph_vss_all();
14174
char* shell_arg_res=0;
14179
int shell_index=-1;
14180
struct option shell_options[]= { { "graph",required_argument,0,0 },
14181
{ "res",required_argument,0,1 },
14182
{ "vids",required_argument,0,2 },
14183
{ "help",no_argument,0,3 },
14187
/* 0 - not seen, 1 - seen as argument, 2 - seen as default */
14188
memset(shell_seen, 0, 3*sizeof(int));
14191
/* Parse arguments and read input */
14192
while (getopt_long(argc, argv, "", shell_options, &shell_index) != -1) {
14194
if (shell_index==-1) {
14198
if (shell_seen[shell_index]==1) {
14199
fprintf(stderr, "Error, `--%s' argument given twice.\n",
14200
shell_options[shell_index].name);
14203
shell_seen[shell_index]=1;
14205
switch (shell_index) {
14206
case 0: /* graph */
14207
shell_read_graph(&graph, optarg);
14210
shell_arg_res=strdup(optarg);
14211
igraph_matrix_init(&res, 0, 0);
14214
shell_read_vector(&v_vids, optarg); igraph_vs_vector(&vids, &v_vids);
14217
shell_igraph_cocitation_usage(argv);
14226
/* Check that we have all arguments */
14227
for (shell_index=0; shell_index<3; shell_index++) {
14228
if (!shell_seen[shell_index]) {
14229
fprintf(stderr, "Error, argument missing: `--%s'.\n",
14230
shell_options[shell_index].name);
14235
/* Do the operation */
14236
shell_result=igraph_cocitation(&graph, &res, vids);
14238
/* Write the result */
14239
igraph_destroy(&graph);
14240
shell_write_matrix(&res, shell_arg_res);
14241
igraph_matrix_destroy(&res);
14242
if (!igraph_vs_is_all(&vids)) { igraph_vector_destroy(&v_vids); }
14247
/*-------------------------------------------/
14248
/ igraph_bibcoupling /
14249
/-------------------------------------------*/
14250
void shell_igraph_bibcoupling_usage(char **argv) {
14251
printf("%s --graph=<graph> --res=<res> --vids=<vids>\n", basename(argv[0]));
14255
int shell_igraph_bibcoupling(int argc, char **argv) {
14258
igraph_matrix_t res;
14259
igraph_vector_t v_vids; igraph_vs_t vids=igraph_vss_all();
14260
char* shell_arg_res=0;
14265
int shell_index=-1;
14266
struct option shell_options[]= { { "graph",required_argument,0,0 },
14267
{ "res",required_argument,0,1 },
14268
{ "vids",required_argument,0,2 },
14269
{ "help",no_argument,0,3 },
14273
/* 0 - not seen, 1 - seen as argument, 2 - seen as default */
14274
memset(shell_seen, 0, 3*sizeof(int));
14277
/* Parse arguments and read input */
14278
while (getopt_long(argc, argv, "", shell_options, &shell_index) != -1) {
14280
if (shell_index==-1) {
14284
if (shell_seen[shell_index]==1) {
14285
fprintf(stderr, "Error, `--%s' argument given twice.\n",
14286
shell_options[shell_index].name);
14289
shell_seen[shell_index]=1;
14291
switch (shell_index) {
14292
case 0: /* graph */
14293
shell_read_graph(&graph, optarg);
14296
shell_arg_res=strdup(optarg);
14297
igraph_matrix_init(&res, 0, 0);
14300
shell_read_vector(&v_vids, optarg); igraph_vs_vector(&vids, &v_vids);
14303
shell_igraph_bibcoupling_usage(argv);
14312
/* Check that we have all arguments */
14313
for (shell_index=0; shell_index<3; shell_index++) {
14314
if (!shell_seen[shell_index]) {
14315
fprintf(stderr, "Error, argument missing: `--%s'.\n",
14316
shell_options[shell_index].name);
14321
/* Do the operation */
14322
shell_result=igraph_bibcoupling(&graph, &res, vids);
14324
/* Write the result */
14325
igraph_destroy(&graph);
14326
shell_write_matrix(&res, shell_arg_res);
14327
igraph_matrix_destroy(&res);
14328
if (!igraph_vs_is_all(&vids)) { igraph_vector_destroy(&v_vids); }
14333
/*-------------------------------------------/
14334
/ igraph_similarity_jaccard /
14335
/-------------------------------------------*/
14336
void shell_igraph_similarity_jaccard_usage(char **argv) {
14337
printf("%s --graph=<graph> --res=<res> --vids=<vids> --mode=<mode> --loops=<loops>\n", basename(argv[0]));
14341
int shell_igraph_similarity_jaccard(int argc, char **argv) {
14344
igraph_matrix_t res;
14345
igraph_vector_t v_vids; igraph_vs_t vids=igraph_vss_all();
14346
igraph_neimode_t mode=IGRAPH_ALL;
14347
igraph_bool_t loops=0;
14348
char* shell_arg_res=0;
14353
int shell_index=-1;
14354
struct option shell_options[]= { { "graph",required_argument,0,0 },
14355
{ "res",required_argument,0,1 },
14356
{ "vids",required_argument,0,2 },
14357
{ "mode",required_argument,0,3 },
14358
{ "loops",required_argument,0,4 },
14359
{ "help",no_argument,0,5 },
14363
/* 0 - not seen, 1 - seen as argument, 2 - seen as default */
14364
memset(shell_seen, 0, 5*sizeof(int));
14369
/* Parse arguments and read input */
14370
while (getopt_long(argc, argv, "", shell_options, &shell_index) != -1) {
14372
if (shell_index==-1) {
14376
if (shell_seen[shell_index]==1) {
14377
fprintf(stderr, "Error, `--%s' argument given twice.\n",
14378
shell_options[shell_index].name);
14381
shell_seen[shell_index]=1;
14383
switch (shell_index) {
14384
case 0: /* graph */
14385
shell_read_graph(&graph, optarg);
14388
shell_arg_res=strdup(optarg);
14389
igraph_matrix_init(&res, 0, 0);
14392
shell_read_vector(&v_vids, optarg); igraph_vs_vector(&vids, &v_vids);
14395
shell_read_enum(&mode, optarg, "out", 1, "in", 2, "all", 3, "total", 3, 0);
14397
case 4: /* loops */
14398
shell_read_boolean(&loops, optarg);
14401
shell_igraph_similarity_jaccard_usage(argv);
14410
/* Check that we have all arguments */
14411
for (shell_index=0; shell_index<5; shell_index++) {
14412
if (!shell_seen[shell_index]) {
14413
fprintf(stderr, "Error, argument missing: `--%s'.\n",
14414
shell_options[shell_index].name);
14419
/* Do the operation */
14420
shell_result=igraph_similarity_jaccard(&graph, &res, vids, mode, loops);
14422
/* Write the result */
14423
igraph_destroy(&graph);
14424
shell_write_matrix(&res, shell_arg_res);
14425
igraph_matrix_destroy(&res);
14426
if (!igraph_vs_is_all(&vids)) { igraph_vector_destroy(&v_vids); }
14431
/*-------------------------------------------/
14432
/ igraph_similarity_dice /
14433
/-------------------------------------------*/
14434
void shell_igraph_similarity_dice_usage(char **argv) {
14435
printf("%s --graph=<graph> --res=<res> --vids=<vids> --mode=<mode> --loops=<loops>\n", basename(argv[0]));
14439
int shell_igraph_similarity_dice(int argc, char **argv) {
14442
igraph_matrix_t res;
14443
igraph_vector_t v_vids; igraph_vs_t vids=igraph_vss_all();
14444
igraph_neimode_t mode=IGRAPH_ALL;
14445
igraph_bool_t loops=0;
14446
char* shell_arg_res=0;
14451
int shell_index=-1;
14452
struct option shell_options[]= { { "graph",required_argument,0,0 },
14453
{ "res",required_argument,0,1 },
14454
{ "vids",required_argument,0,2 },
14455
{ "mode",required_argument,0,3 },
14456
{ "loops",required_argument,0,4 },
14457
{ "help",no_argument,0,5 },
14461
/* 0 - not seen, 1 - seen as argument, 2 - seen as default */
14462
memset(shell_seen, 0, 5*sizeof(int));
14467
/* Parse arguments and read input */
14468
while (getopt_long(argc, argv, "", shell_options, &shell_index) != -1) {
14470
if (shell_index==-1) {
14474
if (shell_seen[shell_index]==1) {
14475
fprintf(stderr, "Error, `--%s' argument given twice.\n",
14476
shell_options[shell_index].name);
14479
shell_seen[shell_index]=1;
14481
switch (shell_index) {
14482
case 0: /* graph */
14483
shell_read_graph(&graph, optarg);
14486
shell_arg_res=strdup(optarg);
14487
igraph_matrix_init(&res, 0, 0);
14490
shell_read_vector(&v_vids, optarg); igraph_vs_vector(&vids, &v_vids);
14493
shell_read_enum(&mode, optarg, "out", 1, "in", 2, "all", 3, "total", 3, 0);
14495
case 4: /* loops */
14496
shell_read_boolean(&loops, optarg);
14499
shell_igraph_similarity_dice_usage(argv);
14508
/* Check that we have all arguments */
14509
for (shell_index=0; shell_index<5; shell_index++) {
14510
if (!shell_seen[shell_index]) {
14511
fprintf(stderr, "Error, argument missing: `--%s'.\n",
14512
shell_options[shell_index].name);
14517
/* Do the operation */
14518
shell_result=igraph_similarity_dice(&graph, &res, vids, mode, loops);
14520
/* Write the result */
14521
igraph_destroy(&graph);
14522
shell_write_matrix(&res, shell_arg_res);
14523
igraph_matrix_destroy(&res);
14524
if (!igraph_vs_is_all(&vids)) { igraph_vector_destroy(&v_vids); }
14529
/*-------------------------------------------/
14530
/ igraph_similarity_inverse_log_weighted /
14531
/-------------------------------------------*/
14532
void shell_igraph_similarity_inverse_log_weighted_usage(char **argv) {
14533
printf("%s --graph=<graph> --res=<res> --vids=<vids> --mode=<mode>\n", basename(argv[0]));
14537
int shell_igraph_similarity_inverse_log_weighted(int argc, char **argv) {
14540
igraph_matrix_t res;
14541
igraph_vector_t v_vids; igraph_vs_t vids=igraph_vss_all();
14542
igraph_neimode_t mode=IGRAPH_ALL;
14543
char* shell_arg_res=0;
14548
int shell_index=-1;
14549
struct option shell_options[]= { { "graph",required_argument,0,0 },
14550
{ "res",required_argument,0,1 },
14551
{ "vids",required_argument,0,2 },
14552
{ "mode",required_argument,0,3 },
14553
{ "help",no_argument,0,4 },
14557
/* 0 - not seen, 1 - seen as argument, 2 - seen as default */
14558
memset(shell_seen, 0, 4*sizeof(int));
14562
/* Parse arguments and read input */
14563
while (getopt_long(argc, argv, "", shell_options, &shell_index) != -1) {
14565
if (shell_index==-1) {
14569
if (shell_seen[shell_index]==1) {
14570
fprintf(stderr, "Error, `--%s' argument given twice.\n",
14571
shell_options[shell_index].name);
14574
shell_seen[shell_index]=1;
14576
switch (shell_index) {
14577
case 0: /* graph */
14578
shell_read_graph(&graph, optarg);
14581
shell_arg_res=strdup(optarg);
14582
igraph_matrix_init(&res, 0, 0);
14585
shell_read_vector(&v_vids, optarg); igraph_vs_vector(&vids, &v_vids);
14588
shell_read_enum(&mode, optarg, "out", 1, "in", 2, "all", 3, "total", 3, 0);
14591
shell_igraph_similarity_inverse_log_weighted_usage(argv);
14600
/* Check that we have all arguments */
14601
for (shell_index=0; shell_index<4; shell_index++) {
14602
if (!shell_seen[shell_index]) {
14603
fprintf(stderr, "Error, argument missing: `--%s'.\n",
14604
shell_options[shell_index].name);
14609
/* Do the operation */
14610
shell_result=igraph_similarity_inverse_log_weighted(&graph, &res, vids, mode);
14612
/* Write the result */
14613
igraph_destroy(&graph);
14614
shell_write_matrix(&res, shell_arg_res);
14615
igraph_matrix_destroy(&res);
14616
if (!igraph_vs_is_all(&vids)) { igraph_vector_destroy(&v_vids); }
14621
/*-------------------------------------------/
14622
/ igraph_community_spinglass /
14623
/-------------------------------------------*/
14624
void shell_igraph_community_spinglass_usage(char **argv) {
14625
printf("%s --graph=<graph> --weights=<weights> --modularity=<modularity> --temperature=<temperature> --membership=<membership> --csize=<csize> --spins=<spins> --parupdate=<parupdate> --starttemp=<starttemp> --stoptemp=<stoptemp> --coolfact=<coolfact> --update_rule=<update_rule> --gamma=<gamma>\n", basename(argv[0]));
14629
int shell_igraph_community_spinglass(int argc, char **argv) {
14632
igraph_vector_t v_weights; igraph_vector_t *weights=0;
14633
igraph_real_t modularity;
14634
igraph_real_t temperature;
14635
igraph_vector_t membership;
14636
igraph_vector_t csize;
14637
igraph_integer_t spins=25;
14638
igraph_bool_t parupdate=0;
14639
igraph_real_t starttemp=1;
14640
igraph_real_t stoptemp=0.01;
14641
igraph_real_t coolfact=0.99;
14642
igraph_spincomm_update_t update_rule=IGRAPH_SPINCOMM_UPDATE_CONFIG;
14643
igraph_real_t gamma=1.0;
14644
char* shell_arg_modularity=0;
14645
char* shell_arg_temperature=0;
14646
char* shell_arg_membership=0;
14647
char* shell_arg_csize=0;
14651
int shell_seen[13];
14652
int shell_index=-1;
14653
struct option shell_options[]= { { "graph",required_argument,0,0 },
14654
{ "weights",required_argument,0,1 },
14655
{ "modularity",required_argument,0,2 },
14656
{ "temperature",required_argument,0,3 },
14657
{ "membership",required_argument,0,4 },
14658
{ "csize",required_argument,0,5 },
14659
{ "spins",required_argument,0,6 },
14660
{ "parupdate",required_argument,0,7 },
14661
{ "starttemp",required_argument,0,8 },
14662
{ "stoptemp",required_argument,0,9 },
14663
{ "coolfact",required_argument,0,10 },
14664
{ "update_rule",required_argument,0,11 },
14665
{ "gamma",required_argument,0,12 },
14666
{ "help",no_argument,0,13 },
14670
/* 0 - not seen, 1 - seen as argument, 2 - seen as default */
14671
memset(shell_seen, 0, 13*sizeof(int));
14680
/* Parse arguments and read input */
14681
while (getopt_long(argc, argv, "", shell_options, &shell_index) != -1) {
14683
if (shell_index==-1) {
14687
if (shell_seen[shell_index]==1) {
14688
fprintf(stderr, "Error, `--%s' argument given twice.\n",
14689
shell_options[shell_index].name);
14692
shell_seen[shell_index]=1;
14694
switch (shell_index) {
14695
case 0: /* graph */
14696
shell_read_graph(&graph, optarg);
14698
case 1: /* weights */
14699
weights=&v_weights; shell_read_vector(weights, optarg);
14701
case 2: /* modularity */
14702
shell_arg_modularity=strdup(optarg);
14704
case 3: /* temperature */
14705
shell_arg_temperature=strdup(optarg);
14707
case 4: /* membership */
14708
shell_arg_membership=strdup(optarg);
14709
igraph_vector_init(&membership, 0);
14711
case 5: /* csize */
14712
shell_arg_csize=strdup(optarg);
14713
igraph_vector_init(&csize, 0);
14715
case 6: /* spins */
14716
shell_read_integer(&spins, optarg);
14718
case 7: /* parupdate */
14719
shell_read_boolean(&parupdate, optarg);
14721
case 8: /* starttemp */
14722
shell_read_real(&starttemp, optarg);
14724
case 9: /* stoptemp */
14725
shell_read_real(&stoptemp, optarg);
14727
case 10: /* coolfact */
14728
shell_read_real(&coolfact, optarg);
14730
case 11: /* update_rule */
14731
shell_read_enum(&update_rule, optarg, "simple", 0, "config", 1, 0);
14733
case 12: /* gamma */
14734
shell_read_real(&gamma, optarg);
14737
shell_igraph_community_spinglass_usage(argv);
14746
/* Check that we have all arguments */
14747
for (shell_index=0; shell_index<13; shell_index++) {
14748
if (!shell_seen[shell_index]) {
14749
fprintf(stderr, "Error, argument missing: `--%s'.\n",
14750
shell_options[shell_index].name);
14755
/* Do the operation */
14756
shell_result=igraph_community_spinglass(&graph, weights, &modularity, &temperature, &membership, &csize, spins, parupdate, starttemp, stoptemp, coolfact, update_rule, gamma);
14758
/* Write the result */
14759
igraph_destroy(&graph);
14760
if (weights) { igraph_vector_destroy(weights); }
14761
shell_write_real(modularity, shell_arg_modularity);
14762
shell_write_real(temperature, shell_arg_temperature);
14763
shell_write_vector(&membership, shell_arg_membership);
14764
igraph_vector_destroy(&membership);
14765
shell_write_vector(&csize, shell_arg_csize);
14766
igraph_vector_destroy(&csize);
14771
/*-------------------------------------------/
14772
/ igraph_community_spinglass_single /
14773
/-------------------------------------------*/
14774
void shell_igraph_community_spinglass_single_usage(char **argv) {
14775
printf("%s --graph=<graph> --weights=<weights> --vertex=<vertex> --community=<community> --cohesion=<cohesion> --adhesion=<adhesion> --inner_links=<inner_links> --outer_links=<outer_links> --spins=<spins> --update_rule=<update_rule> --gamma=<gamma>\n", basename(argv[0]));
14779
int shell_igraph_community_spinglass_single(int argc, char **argv) {
14782
igraph_vector_t v_weights; igraph_vector_t *weights=0;
14783
igraph_integer_t vertex;
14784
igraph_vector_t community;
14785
igraph_real_t cohesion;
14786
igraph_real_t adhesion;
14787
igraph_integer_t inner_links;
14788
igraph_integer_t outer_links;
14789
igraph_integer_t spins=25;
14790
igraph_spincomm_update_t update_rule=IGRAPH_SPINCOMM_UPDATE_CONFIG;
14791
igraph_real_t gamma=1.0;
14792
char* shell_arg_community=0;
14793
char* shell_arg_cohesion=0;
14794
char* shell_arg_adhesion=0;
14795
char* shell_arg_inner_links=0;
14796
char* shell_arg_outer_links=0;
14800
int shell_seen[11];
14801
int shell_index=-1;
14802
struct option shell_options[]= { { "graph",required_argument,0,0 },
14803
{ "weights",required_argument,0,1 },
14804
{ "vertex",required_argument,0,2 },
14805
{ "community",required_argument,0,3 },
14806
{ "cohesion",required_argument,0,4 },
14807
{ "adhesion",required_argument,0,5 },
14808
{ "inner_links",required_argument,0,6 },
14809
{ "outer_links",required_argument,0,7 },
14810
{ "spins",required_argument,0,8 },
14811
{ "update_rule",required_argument,0,9 },
14812
{ "gamma",required_argument,0,10 },
14813
{ "help",no_argument,0,11 },
14817
/* 0 - not seen, 1 - seen as argument, 2 - seen as default */
14818
memset(shell_seen, 0, 11*sizeof(int));
14823
/* Parse arguments and read input */
14824
while (getopt_long(argc, argv, "", shell_options, &shell_index) != -1) {
14826
if (shell_index==-1) {
14830
if (shell_seen[shell_index]==1) {
14831
fprintf(stderr, "Error, `--%s' argument given twice.\n",
14832
shell_options[shell_index].name);
14835
shell_seen[shell_index]=1;
14837
switch (shell_index) {
14838
case 0: /* graph */
14839
shell_read_graph(&graph, optarg);
14841
case 1: /* weights */
14842
weights=&v_weights; shell_read_vector(weights, optarg);
14844
case 2: /* vertex */
14845
shell_read_integer(&vertex, optarg);
14847
case 3: /* community */
14848
shell_arg_community=strdup(optarg);
14849
igraph_vector_init(&community, 0);
14851
case 4: /* cohesion */
14852
shell_arg_cohesion=strdup(optarg);
14854
case 5: /* adhesion */
14855
shell_arg_adhesion=strdup(optarg);
14857
case 6: /* inner_links */
14858
shell_arg_inner_links=strdup(optarg);
14860
case 7: /* outer_links */
14861
shell_arg_outer_links=strdup(optarg);
14863
case 8: /* spins */
14864
shell_read_integer(&spins, optarg);
14866
case 9: /* update_rule */
14867
shell_read_enum(&update_rule, optarg, "simple", 0, "config", 1, 0);
14869
case 10: /* gamma */
14870
shell_read_real(&gamma, optarg);
14873
shell_igraph_community_spinglass_single_usage(argv);
14882
/* Check that we have all arguments */
14883
for (shell_index=0; shell_index<11; shell_index++) {
14884
if (!shell_seen[shell_index]) {
14885
fprintf(stderr, "Error, argument missing: `--%s'.\n",
14886
shell_options[shell_index].name);
14891
/* Do the operation */
14892
shell_result=igraph_community_spinglass_single(&graph, weights, vertex, &community, &cohesion, &adhesion, &inner_links, &outer_links, spins, update_rule, gamma);
14894
/* Write the result */
14895
igraph_destroy(&graph);
14896
if (weights) { igraph_vector_destroy(weights); }
14897
shell_write_vector(&community, shell_arg_community);
14898
igraph_vector_destroy(&community);
14899
shell_write_real(cohesion, shell_arg_cohesion);
14900
shell_write_real(adhesion, shell_arg_adhesion);
14901
shell_write_integer(inner_links, shell_arg_inner_links);
14902
shell_write_integer(outer_links, shell_arg_outer_links);
14907
/*-------------------------------------------/
14908
/ igraph_community_walktrap /
14909
/-------------------------------------------*/
14910
void shell_igraph_community_walktrap_usage(char **argv) {
14911
printf("%s --graph=<graph> --weights=<weights> --steps=<steps> --merges=<merges> --modularity=<modularity>\n", basename(argv[0]));
14915
int shell_igraph_community_walktrap(int argc, char **argv) {
14918
igraph_vector_t weights;
14920
igraph_matrix_t merges;
14921
igraph_vector_t modularity;
14922
char* shell_arg_merges=0;
14923
char* shell_arg_modularity=0;
14928
int shell_index=-1;
14929
struct option shell_options[]= { { "graph",required_argument,0,0 },
14930
{ "weights",required_argument,0,1 },
14931
{ "steps",required_argument,0,2 },
14932
{ "merges",required_argument,0,3 },
14933
{ "modularity",required_argument,0,4 },
14934
{ "help",no_argument,0,5 },
14938
/* 0 - not seen, 1 - seen as argument, 2 - seen as default */
14939
memset(shell_seen, 0, 5*sizeof(int));
14942
/* Parse arguments and read input */
14943
while (getopt_long(argc, argv, "", shell_options, &shell_index) != -1) {
14945
if (shell_index==-1) {
14949
if (shell_seen[shell_index]==1) {
14950
fprintf(stderr, "Error, `--%s' argument given twice.\n",
14951
shell_options[shell_index].name);
14954
shell_seen[shell_index]=1;
14956
switch (shell_index) {
14957
case 0: /* graph */
14958
shell_read_graph(&graph, optarg);
14960
case 1: /* weights */
14961
shell_read_vector(&weights, optarg);
14963
case 2: /* steps */
14964
shell_read_int(&steps, optarg);
14966
case 3: /* merges */
14967
shell_arg_merges=strdup(optarg);
14968
igraph_matrix_init(&merges, 0, 0);
14970
case 4: /* modularity */
14971
shell_arg_modularity=strdup(optarg);
14972
igraph_vector_init(&modularity, 0);
14975
shell_igraph_community_walktrap_usage(argv);
14984
/* Check that we have all arguments */
14985
for (shell_index=0; shell_index<5; shell_index++) {
14986
if (!shell_seen[shell_index]) {
14987
fprintf(stderr, "Error, argument missing: `--%s'.\n",
14988
shell_options[shell_index].name);
14993
/* Do the operation */
14994
shell_result=igraph_community_walktrap(&graph, &weights, steps, &merges, &modularity);
14996
/* Write the result */
14997
igraph_destroy(&graph);
14998
igraph_vector_destroy(&weights);
14999
shell_write_matrix(&merges, shell_arg_merges);
15000
igraph_matrix_destroy(&merges);
15001
shell_write_vector(&modularity, shell_arg_modularity);
15002
igraph_vector_destroy(&modularity);
15007
/*-------------------------------------------/
15008
/ igraph_community_edge_betweenness /
15009
/-------------------------------------------*/
15010
void shell_igraph_community_edge_betweenness_usage(char **argv) {
15011
printf("%s --graph=<graph> --result=<result> --edge_betweenness=<edge_betweenness> --merges=<merges> --bridges=<bridges> --directed=<directed>\n", basename(argv[0]));
15015
int shell_igraph_community_edge_betweenness(int argc, char **argv) {
15018
igraph_vector_t result;
15019
igraph_vector_t edge_betweenness;
15020
igraph_matrix_t merges;
15021
igraph_vector_t bridges;
15022
igraph_bool_t directed=1;
15023
char* shell_arg_result=0;
15024
char* shell_arg_edge_betweenness=0;
15025
char* shell_arg_merges=0;
15026
char* shell_arg_bridges=0;
15031
int shell_index=-1;
15032
struct option shell_options[]= { { "graph",required_argument,0,0 },
15033
{ "result",required_argument,0,1 },
15034
{ "edge_betweenness",required_argument,0,2 },
15035
{ "merges",required_argument,0,3 },
15036
{ "bridges",required_argument,0,4 },
15037
{ "directed",required_argument,0,5 },
15038
{ "help",no_argument,0,6 },
15042
/* 0 - not seen, 1 - seen as argument, 2 - seen as default */
15043
memset(shell_seen, 0, 6*sizeof(int));
15046
/* Parse arguments and read input */
15047
while (getopt_long(argc, argv, "", shell_options, &shell_index) != -1) {
15049
if (shell_index==-1) {
15053
if (shell_seen[shell_index]==1) {
15054
fprintf(stderr, "Error, `--%s' argument given twice.\n",
15055
shell_options[shell_index].name);
15058
shell_seen[shell_index]=1;
15060
switch (shell_index) {
15061
case 0: /* graph */
15062
shell_read_graph(&graph, optarg);
15064
case 1: /* result */
15065
shell_arg_result=strdup(optarg);
15066
igraph_vector_init(&result, 0);
15068
case 2: /* edge_betweenness */
15069
shell_arg_edge_betweenness=strdup(optarg);
15070
igraph_vector_init(&edge_betweenness, 0);
15072
case 3: /* merges */
15073
shell_arg_merges=strdup(optarg);
15074
igraph_matrix_init(&merges, 0, 0);
15076
case 4: /* bridges */
15077
shell_arg_bridges=strdup(optarg);
15078
igraph_vector_init(&bridges, 0);
15080
case 5: /* directed */
15081
shell_read_boolean(&directed, optarg);
15084
shell_igraph_community_edge_betweenness_usage(argv);
15093
/* Check that we have all arguments */
15094
for (shell_index=0; shell_index<6; shell_index++) {
15095
if (!shell_seen[shell_index]) {
15096
fprintf(stderr, "Error, argument missing: `--%s'.\n",
15097
shell_options[shell_index].name);
15102
/* Do the operation */
15103
shell_result=igraph_community_edge_betweenness(&graph, &result, &edge_betweenness, &merges, &bridges, directed);
15105
/* Write the result */
15106
igraph_destroy(&graph);
15107
shell_write_vector(&result, shell_arg_result);
15108
igraph_vector_destroy(&result);
15109
shell_write_vector(&edge_betweenness, shell_arg_edge_betweenness);
15110
igraph_vector_destroy(&edge_betweenness);
15111
shell_write_matrix(&merges, shell_arg_merges);
15112
igraph_matrix_destroy(&merges);
15113
shell_write_vector(&bridges, shell_arg_bridges);
15114
igraph_vector_destroy(&bridges);
15119
/*-------------------------------------------/
15120
/ igraph_community_eb_get_merges /
15121
/-------------------------------------------*/
15122
void shell_igraph_community_eb_get_merges_usage(char **argv) {
15123
printf("%s --graph=<graph> --edges=<edges> --merges=<merges> --bridges=<bridges>\n", basename(argv[0]));
15127
int shell_igraph_community_eb_get_merges(int argc, char **argv) {
15130
igraph_vector_t edges;
15131
igraph_matrix_t merges;
15132
igraph_vector_t bridges;
15133
char* shell_arg_merges=0;
15134
char* shell_arg_bridges=0;
15139
int shell_index=-1;
15140
struct option shell_options[]= { { "graph",required_argument,0,0 },
15141
{ "edges",required_argument,0,1 },
15142
{ "merges",required_argument,0,2 },
15143
{ "bridges",required_argument,0,3 },
15144
{ "help",no_argument,0,4 },
15148
/* 0 - not seen, 1 - seen as argument, 2 - seen as default */
15149
memset(shell_seen, 0, 4*sizeof(int));
15152
/* Parse arguments and read input */
15153
while (getopt_long(argc, argv, "", shell_options, &shell_index) != -1) {
15155
if (shell_index==-1) {
15159
if (shell_seen[shell_index]==1) {
15160
fprintf(stderr, "Error, `--%s' argument given twice.\n",
15161
shell_options[shell_index].name);
15164
shell_seen[shell_index]=1;
15166
switch (shell_index) {
15167
case 0: /* graph */
15168
shell_read_graph(&graph, optarg);
15170
case 1: /* edges */
15171
shell_read_vector(&edges, optarg);
15173
case 2: /* merges */
15174
shell_arg_merges=strdup(optarg);
15175
igraph_matrix_init(&merges, 0, 0);
15177
case 3: /* bridges */
15178
shell_arg_bridges=strdup(optarg);
15179
igraph_vector_init(&bridges, 0);
15182
shell_igraph_community_eb_get_merges_usage(argv);
15191
/* Check that we have all arguments */
15192
for (shell_index=0; shell_index<4; shell_index++) {
15193
if (!shell_seen[shell_index]) {
15194
fprintf(stderr, "Error, argument missing: `--%s'.\n",
15195
shell_options[shell_index].name);
15200
/* Do the operation */
15201
shell_result=igraph_community_eb_get_merges(&graph, &edges, &merges, &bridges);
15203
/* Write the result */
15204
igraph_destroy(&graph);
15205
igraph_vector_destroy(&edges);
15206
shell_write_matrix(&merges, shell_arg_merges);
15207
igraph_matrix_destroy(&merges);
15208
shell_write_vector(&bridges, shell_arg_bridges);
15209
igraph_vector_destroy(&bridges);
15214
/*-------------------------------------------/
15215
/ igraph_community_fastgreedy /
15216
/-------------------------------------------*/
15217
void shell_igraph_community_fastgreedy_usage(char **argv) {
15218
printf("%s --graph=<graph> --weights=<weights> --merges=<merges> --modularity=<modularity>\n", basename(argv[0]));
15222
int shell_igraph_community_fastgreedy(int argc, char **argv) {
15225
igraph_vector_t v_weights; igraph_vector_t *weights=0;
15226
igraph_matrix_t merges;
15227
igraph_vector_t modularity;
15228
char* shell_arg_merges=0;
15229
char* shell_arg_modularity=0;
15234
int shell_index=-1;
15235
struct option shell_options[]= { { "graph",required_argument,0,0 },
15236
{ "weights",required_argument,0,1 },
15237
{ "merges",required_argument,0,2 },
15238
{ "modularity",required_argument,0,3 },
15239
{ "help",no_argument,0,4 },
15243
/* 0 - not seen, 1 - seen as argument, 2 - seen as default */
15244
memset(shell_seen, 0, 4*sizeof(int));
15247
/* Parse arguments and read input */
15248
while (getopt_long(argc, argv, "", shell_options, &shell_index) != -1) {
15250
if (shell_index==-1) {
15254
if (shell_seen[shell_index]==1) {
15255
fprintf(stderr, "Error, `--%s' argument given twice.\n",
15256
shell_options[shell_index].name);
15259
shell_seen[shell_index]=1;
15261
switch (shell_index) {
15262
case 0: /* graph */
15263
shell_read_graph(&graph, optarg);
15265
case 1: /* weights */
15266
weights=&v_weights; shell_read_vector(weights, optarg);
15268
case 2: /* merges */
15269
shell_arg_merges=strdup(optarg);
15270
igraph_matrix_init(&merges, 0, 0);
15272
case 3: /* modularity */
15273
shell_arg_modularity=strdup(optarg);
15274
igraph_vector_init(&modularity, 0);
15277
shell_igraph_community_fastgreedy_usage(argv);
15286
/* Check that we have all arguments */
15287
for (shell_index=0; shell_index<4; shell_index++) {
15288
if (!shell_seen[shell_index]) {
15289
fprintf(stderr, "Error, argument missing: `--%s'.\n",
15290
shell_options[shell_index].name);
15295
/* Do the operation */
15296
shell_result=igraph_community_fastgreedy(&graph, weights, &merges, &modularity);
15298
/* Write the result */
15299
igraph_destroy(&graph);
15300
if (weights) { igraph_vector_destroy(weights); }
15301
shell_write_matrix(&merges, shell_arg_merges);
15302
igraph_matrix_destroy(&merges);
15303
shell_write_vector(&modularity, shell_arg_modularity);
15304
igraph_vector_destroy(&modularity);
15309
/*-------------------------------------------/
15310
/ igraph_community_to_membership /
15311
/-------------------------------------------*/
15312
void shell_igraph_community_to_membership_usage(char **argv) {
15313
printf("%s --graph=<graph> --merges=<merges> --steps=<steps> --membership=<membership> --csize=<csize>\n", basename(argv[0]));
15317
int shell_igraph_community_to_membership(int argc, char **argv) {
15320
igraph_matrix_t merges;
15321
igraph_integer_t steps;
15322
igraph_vector_t membership;
15323
igraph_vector_t csize;
15324
char* shell_arg_membership=0;
15325
char* shell_arg_csize=0;
15330
int shell_index=-1;
15331
struct option shell_options[]= { { "graph",required_argument,0,0 },
15332
{ "merges",required_argument,0,1 },
15333
{ "steps",required_argument,0,2 },
15334
{ "membership",required_argument,0,3 },
15335
{ "csize",required_argument,0,4 },
15336
{ "help",no_argument,0,5 },
15340
/* 0 - not seen, 1 - seen as argument, 2 - seen as default */
15341
memset(shell_seen, 0, 5*sizeof(int));
15344
/* Parse arguments and read input */
15345
while (getopt_long(argc, argv, "", shell_options, &shell_index) != -1) {
15347
if (shell_index==-1) {
15351
if (shell_seen[shell_index]==1) {
15352
fprintf(stderr, "Error, `--%s' argument given twice.\n",
15353
shell_options[shell_index].name);
15356
shell_seen[shell_index]=1;
15358
switch (shell_index) {
15359
case 0: /* graph */
15360
shell_read_graph(&graph, optarg);
15362
case 1: /* merges */
15363
shell_read_matrix(&merges, optarg);
15365
case 2: /* steps */
15366
shell_read_integer(&steps, optarg);
15368
case 3: /* membership */
15369
shell_arg_membership=strdup(optarg);
15370
igraph_vector_init(&membership, 0);
15372
case 4: /* csize */
15373
shell_arg_csize=strdup(optarg);
15374
igraph_vector_init(&csize, 0);
15377
shell_igraph_community_to_membership_usage(argv);
15386
/* Check that we have all arguments */
15387
for (shell_index=0; shell_index<5; shell_index++) {
15388
if (!shell_seen[shell_index]) {
15389
fprintf(stderr, "Error, argument missing: `--%s'.\n",
15390
shell_options[shell_index].name);
15395
/* Do the operation */
15396
shell_result=igraph_community_to_membership(&graph, &merges, steps, &membership, &csize);
15398
/* Write the result */
15399
igraph_destroy(&graph);
15400
igraph_matrix_destroy(&merges);
15401
shell_write_vector(&membership, shell_arg_membership);
15402
igraph_vector_destroy(&membership);
15403
shell_write_vector(&csize, shell_arg_csize);
15404
igraph_vector_destroy(&csize);
15409
/*-------------------------------------------/
15410
/ igraph_le_community_to_membership /
15411
/-------------------------------------------*/
15412
void shell_igraph_le_community_to_membership_usage(char **argv) {
15413
printf("%s --merges=<merges> --steps=<steps> --membership=<membership> --membership-out=<membership-out> --csize=<csize>\n", basename(argv[0]));
15417
int shell_igraph_le_community_to_membership(int argc, char **argv) {
15419
igraph_matrix_t merges;
15420
igraph_integer_t steps;
15421
igraph_vector_t membership;
15422
igraph_vector_t v_csize; igraph_vector_t *csize=0;
15423
char* shell_arg_membership=0;
15424
char* shell_arg_csize=0;
15429
int shell_index=-1;
15430
struct option shell_options[]= { { "merges",required_argument,0,0 },
15431
{ "steps",required_argument,0,1 },
15432
{ "membership",required_argument,0,2 },
15433
{ "membership-out",required_argument,0,3 },
15434
{ "csize",required_argument,0,4 },
15435
{ "help",no_argument,0,5 },
15439
/* 0 - not seen, 1 - seen as argument, 2 - seen as default */
15440
memset(shell_seen, 0, 5*sizeof(int));
15443
/* Parse arguments and read input */
15444
while (getopt_long(argc, argv, "", shell_options, &shell_index) != -1) {
15446
if (shell_index==-1) {
15450
if (shell_seen[shell_index]==1) {
15451
fprintf(stderr, "Error, `--%s' argument given twice.\n",
15452
shell_options[shell_index].name);
15455
shell_seen[shell_index]=1;
15457
switch (shell_index) {
15458
case 0: /* merges */
15459
shell_read_matrix(&merges, optarg);
15461
case 1: /* steps */
15462
shell_read_integer(&steps, optarg);
15464
case 2: /* membership */
15465
shell_read_vector(&membership, optarg);
15467
case 3: /* membership-out */
15468
shell_arg_membership=strdup(optarg);
15469
igraph_vector_init(&membership, 0);
15471
case 4: /* csize */
15472
csize=&v_csize; igraph_vector_init(csize, 0);
15473
shell_arg_csize=strdup(optarg);
15476
shell_igraph_le_community_to_membership_usage(argv);
15485
/* Check that we have all arguments */
15486
for (shell_index=0; shell_index<5; shell_index++) {
15487
if (!shell_seen[shell_index]) {
15488
fprintf(stderr, "Error, argument missing: `--%s'.\n",
15489
shell_options[shell_index].name);
15494
/* Do the operation */
15495
shell_result=igraph_le_community_to_membership(&merges, steps, &membership, csize);
15497
/* Write the result */
15498
igraph_matrix_destroy(&merges);
15499
igraph_vector_destroy(&membership);
15500
shell_write_vector(&membership, shell_arg_membership);
15501
igraph_vector_destroy(&membership);
15502
if (csize) { shell_write_vector(csize, shell_arg_csize);
15503
igraph_vector_destroy(csize); }
15508
/*-------------------------------------------/
15509
/ igraph_modularity /
15510
/-------------------------------------------*/
15511
void shell_igraph_modularity_usage(char **argv) {
15512
printf("%s --graph=<graph> --membership=<membership> --modularity=<modularity> --weights=<weights>\n", basename(argv[0]));
15516
int shell_igraph_modularity(int argc, char **argv) {
15519
igraph_vector_t membership;
15520
igraph_real_t modularity;
15521
igraph_vector_t v_weights; igraph_vector_t *weights=0=NULL;
15522
char* shell_arg_modularity=0;
15527
int shell_index=-1;
15528
struct option shell_options[]= { { "graph",required_argument,0,0 },
15529
{ "membership",required_argument,0,1 },
15530
{ "modularity",required_argument,0,2 },
15531
{ "weights",required_argument,0,3 },
15532
{ "help",no_argument,0,4 },
15536
/* 0 - not seen, 1 - seen as argument, 2 - seen as default */
15537
memset(shell_seen, 0, 4*sizeof(int));
15540
/* Parse arguments and read input */
15541
while (getopt_long(argc, argv, "", shell_options, &shell_index) != -1) {
15543
if (shell_index==-1) {
15547
if (shell_seen[shell_index]==1) {
15548
fprintf(stderr, "Error, `--%s' argument given twice.\n",
15549
shell_options[shell_index].name);
15552
shell_seen[shell_index]=1;
15554
switch (shell_index) {
15555
case 0: /* graph */
15556
shell_read_graph(&graph, optarg);
15558
case 1: /* membership */
15559
shell_read_vector(&membership, optarg);
15561
case 2: /* modularity */
15562
shell_arg_modularity=strdup(optarg);
15564
case 3: /* weights */
15565
weights=&v_weights; shell_read_vector(weights, optarg);
15568
shell_igraph_modularity_usage(argv);
15577
/* Check that we have all arguments */
15578
for (shell_index=0; shell_index<4; shell_index++) {
15579
if (!shell_seen[shell_index]) {
15580
fprintf(stderr, "Error, argument missing: `--%s'.\n",
15581
shell_options[shell_index].name);
15586
/* Do the operation */
15587
shell_result=igraph_modularity(&graph, &membership, &modularity, weights);
15589
/* Write the result */
15590
igraph_destroy(&graph);
15591
igraph_vector_destroy(&membership);
15592
shell_write_real(modularity, shell_arg_modularity);
15593
if (weights) { igraph_vector_destroy(weights); }
15598
/*-------------------------------------------/
15599
/ igraph_community_leading_eigenvector /
15600
/-------------------------------------------*/
15601
void shell_igraph_community_leading_eigenvector_usage(char **argv) {
15602
printf("%s --graph=<graph> --merges=<merges> --membership=<membership> --steps=<steps>\n", basename(argv[0]));
15606
int shell_igraph_community_leading_eigenvector(int argc, char **argv) {
15609
igraph_matrix_t merges;
15610
igraph_vector_t membership;
15611
igraph_integer_t steps=-1;
15613
char* shell_arg_merges=0;
15614
char* shell_arg_membership=0;
15615
char* shell_arg_options=0;
15620
int shell_index=-1;
15621
struct option shell_options[]= { { "graph",required_argument,0,0 },
15622
{ "merges",required_argument,0,1 },
15623
{ "membership",required_argument,0,2 },
15624
{ "steps",required_argument,0,3 },
15625
{ "help",no_argument,0,4 },
15629
/* 0 - not seen, 1 - seen as argument, 2 - seen as default */
15630
memset(shell_seen, 0, 4*sizeof(int));
15633
/* Parse arguments and read input */
15634
while (getopt_long(argc, argv, "", shell_options, &shell_index) != -1) {
15636
if (shell_index==-1) {
15640
if (shell_seen[shell_index]==1) {
15641
fprintf(stderr, "Error, `--%s' argument given twice.\n",
15642
shell_options[shell_index].name);
15645
shell_seen[shell_index]=1;
15647
switch (shell_index) {
15648
case 0: /* graph */
15649
shell_read_graph(&graph, optarg);
15651
case 1: /* merges */
15652
shell_arg_merges=strdup(optarg);
15653
igraph_matrix_init(&merges, 0, 0);
15655
case 2: /* membership */
15656
shell_arg_membership=strdup(optarg);
15657
igraph_vector_init(&membership, 0);
15659
case 3: /* steps */
15660
shell_read_integer(&steps, optarg);
15663
shell_igraph_community_leading_eigenvector_usage(argv);
15672
/* Check that we have all arguments */
15673
for (shell_index=0; shell_index<4; shell_index++) {
15674
if (!shell_seen[shell_index]) {
15675
fprintf(stderr, "Error, argument missing: `--%s'.\n",
15676
shell_options[shell_index].name);
15681
/* Do the operation */
15682
shell_result=igraph_community_leading_eigenvector(&graph, &merges, &membership, steps, 0);
15684
/* Write the result */
15685
igraph_destroy(&graph);
15686
shell_write_matrix(&merges, shell_arg_merges);
15687
igraph_matrix_destroy(&merges);
15688
shell_write_vector(&membership, shell_arg_membership);
15689
igraph_vector_destroy(&membership);
15694
/*-------------------------------------------/
15695
/ igraph_community_leading_eigenvector_naive /
15696
/-------------------------------------------*/
15697
void shell_igraph_community_leading_eigenvector_naive_usage(char **argv) {
15698
printf("%s --graph=<graph> --merges=<merges> --membership=<membership> --steps=<steps>\n", basename(argv[0]));
15702
int shell_igraph_community_leading_eigenvector_naive(int argc, char **argv) {
15705
igraph_matrix_t merges;
15706
igraph_vector_t membership;
15707
igraph_integer_t steps=-1;
15709
char* shell_arg_merges=0;
15710
char* shell_arg_membership=0;
15711
char* shell_arg_options=0;
15716
int shell_index=-1;
15717
struct option shell_options[]= { { "graph",required_argument,0,0 },
15718
{ "merges",required_argument,0,1 },
15719
{ "membership",required_argument,0,2 },
15720
{ "steps",required_argument,0,3 },
15721
{ "help",no_argument,0,4 },
15725
/* 0 - not seen, 1 - seen as argument, 2 - seen as default */
15726
memset(shell_seen, 0, 4*sizeof(int));
15729
/* Parse arguments and read input */
15730
while (getopt_long(argc, argv, "", shell_options, &shell_index) != -1) {
15732
if (shell_index==-1) {
15736
if (shell_seen[shell_index]==1) {
15737
fprintf(stderr, "Error, `--%s' argument given twice.\n",
15738
shell_options[shell_index].name);
15741
shell_seen[shell_index]=1;
15743
switch (shell_index) {
15744
case 0: /* graph */
15745
shell_read_graph(&graph, optarg);
15747
case 1: /* merges */
15748
shell_arg_merges=strdup(optarg);
15749
igraph_matrix_init(&merges, 0, 0);
15751
case 2: /* membership */
15752
shell_arg_membership=strdup(optarg);
15753
igraph_vector_init(&membership, 0);
15755
case 3: /* steps */
15756
shell_read_integer(&steps, optarg);
15759
shell_igraph_community_leading_eigenvector_naive_usage(argv);
15768
/* Check that we have all arguments */
15769
for (shell_index=0; shell_index<4; shell_index++) {
15770
if (!shell_seen[shell_index]) {
15771
fprintf(stderr, "Error, argument missing: `--%s'.\n",
15772
shell_options[shell_index].name);
15777
/* Do the operation */
15778
shell_result=igraph_community_leading_eigenvector_naive(&graph, &merges, &membership, steps, 0);
15780
/* Write the result */
15781
igraph_destroy(&graph);
15782
shell_write_matrix(&merges, shell_arg_merges);
15783
igraph_matrix_destroy(&merges);
15784
shell_write_vector(&membership, shell_arg_membership);
15785
igraph_vector_destroy(&membership);
15790
/*-------------------------------------------/
15791
/ igraph_community_leading_eigenvector_step /
15792
/-------------------------------------------*/
15793
void shell_igraph_community_leading_eigenvector_step_usage(char **argv) {
15794
printf("%s --graph=<graph> --membership=<membership> --membership-out=<membership-out> --community=<community> --split=<split> --eigenvector=<eigenvector> --eigenvalue=<eigenvalue>\n", basename(argv[0]));
15798
int shell_igraph_community_leading_eigenvector_step(int argc, char **argv) {
15801
igraph_vector_t membership;
15802
igraph_integer_t community;
15803
igraph_bool_t split;
15804
igraph_vector_t v_eigenvector; igraph_vector_t *eigenvector=0;
15805
igraph_real_t eigenvalue;
15808
char* shell_arg_membership=0;
15809
char* shell_arg_split=0;
15810
char* shell_arg_eigenvector=0;
15811
char* shell_arg_eigenvalue=0;
15812
char* shell_arg_options=0;
15817
int shell_index=-1;
15818
struct option shell_options[]= { { "graph",required_argument,0,0 },
15819
{ "membership",required_argument,0,1 },
15820
{ "membership-out",required_argument,0,2 },
15821
{ "community",required_argument,0,3 },
15822
{ "split",required_argument,0,4 },
15823
{ "eigenvector",required_argument,0,5 },
15824
{ "eigenvalue",required_argument,0,6 },
15825
{ "help",no_argument,0,7 },
15829
/* 0 - not seen, 1 - seen as argument, 2 - seen as default */
15830
memset(shell_seen, 0, 7*sizeof(int));
15833
/* Parse arguments and read input */
15834
while (getopt_long(argc, argv, "", shell_options, &shell_index) != -1) {
15836
if (shell_index==-1) {
15840
if (shell_seen[shell_index]==1) {
15841
fprintf(stderr, "Error, `--%s' argument given twice.\n",
15842
shell_options[shell_index].name);
15845
shell_seen[shell_index]=1;
15847
switch (shell_index) {
15848
case 0: /* graph */
15849
shell_read_graph(&graph, optarg);
15851
case 1: /* membership */
15852
shell_read_vector(&membership, optarg);
15854
case 2: /* membership-out */
15855
shell_arg_membership=strdup(optarg);
15856
igraph_vector_init(&membership, 0);
15858
case 3: /* community */
15859
shell_read_integer(&community, optarg);
15861
case 4: /* split */
15864
case 5: /* eigenvector */
15865
eigenvector=&v_eigenvector; igraph_vector_init(eigenvector, 0);
15866
shell_arg_eigenvector=strdup(optarg);
15868
case 6: /* eigenvalue */
15869
shell_arg_eigenvalue=strdup(optarg);
15872
shell_igraph_community_leading_eigenvector_step_usage(argv);
15881
/* Check that we have all arguments */
15882
for (shell_index=0; shell_index<7; shell_index++) {
15883
if (!shell_seen[shell_index]) {
15884
fprintf(stderr, "Error, argument missing: `--%s'.\n",
15885
shell_options[shell_index].name);
15890
/* Do the operation */
15891
shell_result=igraph_community_leading_eigenvector_step(&graph, &membership, community, &split, eigenvector, &eigenvalue, 0, 0);
15893
/* Write the result */
15894
igraph_destroy(&graph);
15895
igraph_vector_destroy(&membership);
15896
shell_write_vector(&membership, shell_arg_membership);
15897
igraph_vector_destroy(&membership);
15898
shell_write_boolean(split, shell_arg_split);
15899
if (eigenvector) { shell_write_vector(eigenvector, shell_arg_eigenvector);
15900
igraph_vector_destroy(eigenvector); }
15901
shell_write_real(eigenvalue, shell_arg_eigenvalue);
15906
/*-------------------------------------------/
15907
/ igraph_community_label_propagation /
15908
/-------------------------------------------*/
15909
void shell_igraph_community_label_propagation_usage(char **argv) {
15910
printf("%s --graph=<graph> --membership=<membership> --initial=<initial>\n", basename(argv[0]));
15914
int shell_igraph_community_label_propagation(int argc, char **argv) {
15917
igraph_vector_t membership;
15919
igraph_vector_t v_initial; igraph_vector_t *initial=0=NULL;
15921
char* shell_arg_membership=0;
15926
int shell_index=-1;
15927
struct option shell_options[]= { { "graph",required_argument,0,0 },
15928
{ "membership",required_argument,0,1 },
15929
{ "initial",required_argument,0,2 },
15930
{ "help",no_argument,0,3 },
15934
/* 0 - not seen, 1 - seen as argument, 2 - seen as default */
15935
memset(shell_seen, 0, 3*sizeof(int));
15938
/* Parse arguments and read input */
15939
while (getopt_long(argc, argv, "", shell_options, &shell_index) != -1) {
15941
if (shell_index==-1) {
15945
if (shell_seen[shell_index]==1) {
15946
fprintf(stderr, "Error, `--%s' argument given twice.\n",
15947
shell_options[shell_index].name);
15950
shell_seen[shell_index]=1;
15952
switch (shell_index) {
15953
case 0: /* graph */
15954
shell_read_graph(&graph, optarg);
15956
case 1: /* membership */
15957
shell_arg_membership=strdup(optarg);
15958
igraph_vector_init(&membership, 0);
15960
case 2: /* initial */
15961
initial=&v_initial; shell_read_vector(initial, optarg);
15964
shell_igraph_community_label_propagation_usage(argv);
15973
/* Check that we have all arguments */
15974
for (shell_index=0; shell_index<3; shell_index++) {
15975
if (!shell_seen[shell_index]) {
15976
fprintf(stderr, "Error, argument missing: `--%s'.\n",
15977
shell_options[shell_index].name);
15982
/* Do the operation */
15983
shell_result=igraph_community_label_propagation(&graph, &membership, 0, initial, fixed);
15985
/* Write the result */
15986
igraph_destroy(&graph);
15987
shell_write_vector(&membership, shell_arg_membership);
15988
igraph_vector_destroy(&membership);
15989
if (initial) { igraph_vector_destroy(initial); }
15994
/*-------------------------------------------/
15995
/ igraph_get_adjacency /
15996
/-------------------------------------------*/
15997
void shell_igraph_get_adjacency_usage(char **argv) {
15998
printf("%s --graph=<graph> --res=<res> --type=<type>\n", basename(argv[0]));
16002
int shell_igraph_get_adjacency(int argc, char **argv) {
16005
igraph_matrix_t res;
16006
igraph_get_adjacency_t type=IGRAPH_GET_ADJACENCY_BOTH;
16007
char* shell_arg_res=0;
16012
int shell_index=-1;
16013
struct option shell_options[]= { { "graph",required_argument,0,0 },
16014
{ "res",required_argument,0,1 },
16015
{ "type",required_argument,0,2 },
16016
{ "help",no_argument,0,3 },
16020
/* 0 - not seen, 1 - seen as argument, 2 - seen as default */
16021
memset(shell_seen, 0, 3*sizeof(int));
16024
/* Parse arguments and read input */
16025
while (getopt_long(argc, argv, "", shell_options, &shell_index) != -1) {
16027
if (shell_index==-1) {
16031
if (shell_seen[shell_index]==1) {
16032
fprintf(stderr, "Error, `--%s' argument given twice.\n",
16033
shell_options[shell_index].name);
16036
shell_seen[shell_index]=1;
16038
switch (shell_index) {
16039
case 0: /* graph */
16040
shell_read_graph(&graph, optarg);
16043
shell_arg_res=strdup(optarg);
16044
igraph_matrix_init(&res, 0, 0);
16047
shell_read_enum(&type, optarg, "upper", 0, "lower", 1, "both", 2, 0);
16050
shell_igraph_get_adjacency_usage(argv);
16059
/* Check that we have all arguments */
16060
for (shell_index=0; shell_index<3; shell_index++) {
16061
if (!shell_seen[shell_index]) {
16062
fprintf(stderr, "Error, argument missing: `--%s'.\n",
16063
shell_options[shell_index].name);
16068
/* Do the operation */
16069
shell_result=igraph_get_adjacency(&graph, &res, type);
16071
/* Write the result */
16072
igraph_destroy(&graph);
16073
shell_write_matrix(&res, shell_arg_res);
16074
igraph_matrix_destroy(&res);
16079
/*-------------------------------------------/
16080
/ igraph_get_edgelist /
16081
/-------------------------------------------*/
16082
void shell_igraph_get_edgelist_usage(char **argv) {
16083
printf("%s --graph=<graph> --res=<res> --bycol=<bycol>\n", basename(argv[0]));
16087
int shell_igraph_get_edgelist(int argc, char **argv) {
16090
igraph_vector_t res;
16091
igraph_bool_t bycol=0;
16092
char* shell_arg_res=0;
16097
int shell_index=-1;
16098
struct option shell_options[]= { { "graph",required_argument,0,0 },
16099
{ "res",required_argument,0,1 },
16100
{ "bycol",required_argument,0,2 },
16101
{ "help",no_argument,0,3 },
16105
/* 0 - not seen, 1 - seen as argument, 2 - seen as default */
16106
memset(shell_seen, 0, 3*sizeof(int));
16109
/* Parse arguments and read input */
16110
while (getopt_long(argc, argv, "", shell_options, &shell_index) != -1) {
16112
if (shell_index==-1) {
16116
if (shell_seen[shell_index]==1) {
16117
fprintf(stderr, "Error, `--%s' argument given twice.\n",
16118
shell_options[shell_index].name);
16121
shell_seen[shell_index]=1;
16123
switch (shell_index) {
16124
case 0: /* graph */
16125
shell_read_graph(&graph, optarg);
16128
shell_arg_res=strdup(optarg);
16129
igraph_vector_init(&res, 0);
16131
case 2: /* bycol */
16132
shell_read_boolean(&bycol, optarg);
16135
shell_igraph_get_edgelist_usage(argv);
16144
/* Check that we have all arguments */
16145
for (shell_index=0; shell_index<3; shell_index++) {
16146
if (!shell_seen[shell_index]) {
16147
fprintf(stderr, "Error, argument missing: `--%s'.\n",
16148
shell_options[shell_index].name);
16153
/* Do the operation */
16154
shell_result=igraph_get_edgelist(&graph, &res, bycol);
16156
/* Write the result */
16157
igraph_destroy(&graph);
16158
shell_write_vector(&res, shell_arg_res);
16159
igraph_vector_destroy(&res);
16164
/*-------------------------------------------/
16165
/ igraph_to_directed /
16166
/-------------------------------------------*/
16167
void shell_igraph_to_directed_usage(char **argv) {
16168
printf("%s --graph=<graph> --graph-out=<graph-out> --flags=<flags>\n", basename(argv[0]));
16172
int shell_igraph_to_directed(int argc, char **argv) {
16175
igraph_to_directed_t flags=IGRAPH_TO_DIRECTED_MUTUAL;
16176
char* shell_arg_graph=0;
16181
int shell_index=-1;
16182
struct option shell_options[]= { { "graph",required_argument,0,0 },
16183
{ "graph-out",required_argument,0,1 },
16184
{ "flags",required_argument,0,2 },
16185
{ "help",no_argument,0,3 },
16189
/* 0 - not seen, 1 - seen as argument, 2 - seen as default */
16190
memset(shell_seen, 0, 3*sizeof(int));
16193
/* Parse arguments and read input */
16194
while (getopt_long(argc, argv, "", shell_options, &shell_index) != -1) {
16196
if (shell_index==-1) {
16200
if (shell_seen[shell_index]==1) {
16201
fprintf(stderr, "Error, `--%s' argument given twice.\n",
16202
shell_options[shell_index].name);
16205
shell_seen[shell_index]=1;
16207
switch (shell_index) {
16208
case 0: /* graph */
16209
shell_read_graph(&graph, optarg);
16211
case 1: /* graph-out */
16212
shell_arg_graph=strdup(optarg);
16214
case 2: /* flags */
16215
shell_read_enum(&flags, optarg, "arbitrary", 0, "mutual", 1, 0);
16218
shell_igraph_to_directed_usage(argv);
16227
/* Check that we have all arguments */
16228
for (shell_index=0; shell_index<3; shell_index++) {
16229
if (!shell_seen[shell_index]) {
16230
fprintf(stderr, "Error, argument missing: `--%s'.\n",
16231
shell_options[shell_index].name);
16236
/* Do the operation */
16237
shell_result=igraph_to_directed(&graph, flags);
16239
/* Write the result */
16240
igraph_destroy(&graph);
16241
shell_write_graph(&graph, shell_arg_graph);
16242
igraph_destroy(&graph);
16247
/*-------------------------------------------/
16248
/ igraph_to_undirected /
16249
/-------------------------------------------*/
16250
void shell_igraph_to_undirected_usage(char **argv) {
16251
printf("%s --graph=<graph> --graph-out=<graph-out> --flags=<flags>\n", basename(argv[0]));
16255
int shell_igraph_to_undirected(int argc, char **argv) {
16258
igraph_to_undirected_t flags=IGRAPH_TO_UNDIRECTED_COLLAPSE;
16259
char* shell_arg_graph=0;
16264
int shell_index=-1;
16265
struct option shell_options[]= { { "graph",required_argument,0,0 },
16266
{ "graph-out",required_argument,0,1 },
16267
{ "flags",required_argument,0,2 },
16268
{ "help",no_argument,0,3 },
16272
/* 0 - not seen, 1 - seen as argument, 2 - seen as default */
16273
memset(shell_seen, 0, 3*sizeof(int));
16276
/* Parse arguments and read input */
16277
while (getopt_long(argc, argv, "", shell_options, &shell_index) != -1) {
16279
if (shell_index==-1) {
16283
if (shell_seen[shell_index]==1) {
16284
fprintf(stderr, "Error, `--%s' argument given twice.\n",
16285
shell_options[shell_index].name);
16288
shell_seen[shell_index]=1;
16290
switch (shell_index) {
16291
case 0: /* graph */
16292
shell_read_graph(&graph, optarg);
16294
case 1: /* graph-out */
16295
shell_arg_graph=strdup(optarg);
16297
case 2: /* flags */
16298
shell_read_enum(&flags, optarg, "each", 0, "collapse", 0);
16301
shell_igraph_to_undirected_usage(argv);
16310
/* Check that we have all arguments */
16311
for (shell_index=0; shell_index<3; shell_index++) {
16312
if (!shell_seen[shell_index]) {
16313
fprintf(stderr, "Error, argument missing: `--%s'.\n",
16314
shell_options[shell_index].name);
16319
/* Do the operation */
16320
shell_result=igraph_to_undirected(&graph, flags);
16322
/* Write the result */
16323
igraph_destroy(&graph);
16324
shell_write_graph(&graph, shell_arg_graph);
16325
igraph_destroy(&graph);
16330
/*-------------------------------------------/
16331
/ igraph_read_graph_edgelist /
16332
/-------------------------------------------*/
16333
void shell_igraph_read_graph_edgelist_usage(char **argv) {
16334
printf("%s --graph=<graph> --instream=<instream> --n=<n> --directed=<directed>\n", basename(argv[0]));
16338
int shell_igraph_read_graph_edgelist(int argc, char **argv) {
16342
igraph_integer_t n=0;
16343
igraph_bool_t directed=1;
16344
char* shell_arg_graph=0;
16349
int shell_index=-1;
16350
struct option shell_options[]= { { "graph",required_argument,0,0 },
16351
{ "instream",required_argument,0,1 },
16352
{ "n",required_argument,0,2 },
16353
{ "directed",required_argument,0,3 },
16354
{ "help",no_argument,0,4 },
16358
/* 0 - not seen, 1 - seen as argument, 2 - seen as default */
16359
memset(shell_seen, 0, 4*sizeof(int));
16363
/* Parse arguments and read input */
16364
while (getopt_long(argc, argv, "", shell_options, &shell_index) != -1) {
16366
if (shell_index==-1) {
16370
if (shell_seen[shell_index]==1) {
16371
fprintf(stderr, "Error, `--%s' argument given twice.\n",
16372
shell_options[shell_index].name);
16375
shell_seen[shell_index]=1;
16377
switch (shell_index) {
16378
case 0: /* graph */
16379
shell_arg_graph=strdup(optarg);
16381
case 1: /* instream */
16382
shell_read_file(&instream, optarg, "r");
16385
shell_read_integer(&n, optarg);
16387
case 3: /* directed */
16388
shell_read_boolean(&directed, optarg);
16391
shell_igraph_read_graph_edgelist_usage(argv);
16400
/* Check that we have all arguments */
16401
for (shell_index=0; shell_index<4; shell_index++) {
16402
if (!shell_seen[shell_index]) {
16403
fprintf(stderr, "Error, argument missing: `--%s'.\n",
16404
shell_options[shell_index].name);
16409
/* Do the operation */
16410
shell_result=igraph_read_graph_edgelist(&graph, instream, n, directed);
16412
/* Write the result */
16413
shell_write_graph(&graph, shell_arg_graph);
16414
igraph_destroy(&graph);
16420
/*-------------------------------------------/
16421
/ igraph_read_graph_ncol /
16422
/-------------------------------------------*/
16423
void shell_igraph_read_graph_ncol_usage(char **argv) {
16424
printf("%s --graph=<graph> --instream=<instream> --predefnames=<predefnames> --names=<names> --weights=<weights> --directed=<directed>\n", basename(argv[0]));
16428
int shell_igraph_read_graph_ncol(int argc, char **argv) {
16432
igraph_strvector_t v_predefnames; igraph_strvector_t *predefnames=0;;
16433
igraph_bool_t names=1;
16434
igraph_bool_t weights=1;
16435
igraph_bool_t directed=1;
16436
char* shell_arg_graph=0;
16441
int shell_index=-1;
16442
struct option shell_options[]= { { "graph",required_argument,0,0 },
16443
{ "instream",required_argument,0,1 },
16444
{ "predefnames",required_argument,0,2 },
16445
{ "names",required_argument,0,3 },
16446
{ "weights",required_argument,0,4 },
16447
{ "directed",required_argument,0,5 },
16448
{ "help",no_argument,0,6 },
16452
/* 0 - not seen, 1 - seen as argument, 2 - seen as default */
16453
memset(shell_seen, 0, 6*sizeof(int));
16458
/* Parse arguments and read input */
16459
while (getopt_long(argc, argv, "", shell_options, &shell_index) != -1) {
16461
if (shell_index==-1) {
16465
if (shell_seen[shell_index]==1) {
16466
fprintf(stderr, "Error, `--%s' argument given twice.\n",
16467
shell_options[shell_index].name);
16470
shell_seen[shell_index]=1;
16472
switch (shell_index) {
16473
case 0: /* graph */
16474
shell_arg_graph=strdup(optarg);
16476
case 1: /* instream */
16477
shell_read_file(&instream, optarg, "r");
16479
case 2: /* predefnames */
16480
predefnames=&v_predefnames; shell_read_strvector(predefnames, optarg);
16482
case 3: /* names */
16483
shell_read_boolean(&names, optarg);
16485
case 4: /* weights */
16486
shell_read_boolean(&weights, optarg);
16488
case 5: /* directed */
16489
shell_read_boolean(&directed, optarg);
16492
shell_igraph_read_graph_ncol_usage(argv);
16501
/* Check that we have all arguments */
16502
for (shell_index=0; shell_index<6; shell_index++) {
16503
if (!shell_seen[shell_index]) {
16504
fprintf(stderr, "Error, argument missing: `--%s'.\n",
16505
shell_options[shell_index].name);
16510
/* Do the operation */
16511
shell_result=igraph_read_graph_ncol(&graph, instream, predefnames, names, weights, directed);
16513
/* Write the result */
16514
shell_write_graph(&graph, shell_arg_graph);
16515
igraph_destroy(&graph);
16517
if (predefnames) { igraph_strvector_destroy(predefnames); }
16522
/*-------------------------------------------/
16523
/ igraph_read_graph_lgl /
16524
/-------------------------------------------*/
16525
void shell_igraph_read_graph_lgl_usage(char **argv) {
16526
printf("%s --graph=<graph> --instream=<instream> --names=<names> --weights=<weights>\n", basename(argv[0]));
16530
int shell_igraph_read_graph_lgl(int argc, char **argv) {
16534
igraph_bool_t names=1;
16535
igraph_bool_t weights=1;
16536
char* shell_arg_graph=0;
16541
int shell_index=-1;
16542
struct option shell_options[]= { { "graph",required_argument,0,0 },
16543
{ "instream",required_argument,0,1 },
16544
{ "names",required_argument,0,2 },
16545
{ "weights",required_argument,0,3 },
16546
{ "help",no_argument,0,4 },
16550
/* 0 - not seen, 1 - seen as argument, 2 - seen as default */
16551
memset(shell_seen, 0, 4*sizeof(int));
16555
/* Parse arguments and read input */
16556
while (getopt_long(argc, argv, "", shell_options, &shell_index) != -1) {
16558
if (shell_index==-1) {
16562
if (shell_seen[shell_index]==1) {
16563
fprintf(stderr, "Error, `--%s' argument given twice.\n",
16564
shell_options[shell_index].name);
16567
shell_seen[shell_index]=1;
16569
switch (shell_index) {
16570
case 0: /* graph */
16571
shell_arg_graph=strdup(optarg);
16573
case 1: /* instream */
16574
shell_read_file(&instream, optarg, "r");
16576
case 2: /* names */
16577
shell_read_boolean(&names, optarg);
16579
case 3: /* weights */
16580
shell_read_boolean(&weights, optarg);
16583
shell_igraph_read_graph_lgl_usage(argv);
16592
/* Check that we have all arguments */
16593
for (shell_index=0; shell_index<4; shell_index++) {
16594
if (!shell_seen[shell_index]) {
16595
fprintf(stderr, "Error, argument missing: `--%s'.\n",
16596
shell_options[shell_index].name);
16601
/* Do the operation */
16602
shell_result=igraph_read_graph_lgl(&graph, instream, names, weights);
16604
/* Write the result */
16605
shell_write_graph(&graph, shell_arg_graph);
16606
igraph_destroy(&graph);
16612
/*-------------------------------------------/
16613
/ igraph_read_graph_pajek /
16614
/-------------------------------------------*/
16615
void shell_igraph_read_graph_pajek_usage(char **argv) {
16616
printf("%s --graph=<graph> --instream=<instream>\n", basename(argv[0]));
16620
int shell_igraph_read_graph_pajek(int argc, char **argv) {
16624
char* shell_arg_graph=0;
16629
int shell_index=-1;
16630
struct option shell_options[]= { { "graph",required_argument,0,0 },
16631
{ "instream",required_argument,0,1 },
16632
{ "help",no_argument,0,2 },
16636
/* 0 - not seen, 1 - seen as argument, 2 - seen as default */
16637
memset(shell_seen, 0, 2*sizeof(int));
16640
/* Parse arguments and read input */
16641
while (getopt_long(argc, argv, "", shell_options, &shell_index) != -1) {
16643
if (shell_index==-1) {
16647
if (shell_seen[shell_index]==1) {
16648
fprintf(stderr, "Error, `--%s' argument given twice.\n",
16649
shell_options[shell_index].name);
16652
shell_seen[shell_index]=1;
16654
switch (shell_index) {
16655
case 0: /* graph */
16656
shell_arg_graph=strdup(optarg);
16658
case 1: /* instream */
16659
shell_read_file(&instream, optarg, "r");
16662
shell_igraph_read_graph_pajek_usage(argv);
16671
/* Check that we have all arguments */
16672
for (shell_index=0; shell_index<2; shell_index++) {
16673
if (!shell_seen[shell_index]) {
16674
fprintf(stderr, "Error, argument missing: `--%s'.\n",
16675
shell_options[shell_index].name);
16680
/* Do the operation */
16681
shell_result=igraph_read_graph_pajek(&graph, instream);
16683
/* Write the result */
16684
shell_write_graph(&graph, shell_arg_graph);
16685
igraph_destroy(&graph);
16691
/*-------------------------------------------/
16692
/ igraph_read_graph_graphml /
16693
/-------------------------------------------*/
16694
void shell_igraph_read_graph_graphml_usage(char **argv) {
16695
printf("%s --graph=<graph> --instream=<instream> --index=<index>\n", basename(argv[0]));
16699
int shell_igraph_read_graph_graphml(int argc, char **argv) {
16704
char* shell_arg_graph=0;
16709
int shell_index=-1;
16710
struct option shell_options[]= { { "graph",required_argument,0,0 },
16711
{ "instream",required_argument,0,1 },
16712
{ "index",required_argument,0,2 },
16713
{ "help",no_argument,0,3 },
16717
/* 0 - not seen, 1 - seen as argument, 2 - seen as default */
16718
memset(shell_seen, 0, 3*sizeof(int));
16721
/* Parse arguments and read input */
16722
while (getopt_long(argc, argv, "", shell_options, &shell_index) != -1) {
16724
if (shell_index==-1) {
16728
if (shell_seen[shell_index]==1) {
16729
fprintf(stderr, "Error, `--%s' argument given twice.\n",
16730
shell_options[shell_index].name);
16733
shell_seen[shell_index]=1;
16735
switch (shell_index) {
16736
case 0: /* graph */
16737
shell_arg_graph=strdup(optarg);
16739
case 1: /* instream */
16740
shell_read_file(&instream, optarg, "r");
16742
case 2: /* index */
16743
shell_read_int(&index, optarg);
16746
shell_igraph_read_graph_graphml_usage(argv);
16755
/* Check that we have all arguments */
16756
for (shell_index=0; shell_index<3; shell_index++) {
16757
if (!shell_seen[shell_index]) {
16758
fprintf(stderr, "Error, argument missing: `--%s'.\n",
16759
shell_options[shell_index].name);
16764
/* Do the operation */
16765
shell_result=igraph_read_graph_graphml(&graph, instream, index);
16767
/* Write the result */
16768
shell_write_graph(&graph, shell_arg_graph);
16769
igraph_destroy(&graph);
16775
/*-------------------------------------------/
16776
/ igraph_read_graph_dimacs /
16777
/-------------------------------------------*/
16778
void shell_igraph_read_graph_dimacs_usage(char **argv) {
16779
printf("%s --graph=<graph> --instream=<instream> --source=<source> --target=<target> --capacity=<capacity> --directed=<directed>\n", basename(argv[0]));
16783
int shell_igraph_read_graph_dimacs(int argc, char **argv) {
16787
igraph_integer_t source;
16788
igraph_integer_t target;
16789
igraph_vector_t capacity;
16790
igraph_bool_t directed=1;
16791
char* shell_arg_graph=0;
16792
char* shell_arg_source=0;
16793
char* shell_arg_target=0;
16794
char* shell_arg_capacity=0;
16799
int shell_index=-1;
16800
struct option shell_options[]= { { "graph",required_argument,0,0 },
16801
{ "instream",required_argument,0,1 },
16802
{ "source",required_argument,0,2 },
16803
{ "target",required_argument,0,3 },
16804
{ "capacity",required_argument,0,4 },
16805
{ "directed",required_argument,0,5 },
16806
{ "help",no_argument,0,6 },
16810
/* 0 - not seen, 1 - seen as argument, 2 - seen as default */
16811
memset(shell_seen, 0, 6*sizeof(int));
16814
/* Parse arguments and read input */
16815
while (getopt_long(argc, argv, "", shell_options, &shell_index) != -1) {
16817
if (shell_index==-1) {
16821
if (shell_seen[shell_index]==1) {
16822
fprintf(stderr, "Error, `--%s' argument given twice.\n",
16823
shell_options[shell_index].name);
16826
shell_seen[shell_index]=1;
16828
switch (shell_index) {
16829
case 0: /* graph */
16830
shell_arg_graph=strdup(optarg);
16832
case 1: /* instream */
16833
shell_read_file(&instream, optarg, "r");
16835
case 2: /* source */
16836
shell_arg_source=strdup(optarg);
16838
case 3: /* target */
16839
shell_arg_target=strdup(optarg);
16841
case 4: /* capacity */
16842
shell_arg_capacity=strdup(optarg);
16843
igraph_vector_init(&capacity, 0);
16845
case 5: /* directed */
16846
shell_read_boolean(&directed, optarg);
16849
shell_igraph_read_graph_dimacs_usage(argv);
16858
/* Check that we have all arguments */
16859
for (shell_index=0; shell_index<6; shell_index++) {
16860
if (!shell_seen[shell_index]) {
16861
fprintf(stderr, "Error, argument missing: `--%s'.\n",
16862
shell_options[shell_index].name);
16867
/* Do the operation */
16868
shell_result=igraph_read_graph_dimacs(&graph, instream, &source, &target, &capacity, directed);
16870
/* Write the result */
16871
shell_write_graph(&graph, shell_arg_graph);
16872
igraph_destroy(&graph);
16874
shell_write_integer(source, shell_arg_source);
16875
shell_write_integer(target, shell_arg_target);
16876
shell_write_vector(&capacity, shell_arg_capacity);
16877
igraph_vector_destroy(&capacity);
16882
/*-------------------------------------------/
16883
/ igraph_read_graph_graphdb /
16884
/-------------------------------------------*/
16885
void shell_igraph_read_graph_graphdb_usage(char **argv) {
16886
printf("%s --graph=<graph> --instream=<instream> --directed=<directed>\n", basename(argv[0]));
16890
int shell_igraph_read_graph_graphdb(int argc, char **argv) {
16894
igraph_bool_t directed=0;
16895
char* shell_arg_graph=0;
16900
int shell_index=-1;
16901
struct option shell_options[]= { { "graph",required_argument,0,0 },
16902
{ "instream",required_argument,0,1 },
16903
{ "directed",required_argument,0,2 },
16904
{ "help",no_argument,0,3 },
16908
/* 0 - not seen, 1 - seen as argument, 2 - seen as default */
16909
memset(shell_seen, 0, 3*sizeof(int));
16912
/* Parse arguments and read input */
16913
while (getopt_long(argc, argv, "", shell_options, &shell_index) != -1) {
16915
if (shell_index==-1) {
16919
if (shell_seen[shell_index]==1) {
16920
fprintf(stderr, "Error, `--%s' argument given twice.\n",
16921
shell_options[shell_index].name);
16924
shell_seen[shell_index]=1;
16926
switch (shell_index) {
16927
case 0: /* graph */
16928
shell_arg_graph=strdup(optarg);
16930
case 1: /* instream */
16931
shell_read_file(&instream, optarg, "r");
16933
case 2: /* directed */
16934
shell_read_boolean(&directed, optarg);
16937
shell_igraph_read_graph_graphdb_usage(argv);
16946
/* Check that we have all arguments */
16947
for (shell_index=0; shell_index<3; shell_index++) {
16948
if (!shell_seen[shell_index]) {
16949
fprintf(stderr, "Error, argument missing: `--%s'.\n",
16950
shell_options[shell_index].name);
16955
/* Do the operation */
16956
shell_result=igraph_read_graph_graphdb(&graph, instream, directed);
16958
/* Write the result */
16959
shell_write_graph(&graph, shell_arg_graph);
16960
igraph_destroy(&graph);
16966
/*-------------------------------------------/
16967
/ igraph_read_graph_gml /
16968
/-------------------------------------------*/
16969
void shell_igraph_read_graph_gml_usage(char **argv) {
16970
printf("%s --graph=<graph> --instream=<instream>\n", basename(argv[0]));
16974
int shell_igraph_read_graph_gml(int argc, char **argv) {
16978
char* shell_arg_graph=0;
16983
int shell_index=-1;
16984
struct option shell_options[]= { { "graph",required_argument,0,0 },
16985
{ "instream",required_argument,0,1 },
16986
{ "help",no_argument,0,2 },
16990
/* 0 - not seen, 1 - seen as argument, 2 - seen as default */
16991
memset(shell_seen, 0, 2*sizeof(int));
16994
/* Parse arguments and read input */
16995
while (getopt_long(argc, argv, "", shell_options, &shell_index) != -1) {
16997
if (shell_index==-1) {
17001
if (shell_seen[shell_index]==1) {
17002
fprintf(stderr, "Error, `--%s' argument given twice.\n",
17003
shell_options[shell_index].name);
17006
shell_seen[shell_index]=1;
17008
switch (shell_index) {
17009
case 0: /* graph */
17010
shell_arg_graph=strdup(optarg);
17012
case 1: /* instream */
17013
shell_read_file(&instream, optarg, "r");
17016
shell_igraph_read_graph_gml_usage(argv);
17025
/* Check that we have all arguments */
17026
for (shell_index=0; shell_index<2; shell_index++) {
17027
if (!shell_seen[shell_index]) {
17028
fprintf(stderr, "Error, argument missing: `--%s'.\n",
17029
shell_options[shell_index].name);
17034
/* Do the operation */
17035
shell_result=igraph_read_graph_gml(&graph, instream);
17037
/* Write the result */
17038
shell_write_graph(&graph, shell_arg_graph);
17039
igraph_destroy(&graph);
17045
/*-------------------------------------------/
17046
/ igraph_write_graph_edgelist /
17047
/-------------------------------------------*/
17048
void shell_igraph_write_graph_edgelist_usage(char **argv) {
17049
printf("%s --graph=<graph> --outstream=<outstream>\n", basename(argv[0]));
17053
int shell_igraph_write_graph_edgelist(int argc, char **argv) {
17061
int shell_index=-1;
17062
struct option shell_options[]= { { "graph",required_argument,0,0 },
17063
{ "outstream",required_argument,0,1 },
17064
{ "help",no_argument,0,2 },
17068
/* 0 - not seen, 1 - seen as argument, 2 - seen as default */
17069
memset(shell_seen, 0, 2*sizeof(int));
17072
/* Parse arguments and read input */
17073
while (getopt_long(argc, argv, "", shell_options, &shell_index) != -1) {
17075
if (shell_index==-1) {
17079
if (shell_seen[shell_index]==1) {
17080
fprintf(stderr, "Error, `--%s' argument given twice.\n",
17081
shell_options[shell_index].name);
17084
shell_seen[shell_index]=1;
17086
switch (shell_index) {
17087
case 0: /* graph */
17088
shell_read_graph(&graph, optarg);
17090
case 1: /* outstream */
17091
shell_read_file(&outstream, optarg, "w");
17094
shell_igraph_write_graph_edgelist_usage(argv);
17103
/* Check that we have all arguments */
17104
for (shell_index=0; shell_index<2; shell_index++) {
17105
if (!shell_seen[shell_index]) {
17106
fprintf(stderr, "Error, argument missing: `--%s'.\n",
17107
shell_options[shell_index].name);
17112
/* Do the operation */
17113
shell_result=igraph_write_graph_edgelist(&graph, outstream);
17115
/* Write the result */
17116
igraph_destroy(&graph);
17122
/*-------------------------------------------/
17123
/ igraph_write_graph_ncol /
17124
/-------------------------------------------*/
17125
void shell_igraph_write_graph_ncol_usage(char **argv) {
17126
printf("%s --graph=<graph> --outstream=<outstream> --names=<names> --weights=<weights>\n", basename(argv[0]));
17130
int shell_igraph_write_graph_ncol(int argc, char **argv) {
17134
char * names="name";
17135
char * weights="weight";
17140
int shell_index=-1;
17141
struct option shell_options[]= { { "graph",required_argument,0,0 },
17142
{ "outstream",required_argument,0,1 },
17143
{ "names",required_argument,0,2 },
17144
{ "weights",required_argument,0,3 },
17145
{ "help",no_argument,0,4 },
17149
/* 0 - not seen, 1 - seen as argument, 2 - seen as default */
17150
memset(shell_seen, 0, 4*sizeof(int));
17154
/* Parse arguments and read input */
17155
while (getopt_long(argc, argv, "", shell_options, &shell_index) != -1) {
17157
if (shell_index==-1) {
17161
if (shell_seen[shell_index]==1) {
17162
fprintf(stderr, "Error, `--%s' argument given twice.\n",
17163
shell_options[shell_index].name);
17166
shell_seen[shell_index]=1;
17168
switch (shell_index) {
17169
case 0: /* graph */
17170
shell_read_graph(&graph, optarg);
17172
case 1: /* outstream */
17173
shell_read_file(&outstream, optarg, "w");
17175
case 2: /* names */
17176
names=strdup(optarg);
17178
case 3: /* weights */
17179
weights=strdup(optarg);
17182
shell_igraph_write_graph_ncol_usage(argv);
17191
/* Check that we have all arguments */
17192
for (shell_index=0; shell_index<4; shell_index++) {
17193
if (!shell_seen[shell_index]) {
17194
fprintf(stderr, "Error, argument missing: `--%s'.\n",
17195
shell_options[shell_index].name);
17200
/* Do the operation */
17201
shell_result=igraph_write_graph_ncol(&graph, outstream, names, weights);
17203
/* Write the result */
17204
igraph_destroy(&graph);
17212
/*-------------------------------------------/
17213
/ igraph_write_graph_lgl /
17214
/-------------------------------------------*/
17215
void shell_igraph_write_graph_lgl_usage(char **argv) {
17216
printf("%s --graph=<graph> --outstream=<outstream> --names=<names> --weights=<weights> --isolates=<isolates>\n", basename(argv[0]));
17220
int shell_igraph_write_graph_lgl(int argc, char **argv) {
17224
char * names="name";
17225
char * weights="weight";
17226
igraph_bool_t isolates=1;
17231
int shell_index=-1;
17232
struct option shell_options[]= { { "graph",required_argument,0,0 },
17233
{ "outstream",required_argument,0,1 },
17234
{ "names",required_argument,0,2 },
17235
{ "weights",required_argument,0,3 },
17236
{ "isolates",required_argument,0,4 },
17237
{ "help",no_argument,0,5 },
17241
/* 0 - not seen, 1 - seen as argument, 2 - seen as default */
17242
memset(shell_seen, 0, 5*sizeof(int));
17247
/* Parse arguments and read input */
17248
while (getopt_long(argc, argv, "", shell_options, &shell_index) != -1) {
17250
if (shell_index==-1) {
17254
if (shell_seen[shell_index]==1) {
17255
fprintf(stderr, "Error, `--%s' argument given twice.\n",
17256
shell_options[shell_index].name);
17259
shell_seen[shell_index]=1;
17261
switch (shell_index) {
17262
case 0: /* graph */
17263
shell_read_graph(&graph, optarg);
17265
case 1: /* outstream */
17266
shell_read_file(&outstream, optarg, "w");
17268
case 2: /* names */
17269
names=strdup(optarg);
17271
case 3: /* weights */
17272
weights=strdup(optarg);
17274
case 4: /* isolates */
17275
shell_read_boolean(&isolates, optarg);
17278
shell_igraph_write_graph_lgl_usage(argv);
17287
/* Check that we have all arguments */
17288
for (shell_index=0; shell_index<5; shell_index++) {
17289
if (!shell_seen[shell_index]) {
17290
fprintf(stderr, "Error, argument missing: `--%s'.\n",
17291
shell_options[shell_index].name);
17296
/* Do the operation */
17297
shell_result=igraph_write_graph_lgl(&graph, outstream, names, weights, isolates);
17299
/* Write the result */
17300
igraph_destroy(&graph);
17308
/*-------------------------------------------/
17309
/ igraph_write_graph_graphml /
17310
/-------------------------------------------*/
17311
void shell_igraph_write_graph_graphml_usage(char **argv) {
17312
printf("%s --graph=<graph> --outstream=<outstream>\n", basename(argv[0]));
17316
int shell_igraph_write_graph_graphml(int argc, char **argv) {
17324
int shell_index=-1;
17325
struct option shell_options[]= { { "graph",required_argument,0,0 },
17326
{ "outstream",required_argument,0,1 },
17327
{ "help",no_argument,0,2 },
17331
/* 0 - not seen, 1 - seen as argument, 2 - seen as default */
17332
memset(shell_seen, 0, 2*sizeof(int));
17335
/* Parse arguments and read input */
17336
while (getopt_long(argc, argv, "", shell_options, &shell_index) != -1) {
17338
if (shell_index==-1) {
17342
if (shell_seen[shell_index]==1) {
17343
fprintf(stderr, "Error, `--%s' argument given twice.\n",
17344
shell_options[shell_index].name);
17347
shell_seen[shell_index]=1;
17349
switch (shell_index) {
17350
case 0: /* graph */
17351
shell_read_graph(&graph, optarg);
17353
case 1: /* outstream */
17354
shell_read_file(&outstream, optarg, "w");
17357
shell_igraph_write_graph_graphml_usage(argv);
17366
/* Check that we have all arguments */
17367
for (shell_index=0; shell_index<2; shell_index++) {
17368
if (!shell_seen[shell_index]) {
17369
fprintf(stderr, "Error, argument missing: `--%s'.\n",
17370
shell_options[shell_index].name);
17375
/* Do the operation */
17376
shell_result=igraph_write_graph_graphml(&graph, outstream);
17378
/* Write the result */
17379
igraph_destroy(&graph);
17385
/*-------------------------------------------/
17386
/ igraph_write_graph_pajek /
17387
/-------------------------------------------*/
17388
void shell_igraph_write_graph_pajek_usage(char **argv) {
17389
printf("%s --graph=<graph> --outstream=<outstream>\n", basename(argv[0]));
17393
int shell_igraph_write_graph_pajek(int argc, char **argv) {
17401
int shell_index=-1;
17402
struct option shell_options[]= { { "graph",required_argument,0,0 },
17403
{ "outstream",required_argument,0,1 },
17404
{ "help",no_argument,0,2 },
17408
/* 0 - not seen, 1 - seen as argument, 2 - seen as default */
17409
memset(shell_seen, 0, 2*sizeof(int));
17412
/* Parse arguments and read input */
17413
while (getopt_long(argc, argv, "", shell_options, &shell_index) != -1) {
17415
if (shell_index==-1) {
17419
if (shell_seen[shell_index]==1) {
17420
fprintf(stderr, "Error, `--%s' argument given twice.\n",
17421
shell_options[shell_index].name);
17424
shell_seen[shell_index]=1;
17426
switch (shell_index) {
17427
case 0: /* graph */
17428
shell_read_graph(&graph, optarg);
17430
case 1: /* outstream */
17431
shell_read_file(&outstream, optarg, "w");
17434
shell_igraph_write_graph_pajek_usage(argv);
17443
/* Check that we have all arguments */
17444
for (shell_index=0; shell_index<2; shell_index++) {
17445
if (!shell_seen[shell_index]) {
17446
fprintf(stderr, "Error, argument missing: `--%s'.\n",
17447
shell_options[shell_index].name);
17452
/* Do the operation */
17453
shell_result=igraph_write_graph_pajek(&graph, outstream);
17455
/* Write the result */
17456
igraph_destroy(&graph);
17462
/*-------------------------------------------/
17463
/ igraph_write_graph_dimacs /
17464
/-------------------------------------------*/
17465
void shell_igraph_write_graph_dimacs_usage(char **argv) {
17466
printf("%s --graph=<graph> --outstream=<outstream> --source=<source> --target=<target> --capacity=<capacity>\n", basename(argv[0]));
17470
int shell_igraph_write_graph_dimacs(int argc, char **argv) {
17476
igraph_vector_t capacity;
17481
int shell_index=-1;
17482
struct option shell_options[]= { { "graph",required_argument,0,0 },
17483
{ "outstream",required_argument,0,1 },
17484
{ "source",required_argument,0,2 },
17485
{ "target",required_argument,0,3 },
17486
{ "capacity",required_argument,0,4 },
17487
{ "help",no_argument,0,5 },
17491
/* 0 - not seen, 1 - seen as argument, 2 - seen as default */
17492
memset(shell_seen, 0, 5*sizeof(int));
17496
/* Parse arguments and read input */
17497
while (getopt_long(argc, argv, "", shell_options, &shell_index) != -1) {
17499
if (shell_index==-1) {
17503
if (shell_seen[shell_index]==1) {
17504
fprintf(stderr, "Error, `--%s' argument given twice.\n",
17505
shell_options[shell_index].name);
17508
shell_seen[shell_index]=1;
17510
switch (shell_index) {
17511
case 0: /* graph */
17512
shell_read_graph(&graph, optarg);
17514
case 1: /* outstream */
17515
shell_read_file(&outstream, optarg, "w");
17517
case 2: /* source */
17518
shell_read_longint(&source, optarg);
17520
case 3: /* target */
17521
shell_read_longint(&target, optarg);
17523
case 4: /* capacity */
17524
shell_read_vector(&capacity, optarg);
17527
shell_igraph_write_graph_dimacs_usage(argv);
17536
/* Check that we have all arguments */
17537
for (shell_index=0; shell_index<5; shell_index++) {
17538
if (!shell_seen[shell_index]) {
17539
fprintf(stderr, "Error, argument missing: `--%s'.\n",
17540
shell_options[shell_index].name);
17545
/* Do the operation */
17546
shell_result=igraph_write_graph_dimacs(&graph, outstream, source, target, &capacity);
17548
/* Write the result */
17549
igraph_destroy(&graph);
17551
igraph_vector_destroy(&capacity);
17556
/*-------------------------------------------/
17557
/ igraph_write_graph_gml /
17558
/-------------------------------------------*/
17559
void shell_igraph_write_graph_gml_usage(char **argv) {
17560
printf("%s --graph=<graph> --outstream=<outstream> --id=<id> --creator=<creator>\n", basename(argv[0]));
17564
int shell_igraph_write_graph_gml(int argc, char **argv) {
17568
igraph_vector_t id;
17569
char * creator="igraph";
17574
int shell_index=-1;
17575
struct option shell_options[]= { { "graph",required_argument,0,0 },
17576
{ "outstream",required_argument,0,1 },
17577
{ "id",required_argument,0,2 },
17578
{ "creator",required_argument,0,3 },
17579
{ "help",no_argument,0,4 },
17583
/* 0 - not seen, 1 - seen as argument, 2 - seen as default */
17584
memset(shell_seen, 0, 4*sizeof(int));
17587
/* Parse arguments and read input */
17588
while (getopt_long(argc, argv, "", shell_options, &shell_index) != -1) {
17590
if (shell_index==-1) {
17594
if (shell_seen[shell_index]==1) {
17595
fprintf(stderr, "Error, `--%s' argument given twice.\n",
17596
shell_options[shell_index].name);
17599
shell_seen[shell_index]=1;
17601
switch (shell_index) {
17602
case 0: /* graph */
17603
shell_read_graph(&graph, optarg);
17605
case 1: /* outstream */
17606
shell_read_file(&outstream, optarg, "w");
17609
shell_read_vector(&id, optarg);
17611
case 3: /* creator */
17612
creator=strdup(optarg);
17615
shell_igraph_write_graph_gml_usage(argv);
17624
/* Check that we have all arguments */
17625
for (shell_index=0; shell_index<4; shell_index++) {
17626
if (!shell_seen[shell_index]) {
17627
fprintf(stderr, "Error, argument missing: `--%s'.\n",
17628
shell_options[shell_index].name);
17633
/* Do the operation */
17634
shell_result=igraph_write_graph_gml(&graph, outstream, &id, creator);
17636
/* Write the result */
17637
igraph_destroy(&graph);
17639
igraph_vector_destroy(&id);
17645
/*-------------------------------------------/
17646
/ igraph_write_graph_dot /
17647
/-------------------------------------------*/
17648
void shell_igraph_write_graph_dot_usage(char **argv) {
17649
printf("%s --graph=<graph> --outstream=<outstream>\n", basename(argv[0]));
17653
int shell_igraph_write_graph_dot(int argc, char **argv) {
17661
int shell_index=-1;
17662
struct option shell_options[]= { { "graph",required_argument,0,0 },
17663
{ "outstream",required_argument,0,1 },
17664
{ "help",no_argument,0,2 },
17668
/* 0 - not seen, 1 - seen as argument, 2 - seen as default */
17669
memset(shell_seen, 0, 2*sizeof(int));
17672
/* Parse arguments and read input */
17673
while (getopt_long(argc, argv, "", shell_options, &shell_index) != -1) {
17675
if (shell_index==-1) {
17679
if (shell_seen[shell_index]==1) {
17680
fprintf(stderr, "Error, `--%s' argument given twice.\n",
17681
shell_options[shell_index].name);
17684
shell_seen[shell_index]=1;
17686
switch (shell_index) {
17687
case 0: /* graph */
17688
shell_read_graph(&graph, optarg);
17690
case 1: /* outstream */
17691
shell_read_file(&outstream, optarg, "w");
17694
shell_igraph_write_graph_dot_usage(argv);
17703
/* Check that we have all arguments */
17704
for (shell_index=0; shell_index<2; shell_index++) {
17705
if (!shell_seen[shell_index]) {
17706
fprintf(stderr, "Error, argument missing: `--%s'.\n",
17707
shell_options[shell_index].name);
17712
/* Do the operation */
17713
shell_result=igraph_write_graph_dot(&graph, outstream);
17715
/* Write the result */
17716
igraph_destroy(&graph);
17722
/*-------------------------------------------/
17723
/ igraph_motifs_randesu /
17724
/-------------------------------------------*/
17725
void shell_igraph_motifs_randesu_usage(char **argv) {
17726
printf("%s --graph=<graph> --hist=<hist> --size=<size> --cut_prob=<cut_prob>\n", basename(argv[0]));
17730
int shell_igraph_motifs_randesu(int argc, char **argv) {
17733
igraph_vector_t hist;
17735
igraph_vector_t cut_prob;
17736
char* shell_arg_hist=0;
17741
int shell_index=-1;
17742
struct option shell_options[]= { { "graph",required_argument,0,0 },
17743
{ "hist",required_argument,0,1 },
17744
{ "size",required_argument,0,2 },
17745
{ "cut_prob",required_argument,0,3 },
17746
{ "help",no_argument,0,4 },
17750
/* 0 - not seen, 1 - seen as argument, 2 - seen as default */
17751
memset(shell_seen, 0, 4*sizeof(int));
17754
/* Parse arguments and read input */
17755
while (getopt_long(argc, argv, "", shell_options, &shell_index) != -1) {
17757
if (shell_index==-1) {
17761
if (shell_seen[shell_index]==1) {
17762
fprintf(stderr, "Error, `--%s' argument given twice.\n",
17763
shell_options[shell_index].name);
17766
shell_seen[shell_index]=1;
17768
switch (shell_index) {
17769
case 0: /* graph */
17770
shell_read_graph(&graph, optarg);
17773
shell_arg_hist=strdup(optarg);
17774
igraph_vector_init(&hist, 0);
17777
shell_read_int(&size, optarg);
17779
case 3: /* cut_prob */
17780
shell_read_vector(&cut_prob, optarg);
17783
shell_igraph_motifs_randesu_usage(argv);
17792
/* Check that we have all arguments */
17793
for (shell_index=0; shell_index<4; shell_index++) {
17794
if (!shell_seen[shell_index]) {
17795
fprintf(stderr, "Error, argument missing: `--%s'.\n",
17796
shell_options[shell_index].name);
17801
/* Do the operation */
17802
shell_result=igraph_motifs_randesu(&graph, &hist, size, &cut_prob);
17804
/* Write the result */
17805
igraph_destroy(&graph);
17806
shell_write_vector(&hist, shell_arg_hist);
17807
igraph_vector_destroy(&hist);
17808
igraph_vector_destroy(&cut_prob);
17813
/*-------------------------------------------/
17814
/ igraph_motifs_randesu_estimate /
17815
/-------------------------------------------*/
17816
void shell_igraph_motifs_randesu_estimate_usage(char **argv) {
17817
printf("%s --graph=<graph> --est=<est> --size=<size> --cut_prob=<cut_prob> --sample_size=<sample_size> --sample=<sample>\n", basename(argv[0]));
17821
int shell_igraph_motifs_randesu_estimate(int argc, char **argv) {
17824
igraph_integer_t est;
17826
igraph_vector_t cut_prob;
17827
igraph_integer_t sample_size;
17828
igraph_vector_t v_sample; igraph_vector_t *sample=0;
17829
char* shell_arg_est=0;
17834
int shell_index=-1;
17835
struct option shell_options[]= { { "graph",required_argument,0,0 },
17836
{ "est",required_argument,0,1 },
17837
{ "size",required_argument,0,2 },
17838
{ "cut_prob",required_argument,0,3 },
17839
{ "sample_size",required_argument,0,4 },
17840
{ "sample",required_argument,0,5 },
17841
{ "help",no_argument,0,6 },
17845
/* 0 - not seen, 1 - seen as argument, 2 - seen as default */
17846
memset(shell_seen, 0, 6*sizeof(int));
17849
/* Parse arguments and read input */
17850
while (getopt_long(argc, argv, "", shell_options, &shell_index) != -1) {
17852
if (shell_index==-1) {
17856
if (shell_seen[shell_index]==1) {
17857
fprintf(stderr, "Error, `--%s' argument given twice.\n",
17858
shell_options[shell_index].name);
17861
shell_seen[shell_index]=1;
17863
switch (shell_index) {
17864
case 0: /* graph */
17865
shell_read_graph(&graph, optarg);
17868
shell_arg_est=strdup(optarg);
17871
shell_read_int(&size, optarg);
17873
case 3: /* cut_prob */
17874
shell_read_vector(&cut_prob, optarg);
17876
case 4: /* sample_size */
17877
shell_read_integer(&sample_size, optarg);
17879
case 5: /* sample */
17880
sample=&v_sample; shell_read_vector(sample, optarg);
17883
shell_igraph_motifs_randesu_estimate_usage(argv);
17892
/* Check that we have all arguments */
17893
for (shell_index=0; shell_index<6; shell_index++) {
17894
if (!shell_seen[shell_index]) {
17895
fprintf(stderr, "Error, argument missing: `--%s'.\n",
17896
shell_options[shell_index].name);
17901
/* Do the operation */
17902
shell_result=igraph_motifs_randesu_estimate(&graph, &est, size, &cut_prob, sample_size, sample);
17904
/* Write the result */
17905
igraph_destroy(&graph);
17906
shell_write_integer(est, shell_arg_est);
17907
igraph_vector_destroy(&cut_prob);
17908
if (sample) { igraph_vector_destroy(sample); }
17913
/*-------------------------------------------/
17914
/ igraph_motifs_randesu_no /
17915
/-------------------------------------------*/
17916
void shell_igraph_motifs_randesu_no_usage(char **argv) {
17917
printf("%s --graph=<graph> --no=<no> --size=<size> --cut_prob=<cut_prob>\n", basename(argv[0]));
17921
int shell_igraph_motifs_randesu_no(int argc, char **argv) {
17924
igraph_integer_t no;
17926
igraph_vector_t cut_prob;
17927
char* shell_arg_no=0;
17932
int shell_index=-1;
17933
struct option shell_options[]= { { "graph",required_argument,0,0 },
17934
{ "no",required_argument,0,1 },
17935
{ "size",required_argument,0,2 },
17936
{ "cut_prob",required_argument,0,3 },
17937
{ "help",no_argument,0,4 },
17941
/* 0 - not seen, 1 - seen as argument, 2 - seen as default */
17942
memset(shell_seen, 0, 4*sizeof(int));
17945
/* Parse arguments and read input */
17946
while (getopt_long(argc, argv, "", shell_options, &shell_index) != -1) {
17948
if (shell_index==-1) {
17952
if (shell_seen[shell_index]==1) {
17953
fprintf(stderr, "Error, `--%s' argument given twice.\n",
17954
shell_options[shell_index].name);
17957
shell_seen[shell_index]=1;
17959
switch (shell_index) {
17960
case 0: /* graph */
17961
shell_read_graph(&graph, optarg);
17964
shell_arg_no=strdup(optarg);
17967
shell_read_int(&size, optarg);
17969
case 3: /* cut_prob */
17970
shell_read_vector(&cut_prob, optarg);
17973
shell_igraph_motifs_randesu_no_usage(argv);
17982
/* Check that we have all arguments */
17983
for (shell_index=0; shell_index<4; shell_index++) {
17984
if (!shell_seen[shell_index]) {
17985
fprintf(stderr, "Error, argument missing: `--%s'.\n",
17986
shell_options[shell_index].name);
17991
/* Do the operation */
17992
shell_result=igraph_motifs_randesu_no(&graph, &no, size, &cut_prob);
17994
/* Write the result */
17995
igraph_destroy(&graph);
17996
shell_write_integer(no, shell_arg_no);
17997
igraph_vector_destroy(&cut_prob);
18002
/*-------------------------------------------/
18003
/ igraph_dyad_census /
18004
/-------------------------------------------*/
18005
void shell_igraph_dyad_census_usage(char **argv) {
18006
printf("%s --graph=<graph> --mut=<mut> --asym=<asym> --null=<null>\n", basename(argv[0]));
18010
int shell_igraph_dyad_census(int argc, char **argv) {
18013
igraph_integer_t mut;
18014
igraph_integer_t asym;
18015
igraph_integer_t null;
18016
char* shell_arg_mut=0;
18017
char* shell_arg_asym=0;
18018
char* shell_arg_null=0;
18023
int shell_index=-1;
18024
struct option shell_options[]= { { "graph",required_argument,0,0 },
18025
{ "mut",required_argument,0,1 },
18026
{ "asym",required_argument,0,2 },
18027
{ "null",required_argument,0,3 },
18028
{ "help",no_argument,0,4 },
18032
/* 0 - not seen, 1 - seen as argument, 2 - seen as default */
18033
memset(shell_seen, 0, 4*sizeof(int));
18036
/* Parse arguments and read input */
18037
while (getopt_long(argc, argv, "", shell_options, &shell_index) != -1) {
18039
if (shell_index==-1) {
18043
if (shell_seen[shell_index]==1) {
18044
fprintf(stderr, "Error, `--%s' argument given twice.\n",
18045
shell_options[shell_index].name);
18048
shell_seen[shell_index]=1;
18050
switch (shell_index) {
18051
case 0: /* graph */
18052
shell_read_graph(&graph, optarg);
18055
shell_arg_mut=strdup(optarg);
18058
shell_arg_asym=strdup(optarg);
18061
shell_arg_null=strdup(optarg);
18064
shell_igraph_dyad_census_usage(argv);
18073
/* Check that we have all arguments */
18074
for (shell_index=0; shell_index<4; shell_index++) {
18075
if (!shell_seen[shell_index]) {
18076
fprintf(stderr, "Error, argument missing: `--%s'.\n",
18077
shell_options[shell_index].name);
18082
/* Do the operation */
18083
shell_result=igraph_dyad_census(&graph, &mut, &asym, &null);
18085
/* Write the result */
18086
igraph_destroy(&graph);
18087
shell_write_integer(mut, shell_arg_mut);
18088
shell_write_integer(asym, shell_arg_asym);
18089
shell_write_integer(null, shell_arg_null);
18094
/*-------------------------------------------/
18095
/ igraph_triad_census /
18096
/-------------------------------------------*/
18097
void shell_igraph_triad_census_usage(char **argv) {
18098
printf("%s --graph=<graph> --res=<res>\n", basename(argv[0]));
18102
int shell_igraph_triad_census(int argc, char **argv) {
18105
igraph_vector_t res;
18106
char* shell_arg_res=0;
18111
int shell_index=-1;
18112
struct option shell_options[]= { { "graph",required_argument,0,0 },
18113
{ "res",required_argument,0,1 },
18114
{ "help",no_argument,0,2 },
18118
/* 0 - not seen, 1 - seen as argument, 2 - seen as default */
18119
memset(shell_seen, 0, 2*sizeof(int));
18122
/* Parse arguments and read input */
18123
while (getopt_long(argc, argv, "", shell_options, &shell_index) != -1) {
18125
if (shell_index==-1) {
18129
if (shell_seen[shell_index]==1) {
18130
fprintf(stderr, "Error, `--%s' argument given twice.\n",
18131
shell_options[shell_index].name);
18134
shell_seen[shell_index]=1;
18136
switch (shell_index) {
18137
case 0: /* graph */
18138
shell_read_graph(&graph, optarg);
18141
shell_arg_res=strdup(optarg);
18142
igraph_vector_init(&res, 0);
18145
shell_igraph_triad_census_usage(argv);
18154
/* Check that we have all arguments */
18155
for (shell_index=0; shell_index<2; shell_index++) {
18156
if (!shell_seen[shell_index]) {
18157
fprintf(stderr, "Error, argument missing: `--%s'.\n",
18158
shell_options[shell_index].name);
18163
/* Do the operation */
18164
shell_result=igraph_triad_census(&graph, &res);
18166
/* Write the result */
18167
igraph_destroy(&graph);
18168
shell_write_vector(&res, shell_arg_res);
18169
igraph_vector_destroy(&res);
18174
/*-------------------------------------------/
18175
/ igraph_disjoint_union /
18176
/-------------------------------------------*/
18177
void shell_igraph_disjoint_union_usage(char **argv) {
18178
printf("%s --res=<res> --left=<left> --right=<right>\n", basename(argv[0]));
18182
int shell_igraph_disjoint_union(int argc, char **argv) {
18187
char* shell_arg_res=0;
18192
int shell_index=-1;
18193
struct option shell_options[]= { { "res",required_argument,0,0 },
18194
{ "left",required_argument,0,1 },
18195
{ "right",required_argument,0,2 },
18196
{ "help",no_argument,0,3 },
18200
/* 0 - not seen, 1 - seen as argument, 2 - seen as default */
18201
memset(shell_seen, 0, 3*sizeof(int));
18204
/* Parse arguments and read input */
18205
while (getopt_long(argc, argv, "", shell_options, &shell_index) != -1) {
18207
if (shell_index==-1) {
18211
if (shell_seen[shell_index]==1) {
18212
fprintf(stderr, "Error, `--%s' argument given twice.\n",
18213
shell_options[shell_index].name);
18216
shell_seen[shell_index]=1;
18218
switch (shell_index) {
18220
shell_arg_res=strdup(optarg);
18223
shell_read_graph(&left, optarg);
18225
case 2: /* right */
18226
shell_read_graph(&right, optarg);
18229
shell_igraph_disjoint_union_usage(argv);
18238
/* Check that we have all arguments */
18239
for (shell_index=0; shell_index<3; shell_index++) {
18240
if (!shell_seen[shell_index]) {
18241
fprintf(stderr, "Error, argument missing: `--%s'.\n",
18242
shell_options[shell_index].name);
18247
/* Do the operation */
18248
shell_result=igraph_disjoint_union(&res, &left, &right);
18250
/* Write the result */
18251
shell_write_graph(&res, shell_arg_res);
18252
igraph_destroy(&res);
18253
igraph_destroy(&left);
18254
igraph_destroy(&right);
18259
/*-------------------------------------------/
18260
/ igraph_disjoint_union_many /
18261
/-------------------------------------------*/
18262
void shell_igraph_disjoint_union_many_usage(char **argv) {
18263
printf("%s --res=<res> --graphs=<graphs>\n", basename(argv[0]));
18267
int shell_igraph_disjoint_union_many(int argc, char **argv) {
18270
igraph_vector_ptr_t graphs;
18271
char* shell_arg_res=0;
18276
int shell_index=-1;
18277
struct option shell_options[]= { { "res",required_argument,0,0 },
18278
{ "graphs",required_argument,0,1 },
18279
{ "help",no_argument,0,2 },
18283
/* 0 - not seen, 1 - seen as argument, 2 - seen as default */
18284
memset(shell_seen, 0, 2*sizeof(int));
18287
/* Parse arguments and read input */
18288
while (getopt_long(argc, argv, "", shell_options, &shell_index) != -1) {
18290
if (shell_index==-1) {
18294
if (shell_seen[shell_index]==1) {
18295
fprintf(stderr, "Error, `--%s' argument given twice.\n",
18296
shell_options[shell_index].name);
18299
shell_seen[shell_index]=1;
18301
switch (shell_index) {
18303
shell_arg_res=strdup(optarg);
18305
case 1: /* graphs */
18306
shell_read_graphlist(&graphs, optarg);
18309
shell_igraph_disjoint_union_many_usage(argv);
18318
/* Check that we have all arguments */
18319
for (shell_index=0; shell_index<2; shell_index++) {
18320
if (!shell_seen[shell_index]) {
18321
fprintf(stderr, "Error, argument missing: `--%s'.\n",
18322
shell_options[shell_index].name);
18327
/* Do the operation */
18328
shell_result=igraph_disjoint_union_many(&res, &graphs);
18330
/* Write the result */
18331
shell_write_graph(&res, shell_arg_res);
18332
igraph_destroy(&res);
18333
shell_free_graphlist(&graphs);
18334
igraph_vector_ptr_destroy(&graphs);
18339
/*-------------------------------------------/
18341
/-------------------------------------------*/
18342
void shell_igraph_union_usage(char **argv) {
18343
printf("%s --res=<res> --left=<left> --right=<right>\n", basename(argv[0]));
18347
int shell_igraph_union(int argc, char **argv) {
18352
char* shell_arg_res=0;
18357
int shell_index=-1;
18358
struct option shell_options[]= { { "res",required_argument,0,0 },
18359
{ "left",required_argument,0,1 },
18360
{ "right",required_argument,0,2 },
18361
{ "help",no_argument,0,3 },
18365
/* 0 - not seen, 1 - seen as argument, 2 - seen as default */
18366
memset(shell_seen, 0, 3*sizeof(int));
18369
/* Parse arguments and read input */
18370
while (getopt_long(argc, argv, "", shell_options, &shell_index) != -1) {
18372
if (shell_index==-1) {
18376
if (shell_seen[shell_index]==1) {
18377
fprintf(stderr, "Error, `--%s' argument given twice.\n",
18378
shell_options[shell_index].name);
18381
shell_seen[shell_index]=1;
18383
switch (shell_index) {
18385
shell_arg_res=strdup(optarg);
18388
shell_read_graph(&left, optarg);
18390
case 2: /* right */
18391
shell_read_graph(&right, optarg);
18394
shell_igraph_union_usage(argv);
18403
/* Check that we have all arguments */
18404
for (shell_index=0; shell_index<3; shell_index++) {
18405
if (!shell_seen[shell_index]) {
18406
fprintf(stderr, "Error, argument missing: `--%s'.\n",
18407
shell_options[shell_index].name);
18412
/* Do the operation */
18413
shell_result=igraph_union(&res, &left, &right);
18415
/* Write the result */
18416
shell_write_graph(&res, shell_arg_res);
18417
igraph_destroy(&res);
18418
igraph_destroy(&left);
18419
igraph_destroy(&right);
18424
/*-------------------------------------------/
18425
/ igraph_union_many /
18426
/-------------------------------------------*/
18427
void shell_igraph_union_many_usage(char **argv) {
18428
printf("%s --res=<res> --graphs=<graphs>\n", basename(argv[0]));
18432
int shell_igraph_union_many(int argc, char **argv) {
18435
igraph_vector_ptr_t graphs;
18436
char* shell_arg_res=0;
18441
int shell_index=-1;
18442
struct option shell_options[]= { { "res",required_argument,0,0 },
18443
{ "graphs",required_argument,0,1 },
18444
{ "help",no_argument,0,2 },
18448
/* 0 - not seen, 1 - seen as argument, 2 - seen as default */
18449
memset(shell_seen, 0, 2*sizeof(int));
18452
/* Parse arguments and read input */
18453
while (getopt_long(argc, argv, "", shell_options, &shell_index) != -1) {
18455
if (shell_index==-1) {
18459
if (shell_seen[shell_index]==1) {
18460
fprintf(stderr, "Error, `--%s' argument given twice.\n",
18461
shell_options[shell_index].name);
18464
shell_seen[shell_index]=1;
18466
switch (shell_index) {
18468
shell_arg_res=strdup(optarg);
18470
case 1: /* graphs */
18471
shell_read_graphlist(&graphs, optarg);
18474
shell_igraph_union_many_usage(argv);
18483
/* Check that we have all arguments */
18484
for (shell_index=0; shell_index<2; shell_index++) {
18485
if (!shell_seen[shell_index]) {
18486
fprintf(stderr, "Error, argument missing: `--%s'.\n",
18487
shell_options[shell_index].name);
18492
/* Do the operation */
18493
shell_result=igraph_union_many(&res, &graphs);
18495
/* Write the result */
18496
shell_write_graph(&res, shell_arg_res);
18497
igraph_destroy(&res);
18498
shell_free_graphlist(&graphs);
18499
igraph_vector_ptr_destroy(&graphs);
18504
/*-------------------------------------------/
18505
/ igraph_intersection /
18506
/-------------------------------------------*/
18507
void shell_igraph_intersection_usage(char **argv) {
18508
printf("%s --res=<res> --left=<left> --right=<right>\n", basename(argv[0]));
18512
int shell_igraph_intersection(int argc, char **argv) {
18517
char* shell_arg_res=0;
18522
int shell_index=-1;
18523
struct option shell_options[]= { { "res",required_argument,0,0 },
18524
{ "left",required_argument,0,1 },
18525
{ "right",required_argument,0,2 },
18526
{ "help",no_argument,0,3 },
18530
/* 0 - not seen, 1 - seen as argument, 2 - seen as default */
18531
memset(shell_seen, 0, 3*sizeof(int));
18534
/* Parse arguments and read input */
18535
while (getopt_long(argc, argv, "", shell_options, &shell_index) != -1) {
18537
if (shell_index==-1) {
18541
if (shell_seen[shell_index]==1) {
18542
fprintf(stderr, "Error, `--%s' argument given twice.\n",
18543
shell_options[shell_index].name);
18546
shell_seen[shell_index]=1;
18548
switch (shell_index) {
18550
shell_arg_res=strdup(optarg);
18553
shell_read_graph(&left, optarg);
18555
case 2: /* right */
18556
shell_read_graph(&right, optarg);
18559
shell_igraph_intersection_usage(argv);
18568
/* Check that we have all arguments */
18569
for (shell_index=0; shell_index<3; shell_index++) {
18570
if (!shell_seen[shell_index]) {
18571
fprintf(stderr, "Error, argument missing: `--%s'.\n",
18572
shell_options[shell_index].name);
18577
/* Do the operation */
18578
shell_result=igraph_intersection(&res, &left, &right);
18580
/* Write the result */
18581
shell_write_graph(&res, shell_arg_res);
18582
igraph_destroy(&res);
18583
igraph_destroy(&left);
18584
igraph_destroy(&right);
18589
/*-------------------------------------------/
18590
/ igraph_intersection_many /
18591
/-------------------------------------------*/
18592
void shell_igraph_intersection_many_usage(char **argv) {
18593
printf("%s --res=<res> --graphs=<graphs>\n", basename(argv[0]));
18597
int shell_igraph_intersection_many(int argc, char **argv) {
18600
igraph_vector_ptr_t graphs;
18601
char* shell_arg_res=0;
18606
int shell_index=-1;
18607
struct option shell_options[]= { { "res",required_argument,0,0 },
18608
{ "graphs",required_argument,0,1 },
18609
{ "help",no_argument,0,2 },
18613
/* 0 - not seen, 1 - seen as argument, 2 - seen as default */
18614
memset(shell_seen, 0, 2*sizeof(int));
18617
/* Parse arguments and read input */
18618
while (getopt_long(argc, argv, "", shell_options, &shell_index) != -1) {
18620
if (shell_index==-1) {
18624
if (shell_seen[shell_index]==1) {
18625
fprintf(stderr, "Error, `--%s' argument given twice.\n",
18626
shell_options[shell_index].name);
18629
shell_seen[shell_index]=1;
18631
switch (shell_index) {
18633
shell_arg_res=strdup(optarg);
18635
case 1: /* graphs */
18636
shell_read_graphlist(&graphs, optarg);
18639
shell_igraph_intersection_many_usage(argv);
18648
/* Check that we have all arguments */
18649
for (shell_index=0; shell_index<2; shell_index++) {
18650
if (!shell_seen[shell_index]) {
18651
fprintf(stderr, "Error, argument missing: `--%s'.\n",
18652
shell_options[shell_index].name);
18657
/* Do the operation */
18658
shell_result=igraph_intersection_many(&res, &graphs);
18660
/* Write the result */
18661
shell_write_graph(&res, shell_arg_res);
18662
igraph_destroy(&res);
18663
shell_free_graphlist(&graphs);
18664
igraph_vector_ptr_destroy(&graphs);
18669
/*-------------------------------------------/
18670
/ igraph_difference /
18671
/-------------------------------------------*/
18672
void shell_igraph_difference_usage(char **argv) {
18673
printf("%s --res=<res> --orig=<orig> --sub=<sub>\n", basename(argv[0]));
18677
int shell_igraph_difference(int argc, char **argv) {
18682
char* shell_arg_res=0;
18687
int shell_index=-1;
18688
struct option shell_options[]= { { "res",required_argument,0,0 },
18689
{ "orig",required_argument,0,1 },
18690
{ "sub",required_argument,0,2 },
18691
{ "help",no_argument,0,3 },
18695
/* 0 - not seen, 1 - seen as argument, 2 - seen as default */
18696
memset(shell_seen, 0, 3*sizeof(int));
18699
/* Parse arguments and read input */
18700
while (getopt_long(argc, argv, "", shell_options, &shell_index) != -1) {
18702
if (shell_index==-1) {
18706
if (shell_seen[shell_index]==1) {
18707
fprintf(stderr, "Error, `--%s' argument given twice.\n",
18708
shell_options[shell_index].name);
18711
shell_seen[shell_index]=1;
18713
switch (shell_index) {
18715
shell_arg_res=strdup(optarg);
18718
shell_read_graph(&orig, optarg);
18721
shell_read_graph(&sub, optarg);
18724
shell_igraph_difference_usage(argv);
18733
/* Check that we have all arguments */
18734
for (shell_index=0; shell_index<3; shell_index++) {
18735
if (!shell_seen[shell_index]) {
18736
fprintf(stderr, "Error, argument missing: `--%s'.\n",
18737
shell_options[shell_index].name);
18742
/* Do the operation */
18743
shell_result=igraph_difference(&res, &orig, &sub);
18745
/* Write the result */
18746
shell_write_graph(&res, shell_arg_res);
18747
igraph_destroy(&res);
18748
igraph_destroy(&orig);
18749
igraph_destroy(&sub);
18754
/*-------------------------------------------/
18755
/ igraph_complementer /
18756
/-------------------------------------------*/
18757
void shell_igraph_complementer_usage(char **argv) {
18758
printf("%s --res=<res> --graph=<graph> --loops=<loops>\n", basename(argv[0]));
18762
int shell_igraph_complementer(int argc, char **argv) {
18766
igraph_bool_t loops=0;
18767
char* shell_arg_res=0;
18772
int shell_index=-1;
18773
struct option shell_options[]= { { "res",required_argument,0,0 },
18774
{ "graph",required_argument,0,1 },
18775
{ "loops",required_argument,0,2 },
18776
{ "help",no_argument,0,3 },
18780
/* 0 - not seen, 1 - seen as argument, 2 - seen as default */
18781
memset(shell_seen, 0, 3*sizeof(int));
18784
/* Parse arguments and read input */
18785
while (getopt_long(argc, argv, "", shell_options, &shell_index) != -1) {
18787
if (shell_index==-1) {
18791
if (shell_seen[shell_index]==1) {
18792
fprintf(stderr, "Error, `--%s' argument given twice.\n",
18793
shell_options[shell_index].name);
18796
shell_seen[shell_index]=1;
18798
switch (shell_index) {
18800
shell_arg_res=strdup(optarg);
18802
case 1: /* graph */
18803
shell_read_graph(&graph, optarg);
18805
case 2: /* loops */
18806
shell_read_boolean(&loops, optarg);
18809
shell_igraph_complementer_usage(argv);
18818
/* Check that we have all arguments */
18819
for (shell_index=0; shell_index<3; shell_index++) {
18820
if (!shell_seen[shell_index]) {
18821
fprintf(stderr, "Error, argument missing: `--%s'.\n",
18822
shell_options[shell_index].name);
18827
/* Do the operation */
18828
shell_result=igraph_complementer(&res, &graph, loops);
18830
/* Write the result */
18831
shell_write_graph(&res, shell_arg_res);
18832
igraph_destroy(&res);
18833
igraph_destroy(&graph);
18838
/*-------------------------------------------/
18840
/-------------------------------------------*/
18841
void shell_igraph_compose_usage(char **argv) {
18842
printf("%s --res=<res> --g1=<g1> --g2=<g2>\n", basename(argv[0]));
18846
int shell_igraph_compose(int argc, char **argv) {
18851
char* shell_arg_res=0;
18856
int shell_index=-1;
18857
struct option shell_options[]= { { "res",required_argument,0,0 },
18858
{ "g1",required_argument,0,1 },
18859
{ "g2",required_argument,0,2 },
18860
{ "help",no_argument,0,3 },
18864
/* 0 - not seen, 1 - seen as argument, 2 - seen as default */
18865
memset(shell_seen, 0, 3*sizeof(int));
18868
/* Parse arguments and read input */
18869
while (getopt_long(argc, argv, "", shell_options, &shell_index) != -1) {
18871
if (shell_index==-1) {
18875
if (shell_seen[shell_index]==1) {
18876
fprintf(stderr, "Error, `--%s' argument given twice.\n",
18877
shell_options[shell_index].name);
18880
shell_seen[shell_index]=1;
18882
switch (shell_index) {
18884
shell_arg_res=strdup(optarg);
18887
shell_read_graph(&g1, optarg);
18890
shell_read_graph(&g2, optarg);
18893
shell_igraph_compose_usage(argv);
18902
/* Check that we have all arguments */
18903
for (shell_index=0; shell_index<3; shell_index++) {
18904
if (!shell_seen[shell_index]) {
18905
fprintf(stderr, "Error, argument missing: `--%s'.\n",
18906
shell_options[shell_index].name);
18911
/* Do the operation */
18912
shell_result=igraph_compose(&res, &g1, &g2);
18914
/* Write the result */
18915
shell_write_graph(&res, shell_arg_res);
18916
igraph_destroy(&res);
18917
igraph_destroy(&g1);
18918
igraph_destroy(&g2);
18923
/*-------------------------------------------/
18924
/ igraph_maxflow_value /
18925
/-------------------------------------------*/
18926
void shell_igraph_maxflow_value_usage(char **argv) {
18927
printf("%s --graph=<graph> --value=<value> --source=<source> --target=<target> --capacity=<capacity>\n", basename(argv[0]));
18931
int shell_igraph_maxflow_value(int argc, char **argv) {
18934
igraph_real_t value;
18935
igraph_integer_t source;
18936
igraph_integer_t target;
18937
igraph_vector_t v_capacity; igraph_vector_t *capacity=0;
18938
char* shell_arg_value=0;
18943
int shell_index=-1;
18944
struct option shell_options[]= { { "graph",required_argument,0,0 },
18945
{ "value",required_argument,0,1 },
18946
{ "source",required_argument,0,2 },
18947
{ "target",required_argument,0,3 },
18948
{ "capacity",required_argument,0,4 },
18949
{ "help",no_argument,0,5 },
18953
/* 0 - not seen, 1 - seen as argument, 2 - seen as default */
18954
memset(shell_seen, 0, 5*sizeof(int));
18957
/* Parse arguments and read input */
18958
while (getopt_long(argc, argv, "", shell_options, &shell_index) != -1) {
18960
if (shell_index==-1) {
18964
if (shell_seen[shell_index]==1) {
18965
fprintf(stderr, "Error, `--%s' argument given twice.\n",
18966
shell_options[shell_index].name);
18969
shell_seen[shell_index]=1;
18971
switch (shell_index) {
18972
case 0: /* graph */
18973
shell_read_graph(&graph, optarg);
18975
case 1: /* value */
18976
shell_arg_value=strdup(optarg);
18978
case 2: /* source */
18979
shell_read_integer(&source, optarg);
18981
case 3: /* target */
18982
shell_read_integer(&target, optarg);
18984
case 4: /* capacity */
18985
capacity=&v_capacity; shell_read_vector(capacity, optarg);
18988
shell_igraph_maxflow_value_usage(argv);
18997
/* Check that we have all arguments */
18998
for (shell_index=0; shell_index<5; shell_index++) {
18999
if (!shell_seen[shell_index]) {
19000
fprintf(stderr, "Error, argument missing: `--%s'.\n",
19001
shell_options[shell_index].name);
19006
/* Do the operation */
19007
shell_result=igraph_maxflow_value(&graph, &value, source, target, capacity);
19009
/* Write the result */
19010
igraph_destroy(&graph);
19011
shell_write_real(value, shell_arg_value);
19012
if (capacity) { igraph_vector_destroy(capacity); }
19017
/*-------------------------------------------/
19018
/ igraph_mincut_value /
19019
/-------------------------------------------*/
19020
void shell_igraph_mincut_value_usage(char **argv) {
19021
printf("%s --graph=<graph> --res=<res> --capacity=<capacity>\n", basename(argv[0]));
19025
int shell_igraph_mincut_value(int argc, char **argv) {
19029
igraph_vector_t v_capacity; igraph_vector_t *capacity=0;
19030
char* shell_arg_res=0;
19035
int shell_index=-1;
19036
struct option shell_options[]= { { "graph",required_argument,0,0 },
19037
{ "res",required_argument,0,1 },
19038
{ "capacity",required_argument,0,2 },
19039
{ "help",no_argument,0,3 },
19043
/* 0 - not seen, 1 - seen as argument, 2 - seen as default */
19044
memset(shell_seen, 0, 3*sizeof(int));
19047
/* Parse arguments and read input */
19048
while (getopt_long(argc, argv, "", shell_options, &shell_index) != -1) {
19050
if (shell_index==-1) {
19054
if (shell_seen[shell_index]==1) {
19055
fprintf(stderr, "Error, `--%s' argument given twice.\n",
19056
shell_options[shell_index].name);
19059
shell_seen[shell_index]=1;
19061
switch (shell_index) {
19062
case 0: /* graph */
19063
shell_read_graph(&graph, optarg);
19066
shell_arg_res=strdup(optarg);
19068
case 2: /* capacity */
19069
capacity=&v_capacity; shell_read_vector(capacity, optarg);
19072
shell_igraph_mincut_value_usage(argv);
19081
/* Check that we have all arguments */
19082
for (shell_index=0; shell_index<3; shell_index++) {
19083
if (!shell_seen[shell_index]) {
19084
fprintf(stderr, "Error, argument missing: `--%s'.\n",
19085
shell_options[shell_index].name);
19090
/* Do the operation */
19091
shell_result=igraph_mincut_value(&graph, &res, capacity);
19093
/* Write the result */
19094
igraph_destroy(&graph);
19095
shell_write_real(res, shell_arg_res);
19096
if (capacity) { igraph_vector_destroy(capacity); }
19101
/*-------------------------------------------/
19102
/ igraph_st_mincut_value /
19103
/-------------------------------------------*/
19104
void shell_igraph_st_mincut_value_usage(char **argv) {
19105
printf("%s --graph=<graph> --res=<res> --source=<source> --target=<target> --capacity=<capacity>\n", basename(argv[0]));
19109
int shell_igraph_st_mincut_value(int argc, char **argv) {
19113
igraph_integer_t source;
19114
igraph_integer_t target;
19115
igraph_vector_t v_capacity; igraph_vector_t *capacity=0;
19116
char* shell_arg_res=0;
19121
int shell_index=-1;
19122
struct option shell_options[]= { { "graph",required_argument,0,0 },
19123
{ "res",required_argument,0,1 },
19124
{ "source",required_argument,0,2 },
19125
{ "target",required_argument,0,3 },
19126
{ "capacity",required_argument,0,4 },
19127
{ "help",no_argument,0,5 },
19131
/* 0 - not seen, 1 - seen as argument, 2 - seen as default */
19132
memset(shell_seen, 0, 5*sizeof(int));
19135
/* Parse arguments and read input */
19136
while (getopt_long(argc, argv, "", shell_options, &shell_index) != -1) {
19138
if (shell_index==-1) {
19142
if (shell_seen[shell_index]==1) {
19143
fprintf(stderr, "Error, `--%s' argument given twice.\n",
19144
shell_options[shell_index].name);
19147
shell_seen[shell_index]=1;
19149
switch (shell_index) {
19150
case 0: /* graph */
19151
shell_read_graph(&graph, optarg);
19154
shell_arg_res=strdup(optarg);
19156
case 2: /* source */
19157
shell_read_integer(&source, optarg);
19159
case 3: /* target */
19160
shell_read_integer(&target, optarg);
19162
case 4: /* capacity */
19163
capacity=&v_capacity; shell_read_vector(capacity, optarg);
19166
shell_igraph_st_mincut_value_usage(argv);
19175
/* Check that we have all arguments */
19176
for (shell_index=0; shell_index<5; shell_index++) {
19177
if (!shell_seen[shell_index]) {
19178
fprintf(stderr, "Error, argument missing: `--%s'.\n",
19179
shell_options[shell_index].name);
19184
/* Do the operation */
19185
shell_result=igraph_st_mincut_value(&graph, &res, source, target, capacity);
19187
/* Write the result */
19188
igraph_destroy(&graph);
19189
shell_write_real(res, shell_arg_res);
19190
if (capacity) { igraph_vector_destroy(capacity); }
19195
/*-------------------------------------------/
19197
/-------------------------------------------*/
19198
void shell_igraph_mincut_usage(char **argv) {
19199
printf("%s --graph=<graph> --value=<value> --partition=<partition> --partition2=<partition2> --cut=<cut> --capacity=<capacity>\n", basename(argv[0]));
19203
int shell_igraph_mincut(int argc, char **argv) {
19206
igraph_real_t value;
19207
igraph_vector_t partition;
19208
igraph_vector_t partition2;
19209
igraph_vector_t cut;
19210
igraph_vector_t v_capacity; igraph_vector_t *capacity=0;
19211
char* shell_arg_value=0;
19212
char* shell_arg_partition=0;
19213
char* shell_arg_partition2=0;
19214
char* shell_arg_cut=0;
19219
int shell_index=-1;
19220
struct option shell_options[]= { { "graph",required_argument,0,0 },
19221
{ "value",required_argument,0,1 },
19222
{ "partition",required_argument,0,2 },
19223
{ "partition2",required_argument,0,3 },
19224
{ "cut",required_argument,0,4 },
19225
{ "capacity",required_argument,0,5 },
19226
{ "help",no_argument,0,6 },
19230
/* 0 - not seen, 1 - seen as argument, 2 - seen as default */
19231
memset(shell_seen, 0, 6*sizeof(int));
19234
/* Parse arguments and read input */
19235
while (getopt_long(argc, argv, "", shell_options, &shell_index) != -1) {
19237
if (shell_index==-1) {
19241
if (shell_seen[shell_index]==1) {
19242
fprintf(stderr, "Error, `--%s' argument given twice.\n",
19243
shell_options[shell_index].name);
19246
shell_seen[shell_index]=1;
19248
switch (shell_index) {
19249
case 0: /* graph */
19250
shell_read_graph(&graph, optarg);
19252
case 1: /* value */
19253
shell_arg_value=strdup(optarg);
19255
case 2: /* partition */
19256
shell_arg_partition=strdup(optarg);
19257
igraph_vector_init(&partition, 0);
19259
case 3: /* partition2 */
19260
shell_arg_partition2=strdup(optarg);
19261
igraph_vector_init(&partition2, 0);
19264
shell_arg_cut=strdup(optarg);
19265
igraph_vector_init(&cut, 0);
19267
case 5: /* capacity */
19268
capacity=&v_capacity; shell_read_vector(capacity, optarg);
19271
shell_igraph_mincut_usage(argv);
19280
/* Check that we have all arguments */
19281
for (shell_index=0; shell_index<6; shell_index++) {
19282
if (!shell_seen[shell_index]) {
19283
fprintf(stderr, "Error, argument missing: `--%s'.\n",
19284
shell_options[shell_index].name);
19289
/* Do the operation */
19290
shell_result=igraph_mincut(&graph, &value, &partition, &partition2, &cut, capacity);
19292
/* Write the result */
19293
igraph_destroy(&graph);
19294
shell_write_real(value, shell_arg_value);
19295
shell_write_vector(&partition, shell_arg_partition);
19296
igraph_vector_destroy(&partition);
19297
shell_write_vector(&partition2, shell_arg_partition2);
19298
igraph_vector_destroy(&partition2);
19299
shell_write_vector(&cut, shell_arg_cut);
19300
igraph_vector_destroy(&cut);
19301
if (capacity) { igraph_vector_destroy(capacity); }
19306
/*-------------------------------------------/
19307
/ igraph_st_vertex_connectivity /
19308
/-------------------------------------------*/
19309
void shell_igraph_st_vertex_connectivity_usage(char **argv) {
19310
printf("%s --graph=<graph> --res=<res> --source=<source> --target=<target> --neighbors=<neighbors>\n", basename(argv[0]));
19314
int shell_igraph_st_vertex_connectivity(int argc, char **argv) {
19317
igraph_integer_t res;
19318
igraph_integer_t source;
19319
igraph_integer_t target;
19320
igraph_vconn_nei_t neighbors=IGRAPH_VCONN_NEI_INFINITY;
19321
char* shell_arg_res=0;
19326
int shell_index=-1;
19327
struct option shell_options[]= { { "graph",required_argument,0,0 },
19328
{ "res",required_argument,0,1 },
19329
{ "source",required_argument,0,2 },
19330
{ "target",required_argument,0,3 },
19331
{ "neighbors",required_argument,0,4 },
19332
{ "help",no_argument,0,5 },
19336
/* 0 - not seen, 1 - seen as argument, 2 - seen as default */
19337
memset(shell_seen, 0, 5*sizeof(int));
19340
/* Parse arguments and read input */
19341
while (getopt_long(argc, argv, "", shell_options, &shell_index) != -1) {
19343
if (shell_index==-1) {
19347
if (shell_seen[shell_index]==1) {
19348
fprintf(stderr, "Error, `--%s' argument given twice.\n",
19349
shell_options[shell_index].name);
19352
shell_seen[shell_index]=1;
19354
switch (shell_index) {
19355
case 0: /* graph */
19356
shell_read_graph(&graph, optarg);
19359
shell_arg_res=strdup(optarg);
19361
case 2: /* source */
19362
shell_read_integer(&source, optarg);
19364
case 3: /* target */
19365
shell_read_integer(&target, optarg);
19367
case 4: /* neighbors */
19368
shell_read_enum(&neighbors, optarg, "error", 0, "infinity", 1, "ignore", 2, 0);
19371
shell_igraph_st_vertex_connectivity_usage(argv);
19380
/* Check that we have all arguments */
19381
for (shell_index=0; shell_index<5; shell_index++) {
19382
if (!shell_seen[shell_index]) {
19383
fprintf(stderr, "Error, argument missing: `--%s'.\n",
19384
shell_options[shell_index].name);
19389
/* Do the operation */
19390
shell_result=igraph_st_vertex_connectivity(&graph, &res, source, target, neighbors);
19392
/* Write the result */
19393
igraph_destroy(&graph);
19394
shell_write_integer(res, shell_arg_res);
19399
/*-------------------------------------------/
19400
/ igraph_vertex_connectivity /
19401
/-------------------------------------------*/
19402
void shell_igraph_vertex_connectivity_usage(char **argv) {
19403
printf("%s --graph=<graph> --res=<res> --checks=<checks>\n", basename(argv[0]));
19407
int shell_igraph_vertex_connectivity(int argc, char **argv) {
19410
igraph_integer_t res;
19411
igraph_bool_t checks=1;
19412
char* shell_arg_res=0;
19417
int shell_index=-1;
19418
struct option shell_options[]= { { "graph",required_argument,0,0 },
19419
{ "res",required_argument,0,1 },
19420
{ "checks",required_argument,0,2 },
19421
{ "help",no_argument,0,3 },
19425
/* 0 - not seen, 1 - seen as argument, 2 - seen as default */
19426
memset(shell_seen, 0, 3*sizeof(int));
19429
/* Parse arguments and read input */
19430
while (getopt_long(argc, argv, "", shell_options, &shell_index) != -1) {
19432
if (shell_index==-1) {
19436
if (shell_seen[shell_index]==1) {
19437
fprintf(stderr, "Error, `--%s' argument given twice.\n",
19438
shell_options[shell_index].name);
19441
shell_seen[shell_index]=1;
19443
switch (shell_index) {
19444
case 0: /* graph */
19445
shell_read_graph(&graph, optarg);
19448
shell_arg_res=strdup(optarg);
19450
case 2: /* checks */
19451
shell_read_boolean(&checks, optarg);
19454
shell_igraph_vertex_connectivity_usage(argv);
19463
/* Check that we have all arguments */
19464
for (shell_index=0; shell_index<3; shell_index++) {
19465
if (!shell_seen[shell_index]) {
19466
fprintf(stderr, "Error, argument missing: `--%s'.\n",
19467
shell_options[shell_index].name);
19472
/* Do the operation */
19473
shell_result=igraph_vertex_connectivity(&graph, &res, checks);
19475
/* Write the result */
19476
igraph_destroy(&graph);
19477
shell_write_integer(res, shell_arg_res);
19482
/*-------------------------------------------/
19483
/ igraph_st_edge_connectivity /
19484
/-------------------------------------------*/
19485
void shell_igraph_st_edge_connectivity_usage(char **argv) {
19486
printf("%s --graph=<graph> --res=<res> --source=<source> --target=<target>\n", basename(argv[0]));
19490
int shell_igraph_st_edge_connectivity(int argc, char **argv) {
19493
igraph_integer_t res;
19494
igraph_integer_t source;
19495
igraph_integer_t target;
19496
char* shell_arg_res=0;
19501
int shell_index=-1;
19502
struct option shell_options[]= { { "graph",required_argument,0,0 },
19503
{ "res",required_argument,0,1 },
19504
{ "source",required_argument,0,2 },
19505
{ "target",required_argument,0,3 },
19506
{ "help",no_argument,0,4 },
19510
/* 0 - not seen, 1 - seen as argument, 2 - seen as default */
19511
memset(shell_seen, 0, 4*sizeof(int));
19514
/* Parse arguments and read input */
19515
while (getopt_long(argc, argv, "", shell_options, &shell_index) != -1) {
19517
if (shell_index==-1) {
19521
if (shell_seen[shell_index]==1) {
19522
fprintf(stderr, "Error, `--%s' argument given twice.\n",
19523
shell_options[shell_index].name);
19526
shell_seen[shell_index]=1;
19528
switch (shell_index) {
19529
case 0: /* graph */
19530
shell_read_graph(&graph, optarg);
19533
shell_arg_res=strdup(optarg);
19535
case 2: /* source */
19536
shell_read_integer(&source, optarg);
19538
case 3: /* target */
19539
shell_read_integer(&target, optarg);
19542
shell_igraph_st_edge_connectivity_usage(argv);
19551
/* Check that we have all arguments */
19552
for (shell_index=0; shell_index<4; shell_index++) {
19553
if (!shell_seen[shell_index]) {
19554
fprintf(stderr, "Error, argument missing: `--%s'.\n",
19555
shell_options[shell_index].name);
19560
/* Do the operation */
19561
shell_result=igraph_st_edge_connectivity(&graph, &res, source, target);
19563
/* Write the result */
19564
igraph_destroy(&graph);
19565
shell_write_integer(res, shell_arg_res);
19570
/*-------------------------------------------/
19571
/ igraph_edge_connectivity /
19572
/-------------------------------------------*/
19573
void shell_igraph_edge_connectivity_usage(char **argv) {
19574
printf("%s --graph=<graph> --res=<res> --checks=<checks>\n", basename(argv[0]));
19578
int shell_igraph_edge_connectivity(int argc, char **argv) {
19581
igraph_integer_t res;
19582
igraph_bool_t checks=1;
19583
char* shell_arg_res=0;
19588
int shell_index=-1;
19589
struct option shell_options[]= { { "graph",required_argument,0,0 },
19590
{ "res",required_argument,0,1 },
19591
{ "checks",required_argument,0,2 },
19592
{ "help",no_argument,0,3 },
19596
/* 0 - not seen, 1 - seen as argument, 2 - seen as default */
19597
memset(shell_seen, 0, 3*sizeof(int));
19600
/* Parse arguments and read input */
19601
while (getopt_long(argc, argv, "", shell_options, &shell_index) != -1) {
19603
if (shell_index==-1) {
19607
if (shell_seen[shell_index]==1) {
19608
fprintf(stderr, "Error, `--%s' argument given twice.\n",
19609
shell_options[shell_index].name);
19612
shell_seen[shell_index]=1;
19614
switch (shell_index) {
19615
case 0: /* graph */
19616
shell_read_graph(&graph, optarg);
19619
shell_arg_res=strdup(optarg);
19621
case 2: /* checks */
19622
shell_read_boolean(&checks, optarg);
19625
shell_igraph_edge_connectivity_usage(argv);
19634
/* Check that we have all arguments */
19635
for (shell_index=0; shell_index<3; shell_index++) {
19636
if (!shell_seen[shell_index]) {
19637
fprintf(stderr, "Error, argument missing: `--%s'.\n",
19638
shell_options[shell_index].name);
19643
/* Do the operation */
19644
shell_result=igraph_edge_connectivity(&graph, &res, checks);
19646
/* Write the result */
19647
igraph_destroy(&graph);
19648
shell_write_integer(res, shell_arg_res);
19653
/*-------------------------------------------/
19654
/ igraph_edge_disjoint_paths /
19655
/-------------------------------------------*/
19656
void shell_igraph_edge_disjoint_paths_usage(char **argv) {
19657
printf("%s --graph=<graph> --res=<res> --source=<source> --target=<target>\n", basename(argv[0]));
19661
int shell_igraph_edge_disjoint_paths(int argc, char **argv) {
19664
igraph_integer_t res;
19665
igraph_integer_t source;
19666
igraph_integer_t target;
19667
char* shell_arg_res=0;
19672
int shell_index=-1;
19673
struct option shell_options[]= { { "graph",required_argument,0,0 },
19674
{ "res",required_argument,0,1 },
19675
{ "source",required_argument,0,2 },
19676
{ "target",required_argument,0,3 },
19677
{ "help",no_argument,0,4 },
19681
/* 0 - not seen, 1 - seen as argument, 2 - seen as default */
19682
memset(shell_seen, 0, 4*sizeof(int));
19685
/* Parse arguments and read input */
19686
while (getopt_long(argc, argv, "", shell_options, &shell_index) != -1) {
19688
if (shell_index==-1) {
19692
if (shell_seen[shell_index]==1) {
19693
fprintf(stderr, "Error, `--%s' argument given twice.\n",
19694
shell_options[shell_index].name);
19697
shell_seen[shell_index]=1;
19699
switch (shell_index) {
19700
case 0: /* graph */
19701
shell_read_graph(&graph, optarg);
19704
shell_arg_res=strdup(optarg);
19706
case 2: /* source */
19707
shell_read_integer(&source, optarg);
19709
case 3: /* target */
19710
shell_read_integer(&target, optarg);
19713
shell_igraph_edge_disjoint_paths_usage(argv);
19722
/* Check that we have all arguments */
19723
for (shell_index=0; shell_index<4; shell_index++) {
19724
if (!shell_seen[shell_index]) {
19725
fprintf(stderr, "Error, argument missing: `--%s'.\n",
19726
shell_options[shell_index].name);
19731
/* Do the operation */
19732
shell_result=igraph_edge_disjoint_paths(&graph, &res, source, target);
19734
/* Write the result */
19735
igraph_destroy(&graph);
19736
shell_write_integer(res, shell_arg_res);
19741
/*-------------------------------------------/
19742
/ igraph_vertex_disjoint_paths /
19743
/-------------------------------------------*/
19744
void shell_igraph_vertex_disjoint_paths_usage(char **argv) {
19745
printf("%s --graph=<graph> --res=<res> --source=<source> --target=<target>\n", basename(argv[0]));
19749
int shell_igraph_vertex_disjoint_paths(int argc, char **argv) {
19752
igraph_integer_t res;
19753
igraph_integer_t source;
19754
igraph_integer_t target;
19755
char* shell_arg_res=0;
19760
int shell_index=-1;
19761
struct option shell_options[]= { { "graph",required_argument,0,0 },
19762
{ "res",required_argument,0,1 },
19763
{ "source",required_argument,0,2 },
19764
{ "target",required_argument,0,3 },
19765
{ "help",no_argument,0,4 },
19769
/* 0 - not seen, 1 - seen as argument, 2 - seen as default */
19770
memset(shell_seen, 0, 4*sizeof(int));
19773
/* Parse arguments and read input */
19774
while (getopt_long(argc, argv, "", shell_options, &shell_index) != -1) {
19776
if (shell_index==-1) {
19780
if (shell_seen[shell_index]==1) {
19781
fprintf(stderr, "Error, `--%s' argument given twice.\n",
19782
shell_options[shell_index].name);
19785
shell_seen[shell_index]=1;
19787
switch (shell_index) {
19788
case 0: /* graph */
19789
shell_read_graph(&graph, optarg);
19792
shell_arg_res=strdup(optarg);
19794
case 2: /* source */
19795
shell_read_integer(&source, optarg);
19797
case 3: /* target */
19798
shell_read_integer(&target, optarg);
19801
shell_igraph_vertex_disjoint_paths_usage(argv);
19810
/* Check that we have all arguments */
19811
for (shell_index=0; shell_index<4; shell_index++) {
19812
if (!shell_seen[shell_index]) {
19813
fprintf(stderr, "Error, argument missing: `--%s'.\n",
19814
shell_options[shell_index].name);
19819
/* Do the operation */
19820
shell_result=igraph_vertex_disjoint_paths(&graph, &res, source, target);
19822
/* Write the result */
19823
igraph_destroy(&graph);
19824
shell_write_integer(res, shell_arg_res);
19829
/*-------------------------------------------/
19830
/ igraph_adhesion /
19831
/-------------------------------------------*/
19832
void shell_igraph_adhesion_usage(char **argv) {
19833
printf("%s --graph=<graph> --res=<res> --checks=<checks>\n", basename(argv[0]));
19837
int shell_igraph_adhesion(int argc, char **argv) {
19840
igraph_integer_t res;
19841
igraph_bool_t checks=1;
19842
char* shell_arg_res=0;
19847
int shell_index=-1;
19848
struct option shell_options[]= { { "graph",required_argument,0,0 },
19849
{ "res",required_argument,0,1 },
19850
{ "checks",required_argument,0,2 },
19851
{ "help",no_argument,0,3 },
19855
/* 0 - not seen, 1 - seen as argument, 2 - seen as default */
19856
memset(shell_seen, 0, 3*sizeof(int));
19859
/* Parse arguments and read input */
19860
while (getopt_long(argc, argv, "", shell_options, &shell_index) != -1) {
19862
if (shell_index==-1) {
19866
if (shell_seen[shell_index]==1) {
19867
fprintf(stderr, "Error, `--%s' argument given twice.\n",
19868
shell_options[shell_index].name);
19871
shell_seen[shell_index]=1;
19873
switch (shell_index) {
19874
case 0: /* graph */
19875
shell_read_graph(&graph, optarg);
19878
shell_arg_res=strdup(optarg);
19880
case 2: /* checks */
19881
shell_read_boolean(&checks, optarg);
19884
shell_igraph_adhesion_usage(argv);
19893
/* Check that we have all arguments */
19894
for (shell_index=0; shell_index<3; shell_index++) {
19895
if (!shell_seen[shell_index]) {
19896
fprintf(stderr, "Error, argument missing: `--%s'.\n",
19897
shell_options[shell_index].name);
19902
/* Do the operation */
19903
shell_result=igraph_adhesion(&graph, &res, checks);
19905
/* Write the result */
19906
igraph_destroy(&graph);
19907
shell_write_integer(res, shell_arg_res);
19912
/*-------------------------------------------/
19913
/ igraph_cohesion /
19914
/-------------------------------------------*/
19915
void shell_igraph_cohesion_usage(char **argv) {
19916
printf("%s --graph=<graph> --res=<res> --checks=<checks>\n", basename(argv[0]));
19920
int shell_igraph_cohesion(int argc, char **argv) {
19923
igraph_integer_t res;
19924
igraph_bool_t checks=1;
19925
char* shell_arg_res=0;
19930
int shell_index=-1;
19931
struct option shell_options[]= { { "graph",required_argument,0,0 },
19932
{ "res",required_argument,0,1 },
19933
{ "checks",required_argument,0,2 },
19934
{ "help",no_argument,0,3 },
19938
/* 0 - not seen, 1 - seen as argument, 2 - seen as default */
19939
memset(shell_seen, 0, 3*sizeof(int));
19942
/* Parse arguments and read input */
19943
while (getopt_long(argc, argv, "", shell_options, &shell_index) != -1) {
19945
if (shell_index==-1) {
19949
if (shell_seen[shell_index]==1) {
19950
fprintf(stderr, "Error, `--%s' argument given twice.\n",
19951
shell_options[shell_index].name);
19954
shell_seen[shell_index]=1;
19956
switch (shell_index) {
19957
case 0: /* graph */
19958
shell_read_graph(&graph, optarg);
19961
shell_arg_res=strdup(optarg);
19963
case 2: /* checks */
19964
shell_read_boolean(&checks, optarg);
19967
shell_igraph_cohesion_usage(argv);
19976
/* Check that we have all arguments */
19977
for (shell_index=0; shell_index<3; shell_index++) {
19978
if (!shell_seen[shell_index]) {
19979
fprintf(stderr, "Error, argument missing: `--%s'.\n",
19980
shell_options[shell_index].name);
19985
/* Do the operation */
19986
shell_result=igraph_cohesion(&graph, &res, checks);
19988
/* Write the result */
19989
igraph_destroy(&graph);
19990
shell_write_integer(res, shell_arg_res);
19995
/*-------------------------------------------/
19996
/ igraph_coreness /
19997
/-------------------------------------------*/
19998
void shell_igraph_coreness_usage(char **argv) {
19999
printf("%s --graph=<graph> --cores=<cores> --mode=<mode>\n", basename(argv[0]));
20003
int shell_igraph_coreness(int argc, char **argv) {
20006
igraph_vector_t cores;
20007
igraph_neimode_t mode=IGRAPH_ALL;
20008
char* shell_arg_cores=0;
20013
int shell_index=-1;
20014
struct option shell_options[]= { { "graph",required_argument,0,0 },
20015
{ "cores",required_argument,0,1 },
20016
{ "mode",required_argument,0,2 },
20017
{ "help",no_argument,0,3 },
20021
/* 0 - not seen, 1 - seen as argument, 2 - seen as default */
20022
memset(shell_seen, 0, 3*sizeof(int));
20025
/* Parse arguments and read input */
20026
while (getopt_long(argc, argv, "", shell_options, &shell_index) != -1) {
20028
if (shell_index==-1) {
20032
if (shell_seen[shell_index]==1) {
20033
fprintf(stderr, "Error, `--%s' argument given twice.\n",
20034
shell_options[shell_index].name);
20037
shell_seen[shell_index]=1;
20039
switch (shell_index) {
20040
case 0: /* graph */
20041
shell_read_graph(&graph, optarg);
20043
case 1: /* cores */
20044
shell_arg_cores=strdup(optarg);
20045
igraph_vector_init(&cores, 0);
20048
shell_read_enum(&mode, optarg, "out", 1, "in", 2, "all", 3, "total", 3, 0);
20051
shell_igraph_coreness_usage(argv);
20060
/* Check that we have all arguments */
20061
for (shell_index=0; shell_index<3; shell_index++) {
20062
if (!shell_seen[shell_index]) {
20063
fprintf(stderr, "Error, argument missing: `--%s'.\n",
20064
shell_options[shell_index].name);
20069
/* Do the operation */
20070
shell_result=igraph_coreness(&graph, &cores, mode);
20072
/* Write the result */
20073
igraph_destroy(&graph);
20074
shell_write_vector(&cores, shell_arg_cores);
20075
igraph_vector_destroy(&cores);
20080
/*-------------------------------------------/
20081
/ igraph_isoclass /
20082
/-------------------------------------------*/
20083
void shell_igraph_isoclass_usage(char **argv) {
20084
printf("%s --graph=<graph> --isoclass=<isoclass>\n", basename(argv[0]));
20088
int shell_igraph_isoclass(int argc, char **argv) {
20091
igraph_integer_t isoclass;
20092
char* shell_arg_isoclass=0;
20097
int shell_index=-1;
20098
struct option shell_options[]= { { "graph",required_argument,0,0 },
20099
{ "isoclass",required_argument,0,1 },
20100
{ "help",no_argument,0,2 },
20104
/* 0 - not seen, 1 - seen as argument, 2 - seen as default */
20105
memset(shell_seen, 0, 2*sizeof(int));
20108
/* Parse arguments and read input */
20109
while (getopt_long(argc, argv, "", shell_options, &shell_index) != -1) {
20111
if (shell_index==-1) {
20115
if (shell_seen[shell_index]==1) {
20116
fprintf(stderr, "Error, `--%s' argument given twice.\n",
20117
shell_options[shell_index].name);
20120
shell_seen[shell_index]=1;
20122
switch (shell_index) {
20123
case 0: /* graph */
20124
shell_read_graph(&graph, optarg);
20126
case 1: /* isoclass */
20127
shell_arg_isoclass=strdup(optarg);
20130
shell_igraph_isoclass_usage(argv);
20139
/* Check that we have all arguments */
20140
for (shell_index=0; shell_index<2; shell_index++) {
20141
if (!shell_seen[shell_index]) {
20142
fprintf(stderr, "Error, argument missing: `--%s'.\n",
20143
shell_options[shell_index].name);
20148
/* Do the operation */
20149
shell_result=igraph_isoclass(&graph, &isoclass);
20151
/* Write the result */
20152
igraph_destroy(&graph);
20153
shell_write_integer(isoclass, shell_arg_isoclass);
20158
/*-------------------------------------------/
20159
/ igraph_isomorphic /
20160
/-------------------------------------------*/
20161
void shell_igraph_isomorphic_usage(char **argv) {
20162
printf("%s --graph1=<graph1> --graph2=<graph2> --iso=<iso>\n", basename(argv[0]));
20166
int shell_igraph_isomorphic(int argc, char **argv) {
20171
char* shell_arg_iso=0;
20176
int shell_index=-1;
20177
struct option shell_options[]= { { "graph1",required_argument,0,0 },
20178
{ "graph2",required_argument,0,1 },
20179
{ "iso",required_argument,0,2 },
20180
{ "help",no_argument,0,3 },
20184
/* 0 - not seen, 1 - seen as argument, 2 - seen as default */
20185
memset(shell_seen, 0, 3*sizeof(int));
20188
/* Parse arguments and read input */
20189
while (getopt_long(argc, argv, "", shell_options, &shell_index) != -1) {
20191
if (shell_index==-1) {
20195
if (shell_seen[shell_index]==1) {
20196
fprintf(stderr, "Error, `--%s' argument given twice.\n",
20197
shell_options[shell_index].name);
20200
shell_seen[shell_index]=1;
20202
switch (shell_index) {
20203
case 0: /* graph1 */
20204
shell_read_graph(&graph1, optarg);
20206
case 1: /* graph2 */
20207
shell_read_graph(&graph2, optarg);
20213
shell_igraph_isomorphic_usage(argv);
20222
/* Check that we have all arguments */
20223
for (shell_index=0; shell_index<3; shell_index++) {
20224
if (!shell_seen[shell_index]) {
20225
fprintf(stderr, "Error, argument missing: `--%s'.\n",
20226
shell_options[shell_index].name);
20231
/* Do the operation */
20232
shell_result=igraph_isomorphic(&graph1, &graph2, &iso);
20234
/* Write the result */
20235
igraph_destroy(&graph1);
20236
igraph_destroy(&graph2);
20237
shell_write_boolean(iso, shell_arg_iso);
20242
/*-------------------------------------------/
20243
/ igraph_isoclass_subgraph /
20244
/-------------------------------------------*/
20245
void shell_igraph_isoclass_subgraph_usage(char **argv) {
20246
printf("%s --graph=<graph> --vids=<vids> --isoclass=<isoclass>\n", basename(argv[0]));
20250
int shell_igraph_isoclass_subgraph(int argc, char **argv) {
20253
igraph_vector_t vids;
20254
igraph_integer_t isoclass;
20255
char* shell_arg_isoclass=0;
20260
int shell_index=-1;
20261
struct option shell_options[]= { { "graph",required_argument,0,0 },
20262
{ "vids",required_argument,0,1 },
20263
{ "isoclass",required_argument,0,2 },
20264
{ "help",no_argument,0,3 },
20268
/* 0 - not seen, 1 - seen as argument, 2 - seen as default */
20269
memset(shell_seen, 0, 3*sizeof(int));
20272
/* Parse arguments and read input */
20273
while (getopt_long(argc, argv, "", shell_options, &shell_index) != -1) {
20275
if (shell_index==-1) {
20279
if (shell_seen[shell_index]==1) {
20280
fprintf(stderr, "Error, `--%s' argument given twice.\n",
20281
shell_options[shell_index].name);
20284
shell_seen[shell_index]=1;
20286
switch (shell_index) {
20287
case 0: /* graph */
20288
shell_read_graph(&graph, optarg);
20291
shell_read_vector(&vids, optarg);
20293
case 2: /* isoclass */
20294
shell_arg_isoclass=strdup(optarg);
20297
shell_igraph_isoclass_subgraph_usage(argv);
20306
/* Check that we have all arguments */
20307
for (shell_index=0; shell_index<3; shell_index++) {
20308
if (!shell_seen[shell_index]) {
20309
fprintf(stderr, "Error, argument missing: `--%s'.\n",
20310
shell_options[shell_index].name);
20315
/* Do the operation */
20316
shell_result=igraph_isoclass_subgraph(&graph, &vids, &isoclass);
20318
/* Write the result */
20319
igraph_destroy(&graph);
20320
igraph_vector_destroy(&vids);
20321
shell_write_integer(isoclass, shell_arg_isoclass);
20326
/*-------------------------------------------/
20327
/ igraph_isoclass_create /
20328
/-------------------------------------------*/
20329
void shell_igraph_isoclass_create_usage(char **argv) {
20330
printf("%s --graph=<graph> --size=<size> --number=<number> --directed=<directed>\n", basename(argv[0]));
20334
int shell_igraph_isoclass_create(int argc, char **argv) {
20337
igraph_integer_t size;
20338
igraph_integer_t number;
20339
igraph_bool_t directed=1;
20340
char* shell_arg_graph=0;
20345
int shell_index=-1;
20346
struct option shell_options[]= { { "graph",required_argument,0,0 },
20347
{ "size",required_argument,0,1 },
20348
{ "number",required_argument,0,2 },
20349
{ "directed",required_argument,0,3 },
20350
{ "help",no_argument,0,4 },
20354
/* 0 - not seen, 1 - seen as argument, 2 - seen as default */
20355
memset(shell_seen, 0, 4*sizeof(int));
20358
/* Parse arguments and read input */
20359
while (getopt_long(argc, argv, "", shell_options, &shell_index) != -1) {
20361
if (shell_index==-1) {
20365
if (shell_seen[shell_index]==1) {
20366
fprintf(stderr, "Error, `--%s' argument given twice.\n",
20367
shell_options[shell_index].name);
20370
shell_seen[shell_index]=1;
20372
switch (shell_index) {
20373
case 0: /* graph */
20374
shell_arg_graph=strdup(optarg);
20377
shell_read_integer(&size, optarg);
20379
case 2: /* number */
20380
shell_read_integer(&number, optarg);
20382
case 3: /* directed */
20383
shell_read_boolean(&directed, optarg);
20386
shell_igraph_isoclass_create_usage(argv);
20395
/* Check that we have all arguments */
20396
for (shell_index=0; shell_index<4; shell_index++) {
20397
if (!shell_seen[shell_index]) {
20398
fprintf(stderr, "Error, argument missing: `--%s'.\n",
20399
shell_options[shell_index].name);
20404
/* Do the operation */
20405
shell_result=igraph_isoclass_create(&graph, size, number, directed);
20407
/* Write the result */
20408
shell_write_graph(&graph, shell_arg_graph);
20409
igraph_destroy(&graph);
20414
/*-------------------------------------------/
20415
/ igraph_isomorphic_vf2 /
20416
/-------------------------------------------*/
20417
void shell_igraph_isomorphic_vf2_usage(char **argv) {
20418
printf("%s --graph1=<graph1> --graph2=<graph2> --iso=<iso> --map12=<map12> --map21=<map21>\n", basename(argv[0]));
20422
int shell_igraph_isomorphic_vf2(int argc, char **argv) {
20427
igraph_vector_t v_map12; igraph_vector_t *map12=0;
20428
igraph_vector_t v_map21; igraph_vector_t *map21=0;
20429
char* shell_arg_iso=0;
20430
char* shell_arg_map12=0;
20431
char* shell_arg_map21=0;
20436
int shell_index=-1;
20437
struct option shell_options[]= { { "graph1",required_argument,0,0 },
20438
{ "graph2",required_argument,0,1 },
20439
{ "iso",required_argument,0,2 },
20440
{ "map12",required_argument,0,3 },
20441
{ "map21",required_argument,0,4 },
20442
{ "help",no_argument,0,5 },
20446
/* 0 - not seen, 1 - seen as argument, 2 - seen as default */
20447
memset(shell_seen, 0, 5*sizeof(int));
20450
/* Parse arguments and read input */
20451
while (getopt_long(argc, argv, "", shell_options, &shell_index) != -1) {
20453
if (shell_index==-1) {
20457
if (shell_seen[shell_index]==1) {
20458
fprintf(stderr, "Error, `--%s' argument given twice.\n",
20459
shell_options[shell_index].name);
20462
shell_seen[shell_index]=1;
20464
switch (shell_index) {
20465
case 0: /* graph1 */
20466
shell_read_graph(&graph1, optarg);
20468
case 1: /* graph2 */
20469
shell_read_graph(&graph2, optarg);
20474
case 3: /* map12 */
20475
map12=&v_map12; igraph_vector_init(map12, 0);
20476
shell_arg_map12=strdup(optarg);
20478
case 4: /* map21 */
20479
map21=&v_map21; igraph_vector_init(map21, 0);
20480
shell_arg_map21=strdup(optarg);
20483
shell_igraph_isomorphic_vf2_usage(argv);
20492
/* Check that we have all arguments */
20493
for (shell_index=0; shell_index<5; shell_index++) {
20494
if (!shell_seen[shell_index]) {
20495
fprintf(stderr, "Error, argument missing: `--%s'.\n",
20496
shell_options[shell_index].name);
20501
/* Do the operation */
20502
shell_result=igraph_isomorphic_vf2(&graph1, &graph2, &iso, map12, map21);
20504
/* Write the result */
20505
igraph_destroy(&graph1);
20506
igraph_destroy(&graph2);
20507
shell_write_boolean(iso, shell_arg_iso);
20508
if (map12) { shell_write_vector(map12, shell_arg_map12);
20509
igraph_vector_destroy(map12); }
20510
if (map21) { shell_write_vector(map21, shell_arg_map21);
20511
igraph_vector_destroy(map21); }
20516
/*-------------------------------------------/
20517
/ igraph_count_isomorphisms_vf2 /
20518
/-------------------------------------------*/
20519
void shell_igraph_count_isomorphisms_vf2_usage(char **argv) {
20520
printf("%s --graph1=<graph1> --graph2=<graph2> --count=<count>\n", basename(argv[0]));
20524
int shell_igraph_count_isomorphisms_vf2(int argc, char **argv) {
20528
igraph_integer_t count;
20529
char* shell_arg_count=0;
20534
int shell_index=-1;
20535
struct option shell_options[]= { { "graph1",required_argument,0,0 },
20536
{ "graph2",required_argument,0,1 },
20537
{ "count",required_argument,0,2 },
20538
{ "help",no_argument,0,3 },
20542
/* 0 - not seen, 1 - seen as argument, 2 - seen as default */
20543
memset(shell_seen, 0, 3*sizeof(int));
20546
/* Parse arguments and read input */
20547
while (getopt_long(argc, argv, "", shell_options, &shell_index) != -1) {
20549
if (shell_index==-1) {
20553
if (shell_seen[shell_index]==1) {
20554
fprintf(stderr, "Error, `--%s' argument given twice.\n",
20555
shell_options[shell_index].name);
20558
shell_seen[shell_index]=1;
20560
switch (shell_index) {
20561
case 0: /* graph1 */
20562
shell_read_graph(&graph1, optarg);
20564
case 1: /* graph2 */
20565
shell_read_graph(&graph2, optarg);
20567
case 2: /* count */
20568
shell_arg_count=strdup(optarg);
20571
shell_igraph_count_isomorphisms_vf2_usage(argv);
20580
/* Check that we have all arguments */
20581
for (shell_index=0; shell_index<3; shell_index++) {
20582
if (!shell_seen[shell_index]) {
20583
fprintf(stderr, "Error, argument missing: `--%s'.\n",
20584
shell_options[shell_index].name);
20589
/* Do the operation */
20590
shell_result=igraph_count_isomorphisms_vf2(&graph1, &graph2, &count);
20592
/* Write the result */
20593
igraph_destroy(&graph1);
20594
igraph_destroy(&graph2);
20595
shell_write_integer(count, shell_arg_count);
20600
/*-------------------------------------------/
20601
/ igraph_get_isomorphisms_vf2 /
20602
/-------------------------------------------*/
20603
void shell_igraph_get_isomorphisms_vf2_usage(char **argv) {
20604
printf("%s --graph1=<graph1> --graph2=<graph2> --maps=<maps>\n", basename(argv[0]));
20608
int shell_igraph_get_isomorphisms_vf2(int argc, char **argv) {
20612
igraph_vector_ptr_t maps;
20613
char* shell_arg_maps=0;
20618
int shell_index=-1;
20619
struct option shell_options[]= { { "graph1",required_argument,0,0 },
20620
{ "graph2",required_argument,0,1 },
20621
{ "maps",required_argument,0,2 },
20622
{ "help",no_argument,0,3 },
20626
/* 0 - not seen, 1 - seen as argument, 2 - seen as default */
20627
memset(shell_seen, 0, 3*sizeof(int));
20630
/* Parse arguments and read input */
20631
while (getopt_long(argc, argv, "", shell_options, &shell_index) != -1) {
20633
if (shell_index==-1) {
20637
if (shell_seen[shell_index]==1) {
20638
fprintf(stderr, "Error, `--%s' argument given twice.\n",
20639
shell_options[shell_index].name);
20642
shell_seen[shell_index]=1;
20644
switch (shell_index) {
20645
case 0: /* graph1 */
20646
shell_read_graph(&graph1, optarg);
20648
case 1: /* graph2 */
20649
shell_read_graph(&graph2, optarg);
20652
igraph_vector_ptr_init(&maps, 0);
20655
shell_igraph_get_isomorphisms_vf2_usage(argv);
20664
/* Check that we have all arguments */
20665
for (shell_index=0; shell_index<3; shell_index++) {
20666
if (!shell_seen[shell_index]) {
20667
fprintf(stderr, "Error, argument missing: `--%s'.\n",
20668
shell_options[shell_index].name);
20673
/* Do the operation */
20674
shell_result=igraph_get_isomorphisms_vf2(&graph1, &graph2, &maps);
20676
/* Write the result */
20677
igraph_destroy(&graph1);
20678
igraph_destroy(&graph2);
20679
shell_write_vectorlist(&maps, shell_arg_maps);
20680
shell_free_vectorlist(&maps);
20681
igraph_vector_ptr_destroy(&maps);
20686
/*-------------------------------------------/
20687
/ igraph_subisomorphic_vf2 /
20688
/-------------------------------------------*/
20689
void shell_igraph_subisomorphic_vf2_usage(char **argv) {
20690
printf("%s --graph1=<graph1> --graph2=<graph2> --iso=<iso> --map12=<map12> --map21=<map21>\n", basename(argv[0]));
20694
int shell_igraph_subisomorphic_vf2(int argc, char **argv) {
20699
igraph_vector_t v_map12; igraph_vector_t *map12=0;
20700
igraph_vector_t v_map21; igraph_vector_t *map21=0;
20701
char* shell_arg_iso=0;
20702
char* shell_arg_map12=0;
20703
char* shell_arg_map21=0;
20708
int shell_index=-1;
20709
struct option shell_options[]= { { "graph1",required_argument,0,0 },
20710
{ "graph2",required_argument,0,1 },
20711
{ "iso",required_argument,0,2 },
20712
{ "map12",required_argument,0,3 },
20713
{ "map21",required_argument,0,4 },
20714
{ "help",no_argument,0,5 },
20718
/* 0 - not seen, 1 - seen as argument, 2 - seen as default */
20719
memset(shell_seen, 0, 5*sizeof(int));
20722
/* Parse arguments and read input */
20723
while (getopt_long(argc, argv, "", shell_options, &shell_index) != -1) {
20725
if (shell_index==-1) {
20729
if (shell_seen[shell_index]==1) {
20730
fprintf(stderr, "Error, `--%s' argument given twice.\n",
20731
shell_options[shell_index].name);
20734
shell_seen[shell_index]=1;
20736
switch (shell_index) {
20737
case 0: /* graph1 */
20738
shell_read_graph(&graph1, optarg);
20740
case 1: /* graph2 */
20741
shell_read_graph(&graph2, optarg);
20746
case 3: /* map12 */
20747
map12=&v_map12; igraph_vector_init(map12, 0);
20748
shell_arg_map12=strdup(optarg);
20750
case 4: /* map21 */
20751
map21=&v_map21; igraph_vector_init(map21, 0);
20752
shell_arg_map21=strdup(optarg);
20755
shell_igraph_subisomorphic_vf2_usage(argv);
20764
/* Check that we have all arguments */
20765
for (shell_index=0; shell_index<5; shell_index++) {
20766
if (!shell_seen[shell_index]) {
20767
fprintf(stderr, "Error, argument missing: `--%s'.\n",
20768
shell_options[shell_index].name);
20773
/* Do the operation */
20774
shell_result=igraph_subisomorphic_vf2(&graph1, &graph2, &iso, map12, map21);
20776
/* Write the result */
20777
igraph_destroy(&graph1);
20778
igraph_destroy(&graph2);
20779
shell_write_boolean(iso, shell_arg_iso);
20780
if (map12) { shell_write_vector(map12, shell_arg_map12);
20781
igraph_vector_destroy(map12); }
20782
if (map21) { shell_write_vector(map21, shell_arg_map21);
20783
igraph_vector_destroy(map21); }
20788
/*-------------------------------------------/
20789
/ igraph_count_subisomorphisms_vf2 /
20790
/-------------------------------------------*/
20791
void shell_igraph_count_subisomorphisms_vf2_usage(char **argv) {
20792
printf("%s --graph1=<graph1> --graph2=<graph2> --count=<count>\n", basename(argv[0]));
20796
int shell_igraph_count_subisomorphisms_vf2(int argc, char **argv) {
20800
igraph_integer_t count;
20801
char* shell_arg_count=0;
20806
int shell_index=-1;
20807
struct option shell_options[]= { { "graph1",required_argument,0,0 },
20808
{ "graph2",required_argument,0,1 },
20809
{ "count",required_argument,0,2 },
20810
{ "help",no_argument,0,3 },
20814
/* 0 - not seen, 1 - seen as argument, 2 - seen as default */
20815
memset(shell_seen, 0, 3*sizeof(int));
20818
/* Parse arguments and read input */
20819
while (getopt_long(argc, argv, "", shell_options, &shell_index) != -1) {
20821
if (shell_index==-1) {
20825
if (shell_seen[shell_index]==1) {
20826
fprintf(stderr, "Error, `--%s' argument given twice.\n",
20827
shell_options[shell_index].name);
20830
shell_seen[shell_index]=1;
20832
switch (shell_index) {
20833
case 0: /* graph1 */
20834
shell_read_graph(&graph1, optarg);
20836
case 1: /* graph2 */
20837
shell_read_graph(&graph2, optarg);
20839
case 2: /* count */
20840
shell_arg_count=strdup(optarg);
20843
shell_igraph_count_subisomorphisms_vf2_usage(argv);
20852
/* Check that we have all arguments */
20853
for (shell_index=0; shell_index<3; shell_index++) {
20854
if (!shell_seen[shell_index]) {
20855
fprintf(stderr, "Error, argument missing: `--%s'.\n",
20856
shell_options[shell_index].name);
20861
/* Do the operation */
20862
shell_result=igraph_count_subisomorphisms_vf2(&graph1, &graph2, &count);
20864
/* Write the result */
20865
igraph_destroy(&graph1);
20866
igraph_destroy(&graph2);
20867
shell_write_integer(count, shell_arg_count);
20872
/*-------------------------------------------/
20873
/ igraph_get_subisomorphisms_vf2 /
20874
/-------------------------------------------*/
20875
void shell_igraph_get_subisomorphisms_vf2_usage(char **argv) {
20876
printf("%s --graph1=<graph1> --graph2=<graph2> --maps=<maps>\n", basename(argv[0]));
20880
int shell_igraph_get_subisomorphisms_vf2(int argc, char **argv) {
20884
igraph_vector_ptr_t maps;
20885
char* shell_arg_maps=0;
20890
int shell_index=-1;
20891
struct option shell_options[]= { { "graph1",required_argument,0,0 },
20892
{ "graph2",required_argument,0,1 },
20893
{ "maps",required_argument,0,2 },
20894
{ "help",no_argument,0,3 },
20898
/* 0 - not seen, 1 - seen as argument, 2 - seen as default */
20899
memset(shell_seen, 0, 3*sizeof(int));
20902
/* Parse arguments and read input */
20903
while (getopt_long(argc, argv, "", shell_options, &shell_index) != -1) {
20905
if (shell_index==-1) {
20909
if (shell_seen[shell_index]==1) {
20910
fprintf(stderr, "Error, `--%s' argument given twice.\n",
20911
shell_options[shell_index].name);
20914
shell_seen[shell_index]=1;
20916
switch (shell_index) {
20917
case 0: /* graph1 */
20918
shell_read_graph(&graph1, optarg);
20920
case 1: /* graph2 */
20921
shell_read_graph(&graph2, optarg);
20924
igraph_vector_ptr_init(&maps, 0);
20927
shell_igraph_get_subisomorphisms_vf2_usage(argv);
20936
/* Check that we have all arguments */
20937
for (shell_index=0; shell_index<3; shell_index++) {
20938
if (!shell_seen[shell_index]) {
20939
fprintf(stderr, "Error, argument missing: `--%s'.\n",
20940
shell_options[shell_index].name);
20945
/* Do the operation */
20946
shell_result=igraph_get_subisomorphisms_vf2(&graph1, &graph2, &maps);
20948
/* Write the result */
20949
igraph_destroy(&graph1);
20950
igraph_destroy(&graph2);
20951
shell_write_vectorlist(&maps, shell_arg_maps);
20952
shell_free_vectorlist(&maps);
20953
igraph_vector_ptr_destroy(&maps);
20958
/*-------------------------------------------/
20959
/ igraph_isomorphic_34 /
20960
/-------------------------------------------*/
20961
void shell_igraph_isomorphic_34_usage(char **argv) {
20962
printf("%s --graph1=<graph1> --graph2=<graph2> --iso=<iso>\n", basename(argv[0]));
20966
int shell_igraph_isomorphic_34(int argc, char **argv) {
20971
char* shell_arg_iso=0;
20976
int shell_index=-1;
20977
struct option shell_options[]= { { "graph1",required_argument,0,0 },
20978
{ "graph2",required_argument,0,1 },
20979
{ "iso",required_argument,0,2 },
20980
{ "help",no_argument,0,3 },
20984
/* 0 - not seen, 1 - seen as argument, 2 - seen as default */
20985
memset(shell_seen, 0, 3*sizeof(int));
20988
/* Parse arguments and read input */
20989
while (getopt_long(argc, argv, "", shell_options, &shell_index) != -1) {
20991
if (shell_index==-1) {
20995
if (shell_seen[shell_index]==1) {
20996
fprintf(stderr, "Error, `--%s' argument given twice.\n",
20997
shell_options[shell_index].name);
21000
shell_seen[shell_index]=1;
21002
switch (shell_index) {
21003
case 0: /* graph1 */
21004
shell_read_graph(&graph1, optarg);
21006
case 1: /* graph2 */
21007
shell_read_graph(&graph2, optarg);
21013
shell_igraph_isomorphic_34_usage(argv);
21022
/* Check that we have all arguments */
21023
for (shell_index=0; shell_index<3; shell_index++) {
21024
if (!shell_seen[shell_index]) {
21025
fprintf(stderr, "Error, argument missing: `--%s'.\n",
21026
shell_options[shell_index].name);
21031
/* Do the operation */
21032
shell_result=igraph_isomorphic_34(&graph1, &graph2, &iso);
21034
/* Write the result */
21035
igraph_destroy(&graph1);
21036
igraph_destroy(&graph2);
21037
shell_write_boolean(iso, shell_arg_iso);
21042
/*-------------------------------------------/
21043
/ igraph_canonical_permutation /
21044
/-------------------------------------------*/
21045
void shell_igraph_canonical_permutation_usage(char **argv) {
21046
printf("%s --graph=<graph> --labeling=<labeling>\n", basename(argv[0]));
21050
int shell_igraph_canonical_permutation(int argc, char **argv) {
21053
igraph_vector_t labeling;
21056
char* shell_arg_labeling=0;
21057
char* shell_arg_info=0;
21062
int shell_index=-1;
21063
struct option shell_options[]= { { "graph",required_argument,0,0 },
21064
{ "labeling",required_argument,0,1 },
21065
{ "help",no_argument,0,2 },
21069
/* 0 - not seen, 1 - seen as argument, 2 - seen as default */
21070
memset(shell_seen, 0, 2*sizeof(int));
21073
/* Parse arguments and read input */
21074
while (getopt_long(argc, argv, "", shell_options, &shell_index) != -1) {
21076
if (shell_index==-1) {
21080
if (shell_seen[shell_index]==1) {
21081
fprintf(stderr, "Error, `--%s' argument given twice.\n",
21082
shell_options[shell_index].name);
21085
shell_seen[shell_index]=1;
21087
switch (shell_index) {
21088
case 0: /* graph */
21089
shell_read_graph(&graph, optarg);
21091
case 1: /* labeling */
21092
shell_arg_labeling=strdup(optarg);
21093
igraph_vector_init(&labeling, 0);
21096
shell_igraph_canonical_permutation_usage(argv);
21105
/* Check that we have all arguments */
21106
for (shell_index=0; shell_index<2; shell_index++) {
21107
if (!shell_seen[shell_index]) {
21108
fprintf(stderr, "Error, argument missing: `--%s'.\n",
21109
shell_options[shell_index].name);
21114
/* Do the operation */
21115
shell_result=igraph_canonical_permutation(&graph, &labeling, 0, 0);
21117
/* Write the result */
21118
igraph_destroy(&graph);
21119
shell_write_vector(&labeling, shell_arg_labeling);
21120
igraph_vector_destroy(&labeling);
21125
/*-------------------------------------------/
21126
/ igraph_permute_vertices /
21127
/-------------------------------------------*/
21128
void shell_igraph_permute_vertices_usage(char **argv) {
21129
printf("%s --graph=<graph> --res=<res> --permutation=<permutation>\n", basename(argv[0]));
21133
int shell_igraph_permute_vertices(int argc, char **argv) {
21137
igraph_vector_t permutation;
21138
char* shell_arg_res=0;
21143
int shell_index=-1;
21144
struct option shell_options[]= { { "graph",required_argument,0,0 },
21145
{ "res",required_argument,0,1 },
21146
{ "permutation",required_argument,0,2 },
21147
{ "help",no_argument,0,3 },
21151
/* 0 - not seen, 1 - seen as argument, 2 - seen as default */
21152
memset(shell_seen, 0, 3*sizeof(int));
21155
/* Parse arguments and read input */
21156
while (getopt_long(argc, argv, "", shell_options, &shell_index) != -1) {
21158
if (shell_index==-1) {
21162
if (shell_seen[shell_index]==1) {
21163
fprintf(stderr, "Error, `--%s' argument given twice.\n",
21164
shell_options[shell_index].name);
21167
shell_seen[shell_index]=1;
21169
switch (shell_index) {
21170
case 0: /* graph */
21171
shell_read_graph(&graph, optarg);
21174
shell_arg_res=strdup(optarg);
21176
case 2: /* permutation */
21177
shell_read_vector(&permutation, optarg);
21180
shell_igraph_permute_vertices_usage(argv);
21189
/* Check that we have all arguments */
21190
for (shell_index=0; shell_index<3; shell_index++) {
21191
if (!shell_seen[shell_index]) {
21192
fprintf(stderr, "Error, argument missing: `--%s'.\n",
21193
shell_options[shell_index].name);
21198
/* Do the operation */
21199
shell_result=igraph_permute_vertices(&graph, &res, &permutation);
21201
/* Write the result */
21202
igraph_destroy(&graph);
21203
shell_write_graph(&res, shell_arg_res);
21204
igraph_destroy(&res);
21205
igraph_vector_destroy(&permutation);
21210
/*-------------------------------------------/
21211
/ igraph_isomorphic_bliss /
21212
/-------------------------------------------*/
21213
void shell_igraph_isomorphic_bliss_usage(char **argv) {
21214
printf("%s --graph1=<graph1> --graph2=<graph2> --iso=<iso> --map12=<map12> --map21=<map21>\n", basename(argv[0]));
21218
int shell_igraph_isomorphic_bliss(int argc, char **argv) {
21223
igraph_vector_t v_map12; igraph_vector_t *map12=0;
21224
igraph_vector_t v_map21; igraph_vector_t *map21=0;
21229
char* shell_arg_iso=0;
21230
char* shell_arg_map12=0;
21231
char* shell_arg_map21=0;
21232
char* shell_arg_info1=0;
21233
char* shell_arg_info2=0;
21238
int shell_index=-1;
21239
struct option shell_options[]= { { "graph1",required_argument,0,0 },
21240
{ "graph2",required_argument,0,1 },
21241
{ "iso",required_argument,0,2 },
21242
{ "map12",required_argument,0,3 },
21243
{ "map21",required_argument,0,4 },
21244
{ "help",no_argument,0,5 },
21248
/* 0 - not seen, 1 - seen as argument, 2 - seen as default */
21249
memset(shell_seen, 0, 5*sizeof(int));
21252
/* Parse arguments and read input */
21253
while (getopt_long(argc, argv, "", shell_options, &shell_index) != -1) {
21255
if (shell_index==-1) {
21259
if (shell_seen[shell_index]==1) {
21260
fprintf(stderr, "Error, `--%s' argument given twice.\n",
21261
shell_options[shell_index].name);
21264
shell_seen[shell_index]=1;
21266
switch (shell_index) {
21267
case 0: /* graph1 */
21268
shell_read_graph(&graph1, optarg);
21270
case 1: /* graph2 */
21271
shell_read_graph(&graph2, optarg);
21276
case 3: /* map12 */
21277
map12=&v_map12; igraph_vector_init(map12, 0);
21278
shell_arg_map12=strdup(optarg);
21280
case 4: /* map21 */
21281
map21=&v_map21; igraph_vector_init(map21, 0);
21282
shell_arg_map21=strdup(optarg);
21285
shell_igraph_isomorphic_bliss_usage(argv);
21294
/* Check that we have all arguments */
21295
for (shell_index=0; shell_index<5; shell_index++) {
21296
if (!shell_seen[shell_index]) {
21297
fprintf(stderr, "Error, argument missing: `--%s'.\n",
21298
shell_options[shell_index].name);
21303
/* Do the operation */
21304
shell_result=igraph_isomorphic_bliss(&graph1, &graph2, &iso, map12, map21, 0, 0, 0, 0);
21306
/* Write the result */
21307
igraph_destroy(&graph1);
21308
igraph_destroy(&graph2);
21309
shell_write_boolean(iso, shell_arg_iso);
21310
if (map12) { shell_write_vector(map12, shell_arg_map12);
21311
igraph_vector_destroy(map12); }
21312
if (map21) { shell_write_vector(map21, shell_arg_map21);
21313
igraph_vector_destroy(map21); }
21318
/*-------------------------------------------/
21319
/ igraph_automorphisms /
21320
/-------------------------------------------*/
21321
void shell_igraph_automorphisms_usage(char **argv) {
21322
printf("%s --graph=<graph>\n", basename(argv[0]));
21326
int shell_igraph_automorphisms(int argc, char **argv) {
21331
char* shell_arg_info=0;
21336
int shell_index=-1;
21337
struct option shell_options[]= { { "graph",required_argument,0,0 },
21338
{ "help",no_argument,0,1 },
21342
/* 0 - not seen, 1 - seen as argument, 2 - seen as default */
21343
memset(shell_seen, 0, 1*sizeof(int));
21346
/* Parse arguments and read input */
21347
while (getopt_long(argc, argv, "", shell_options, &shell_index) != -1) {
21349
if (shell_index==-1) {
21353
if (shell_seen[shell_index]==1) {
21354
fprintf(stderr, "Error, `--%s' argument given twice.\n",
21355
shell_options[shell_index].name);
21358
shell_seen[shell_index]=1;
21360
switch (shell_index) {
21361
case 0: /* graph */
21362
shell_read_graph(&graph, optarg);
21365
shell_igraph_automorphisms_usage(argv);
21374
/* Check that we have all arguments */
21375
for (shell_index=0; shell_index<1; shell_index++) {
21376
if (!shell_seen[shell_index]) {
21377
fprintf(stderr, "Error, argument missing: `--%s'.\n",
21378
shell_options[shell_index].name);
21383
/* Do the operation */
21384
shell_result=igraph_automorphisms(&graph, 0, 0);
21386
/* Write the result */
21387
igraph_destroy(&graph);
21392
/*-------------------------------------------/
21393
/ igraph_running_mean /
21394
/-------------------------------------------*/
21395
void shell_igraph_running_mean_usage(char **argv) {
21396
printf("%s --data=<data> --res=<res> --binwidth=<binwidth>\n", basename(argv[0]));
21400
int shell_igraph_running_mean(int argc, char **argv) {
21402
igraph_vector_t data;
21403
igraph_vector_t res;
21404
igraph_integer_t binwidth;
21405
char* shell_arg_res=0;
21410
int shell_index=-1;
21411
struct option shell_options[]= { { "data",required_argument,0,0 },
21412
{ "res",required_argument,0,1 },
21413
{ "binwidth",required_argument,0,2 },
21414
{ "help",no_argument,0,3 },
21418
/* 0 - not seen, 1 - seen as argument, 2 - seen as default */
21419
memset(shell_seen, 0, 3*sizeof(int));
21422
/* Parse arguments and read input */
21423
while (getopt_long(argc, argv, "", shell_options, &shell_index) != -1) {
21425
if (shell_index==-1) {
21429
if (shell_seen[shell_index]==1) {
21430
fprintf(stderr, "Error, `--%s' argument given twice.\n",
21431
shell_options[shell_index].name);
21434
shell_seen[shell_index]=1;
21436
switch (shell_index) {
21438
shell_read_vector(&data, optarg);
21441
shell_arg_res=strdup(optarg);
21442
igraph_vector_init(&res, 0);
21444
case 2: /* binwidth */
21445
shell_read_integer(&binwidth, optarg);
21448
shell_igraph_running_mean_usage(argv);
21457
/* Check that we have all arguments */
21458
for (shell_index=0; shell_index<3; shell_index++) {
21459
if (!shell_seen[shell_index]) {
21460
fprintf(stderr, "Error, argument missing: `--%s'.\n",
21461
shell_options[shell_index].name);
21466
/* Do the operation */
21467
shell_result=igraph_running_mean(&data, &res, binwidth);
21469
/* Write the result */
21470
igraph_vector_destroy(&data);
21471
shell_write_vector(&res, shell_arg_res);
21472
igraph_vector_destroy(&res);
21477
/*-------------------------------------------/
21478
/ igraph_random_sample /
21479
/-------------------------------------------*/
21480
void shell_igraph_random_sample_usage(char **argv) {
21481
printf("%s --res=<res> --l=<l> --h=<h> --length=<length>\n", basename(argv[0]));
21485
int shell_igraph_random_sample(int argc, char **argv) {
21487
igraph_vector_t res;
21488
igraph_integer_t l;
21489
igraph_integer_t h;
21490
igraph_integer_t length;
21491
char* shell_arg_res=0;
21496
int shell_index=-1;
21497
struct option shell_options[]= { { "res",required_argument,0,0 },
21498
{ "l",required_argument,0,1 },
21499
{ "h",required_argument,0,2 },
21500
{ "length",required_argument,0,3 },
21501
{ "help",no_argument,0,4 },
21505
/* 0 - not seen, 1 - seen as argument, 2 - seen as default */
21506
memset(shell_seen, 0, 4*sizeof(int));
21509
/* Parse arguments and read input */
21510
while (getopt_long(argc, argv, "", shell_options, &shell_index) != -1) {
21512
if (shell_index==-1) {
21516
if (shell_seen[shell_index]==1) {
21517
fprintf(stderr, "Error, `--%s' argument given twice.\n",
21518
shell_options[shell_index].name);
21521
shell_seen[shell_index]=1;
21523
switch (shell_index) {
21525
shell_arg_res=strdup(optarg);
21526
igraph_vector_init(&res, 0);
21529
shell_read_integer(&l, optarg);
21532
shell_read_integer(&h, optarg);
21534
case 3: /* length */
21535
shell_read_integer(&length, optarg);
21538
shell_igraph_random_sample_usage(argv);
21547
/* Check that we have all arguments */
21548
for (shell_index=0; shell_index<4; shell_index++) {
21549
if (!shell_seen[shell_index]) {
21550
fprintf(stderr, "Error, argument missing: `--%s'.\n",
21551
shell_options[shell_index].name);
21556
/* Do the operation */
21557
shell_result=igraph_random_sample(&res, l, h, length);
21559
/* Write the result */
21560
shell_write_vector(&res, shell_arg_res);
21561
igraph_vector_destroy(&res);
21566
/*-------------------------------------------/
21567
/ igraph_convex_hull /
21568
/-------------------------------------------*/
21569
void shell_igraph_convex_hull_usage(char **argv) {
21570
printf("%s --data=<data> --resverts=<resverts> --rescoords=<rescoords>\n", basename(argv[0]));
21574
int shell_igraph_convex_hull(int argc, char **argv) {
21576
igraph_matrix_t data;
21577
igraph_vector_t resverts;
21578
igraph_matrix_t rescoords;
21579
char* shell_arg_resverts=0;
21580
char* shell_arg_rescoords=0;
21585
int shell_index=-1;
21586
struct option shell_options[]= { { "data",required_argument,0,0 },
21587
{ "resverts",required_argument,0,1 },
21588
{ "rescoords",required_argument,0,2 },
21589
{ "help",no_argument,0,3 },
21593
/* 0 - not seen, 1 - seen as argument, 2 - seen as default */
21594
memset(shell_seen, 0, 3*sizeof(int));
21597
/* Parse arguments and read input */
21598
while (getopt_long(argc, argv, "", shell_options, &shell_index) != -1) {
21600
if (shell_index==-1) {
21604
if (shell_seen[shell_index]==1) {
21605
fprintf(stderr, "Error, `--%s' argument given twice.\n",
21606
shell_options[shell_index].name);
21609
shell_seen[shell_index]=1;
21611
switch (shell_index) {
21613
shell_read_matrix(&data, optarg);
21615
case 1: /* resverts */
21616
shell_arg_resverts=strdup(optarg);
21617
igraph_vector_init(&resverts, 0);
21619
case 2: /* rescoords */
21620
shell_arg_rescoords=strdup(optarg);
21621
igraph_matrix_init(&rescoords, 0, 0);
21624
shell_igraph_convex_hull_usage(argv);
21633
/* Check that we have all arguments */
21634
for (shell_index=0; shell_index<3; shell_index++) {
21635
if (!shell_seen[shell_index]) {
21636
fprintf(stderr, "Error, argument missing: `--%s'.\n",
21637
shell_options[shell_index].name);
21642
/* Do the operation */
21643
shell_result=igraph_convex_hull(&data, &resverts, &rescoords);
21645
/* Write the result */
21646
igraph_matrix_destroy(&data);
21647
shell_write_vector(&resverts, shell_arg_resverts);
21648
igraph_vector_destroy(&resverts);
21649
shell_write_matrix(&rescoords, shell_arg_rescoords);
21650
igraph_matrix_destroy(&rescoords);
21655
/*-------------------------------------------/
21656
/ igraph_revolver_ml_d /
21657
/-------------------------------------------*/
21658
void shell_igraph_revolver_ml_d_usage(char **argv) {
21659
printf("%s --graph=<graph> --niter=<niter> --kernel=<kernel> --cites=<cites> --delta=<delta> --filter=<filter> --logprob=<logprob> --logmax=<logmax>\n", basename(argv[0]));
21663
int shell_igraph_revolver_ml_d(int argc, char **argv) {
21666
igraph_integer_t niter;
21667
igraph_vector_t kernel;
21668
igraph_vector_t v_cites; igraph_vector_t *cites=0;
21669
igraph_real_t delta=1e-10;
21670
igraph_vector_t v_filter; igraph_vector_t *filter=0=NULL;
21671
igraph_real_t logprob;
21672
igraph_real_t logmax;
21673
char* shell_arg_kernel=0;
21674
char* shell_arg_cites=0;
21675
char* shell_arg_logprob=0;
21676
char* shell_arg_logmax=0;
21681
int shell_index=-1;
21682
struct option shell_options[]= { { "graph",required_argument,0,0 },
21683
{ "niter",required_argument,0,1 },
21684
{ "kernel",required_argument,0,2 },
21685
{ "cites",required_argument,0,3 },
21686
{ "delta",required_argument,0,4 },
21687
{ "filter",required_argument,0,5 },
21688
{ "logprob",required_argument,0,6 },
21689
{ "logmax",required_argument,0,7 },
21690
{ "help",no_argument,0,8 },
21694
/* 0 - not seen, 1 - seen as argument, 2 - seen as default */
21695
memset(shell_seen, 0, 8*sizeof(int));
21699
/* Parse arguments and read input */
21700
while (getopt_long(argc, argv, "", shell_options, &shell_index) != -1) {
21702
if (shell_index==-1) {
21706
if (shell_seen[shell_index]==1) {
21707
fprintf(stderr, "Error, `--%s' argument given twice.\n",
21708
shell_options[shell_index].name);
21711
shell_seen[shell_index]=1;
21713
switch (shell_index) {
21714
case 0: /* graph */
21715
shell_read_graph(&graph, optarg);
21717
case 1: /* niter */
21718
shell_read_integer(&niter, optarg);
21720
case 2: /* kernel */
21721
shell_arg_kernel=strdup(optarg);
21722
igraph_vector_init(&kernel, 0);
21724
case 3: /* cites */
21725
cites=&v_cites; igraph_vector_init(cites, 0);
21726
shell_arg_cites=strdup(optarg);
21728
case 4: /* delta */
21729
shell_read_real(&delta, optarg);
21731
case 5: /* filter */
21732
filter=&v_filter; shell_read_vector(filter, optarg);
21734
case 6: /* logprob */
21735
shell_arg_logprob=strdup(optarg);
21737
case 7: /* logmax */
21738
shell_arg_logmax=strdup(optarg);
21741
shell_igraph_revolver_ml_d_usage(argv);
21750
/* Check that we have all arguments */
21751
for (shell_index=0; shell_index<8; shell_index++) {
21752
if (!shell_seen[shell_index]) {
21753
fprintf(stderr, "Error, argument missing: `--%s'.\n",
21754
shell_options[shell_index].name);
21759
/* Do the operation */
21760
shell_result=igraph_revolver_ml_d(&graph, niter, &kernel, cites, delta, filter, &logprob, &logmax);
21762
/* Write the result */
21763
igraph_destroy(&graph);
21764
shell_write_vector(&kernel, shell_arg_kernel);
21765
igraph_vector_destroy(&kernel);
21766
if (cites) { shell_write_vector(cites, shell_arg_cites);
21767
igraph_vector_destroy(cites); }
21768
if (filter) { igraph_vector_destroy(filter); }
21769
shell_write_real(logprob, shell_arg_logprob);
21770
shell_write_real(logmax, shell_arg_logmax);
21775
/*-------------------------------------------/
21776
/ igraph_revolver_probs_d /
21777
/-------------------------------------------*/
21778
void shell_igraph_revolver_probs_d_usage(char **argv) {
21779
printf("%s --graph=<graph> --kernel=<kernel> --probs=<probs> --citedprobs=<citedprobs> --citingprobs=<citingprobs> --ntk=<ntk>\n", basename(argv[0]));
21783
int shell_igraph_revolver_probs_d(int argc, char **argv) {
21786
igraph_vector_t kernel;
21787
igraph_vector_t v_probs; igraph_vector_t *probs=0;
21788
igraph_vector_t v_citedprobs; igraph_vector_t *citedprobs=0;
21789
igraph_vector_t v_citingprobs; igraph_vector_t *citingprobs=0;
21790
igraph_bool_t ntk=0;
21791
char* shell_arg_probs=0;
21792
char* shell_arg_citedprobs=0;
21793
char* shell_arg_citingprobs=0;
21798
int shell_index=-1;
21799
struct option shell_options[]= { { "graph",required_argument,0,0 },
21800
{ "kernel",required_argument,0,1 },
21801
{ "probs",required_argument,0,2 },
21802
{ "citedprobs",required_argument,0,3 },
21803
{ "citingprobs",required_argument,0,4 },
21804
{ "ntk",required_argument,0,5 },
21805
{ "help",no_argument,0,6 },
21809
/* 0 - not seen, 1 - seen as argument, 2 - seen as default */
21810
memset(shell_seen, 0, 6*sizeof(int));
21813
/* Parse arguments and read input */
21814
while (getopt_long(argc, argv, "", shell_options, &shell_index) != -1) {
21816
if (shell_index==-1) {
21820
if (shell_seen[shell_index]==1) {
21821
fprintf(stderr, "Error, `--%s' argument given twice.\n",
21822
shell_options[shell_index].name);
21825
shell_seen[shell_index]=1;
21827
switch (shell_index) {
21828
case 0: /* graph */
21829
shell_read_graph(&graph, optarg);
21831
case 1: /* kernel */
21832
shell_read_vector(&kernel, optarg);
21834
case 2: /* probs */
21835
probs=&v_probs; igraph_vector_init(probs, 0);
21836
shell_arg_probs=strdup(optarg);
21838
case 3: /* citedprobs */
21839
citedprobs=&v_citedprobs; igraph_vector_init(citedprobs, 0);
21840
shell_arg_citedprobs=strdup(optarg);
21842
case 4: /* citingprobs */
21843
citingprobs=&v_citingprobs; igraph_vector_init(citingprobs, 0);
21844
shell_arg_citingprobs=strdup(optarg);
21847
shell_read_boolean(&ntk, optarg);
21850
shell_igraph_revolver_probs_d_usage(argv);
21859
/* Check that we have all arguments */
21860
for (shell_index=0; shell_index<6; shell_index++) {
21861
if (!shell_seen[shell_index]) {
21862
fprintf(stderr, "Error, argument missing: `--%s'.\n",
21863
shell_options[shell_index].name);
21868
/* Do the operation */
21869
shell_result=igraph_revolver_probs_d(&graph, &kernel, probs, citedprobs, citingprobs, ntk);
21871
/* Write the result */
21872
igraph_destroy(&graph);
21873
igraph_vector_destroy(&kernel);
21874
if (probs) { shell_write_vector(probs, shell_arg_probs);
21875
igraph_vector_destroy(probs); }
21876
if (citedprobs) { shell_write_vector(citedprobs, shell_arg_citedprobs);
21877
igraph_vector_destroy(citedprobs); }
21878
if (citingprobs) { shell_write_vector(citingprobs, shell_arg_citingprobs);
21879
igraph_vector_destroy(citingprobs); }
21884
/*-------------------------------------------/
21885
/ igraph_revolver_ml_de /
21886
/-------------------------------------------*/
21887
void shell_igraph_revolver_ml_de_usage(char **argv) {
21888
printf("%s --graph=<graph> --niter=<niter> --kernel=<kernel> --cats=<cats> --delta=<delta> --filter=<filter> --logprob=<logprob> --logmax=<logmax>\n", basename(argv[0]));
21892
int shell_igraph_revolver_ml_de(int argc, char **argv) {
21895
igraph_integer_t niter;
21896
igraph_matrix_t kernel;
21897
igraph_vector_t cats;
21899
igraph_real_t delta=1e-10;
21900
igraph_vector_t v_filter; igraph_vector_t *filter=0=NULL;
21901
igraph_real_t logprob;
21902
igraph_real_t logmax;
21903
char* shell_arg_kernel=0;
21904
char* shell_arg_cites=0;
21905
char* shell_arg_logprob=0;
21906
char* shell_arg_logmax=0;
21911
int shell_index=-1;
21912
struct option shell_options[]= { { "graph",required_argument,0,0 },
21913
{ "niter",required_argument,0,1 },
21914
{ "kernel",required_argument,0,2 },
21915
{ "cats",required_argument,0,3 },
21916
{ "delta",required_argument,0,4 },
21917
{ "filter",required_argument,0,5 },
21918
{ "logprob",required_argument,0,6 },
21919
{ "logmax",required_argument,0,7 },
21920
{ "help",no_argument,0,8 },
21924
/* 0 - not seen, 1 - seen as argument, 2 - seen as default */
21925
memset(shell_seen, 0, 8*sizeof(int));
21929
/* Parse arguments and read input */
21930
while (getopt_long(argc, argv, "", shell_options, &shell_index) != -1) {
21932
if (shell_index==-1) {
21936
if (shell_seen[shell_index]==1) {
21937
fprintf(stderr, "Error, `--%s' argument given twice.\n",
21938
shell_options[shell_index].name);
21941
shell_seen[shell_index]=1;
21943
switch (shell_index) {
21944
case 0: /* graph */
21945
shell_read_graph(&graph, optarg);
21947
case 1: /* niter */
21948
shell_read_integer(&niter, optarg);
21950
case 2: /* kernel */
21951
shell_arg_kernel=strdup(optarg);
21952
igraph_matrix_init(&kernel, 0, 0);
21955
shell_read_vector(&cats, optarg);
21957
case 4: /* delta */
21958
shell_read_real(&delta, optarg);
21960
case 5: /* filter */
21961
filter=&v_filter; shell_read_vector(filter, optarg);
21963
case 6: /* logprob */
21964
shell_arg_logprob=strdup(optarg);
21966
case 7: /* logmax */
21967
shell_arg_logmax=strdup(optarg);
21970
shell_igraph_revolver_ml_de_usage(argv);
21979
/* Check that we have all arguments */
21980
for (shell_index=0; shell_index<8; shell_index++) {
21981
if (!shell_seen[shell_index]) {
21982
fprintf(stderr, "Error, argument missing: `--%s'.\n",
21983
shell_options[shell_index].name);
21988
/* Do the operation */
21989
shell_result=igraph_revolver_ml_de(&graph, niter, &kernel, &cats, 0, delta, filter, &logprob, &logmax);
21991
/* Write the result */
21992
igraph_destroy(&graph);
21993
shell_write_matrix(&kernel, shell_arg_kernel);
21994
igraph_matrix_destroy(&kernel);
21995
igraph_vector_destroy(&cats);
21996
if (filter) { igraph_vector_destroy(filter); }
21997
shell_write_real(logprob, shell_arg_logprob);
21998
shell_write_real(logmax, shell_arg_logmax);
22003
/*-------------------------------------------/
22004
/ igraph_revolver_probs_de /
22005
/-------------------------------------------*/
22006
void shell_igraph_revolver_probs_de_usage(char **argv) {
22007
printf("%s --graph=<graph> --kernel=<kernel> --cats=<cats> --logprobs=<logprobs> --logcited=<logcited> --logciting=<logciting>\n", basename(argv[0]));
22011
int shell_igraph_revolver_probs_de(int argc, char **argv) {
22014
igraph_matrix_t kernel;
22015
igraph_vector_t cats;
22016
igraph_vector_t v_logprobs; igraph_vector_t *logprobs=0;
22017
igraph_vector_t v_logcited; igraph_vector_t *logcited=0;
22018
igraph_vector_t v_logciting; igraph_vector_t *logciting=0;
22019
char* shell_arg_logprobs=0;
22020
char* shell_arg_logcited=0;
22021
char* shell_arg_logciting=0;
22026
int shell_index=-1;
22027
struct option shell_options[]= { { "graph",required_argument,0,0 },
22028
{ "kernel",required_argument,0,1 },
22029
{ "cats",required_argument,0,2 },
22030
{ "logprobs",required_argument,0,3 },
22031
{ "logcited",required_argument,0,4 },
22032
{ "logciting",required_argument,0,5 },
22033
{ "help",no_argument,0,6 },
22037
/* 0 - not seen, 1 - seen as argument, 2 - seen as default */
22038
memset(shell_seen, 0, 6*sizeof(int));
22041
/* Parse arguments and read input */
22042
while (getopt_long(argc, argv, "", shell_options, &shell_index) != -1) {
22044
if (shell_index==-1) {
22048
if (shell_seen[shell_index]==1) {
22049
fprintf(stderr, "Error, `--%s' argument given twice.\n",
22050
shell_options[shell_index].name);
22053
shell_seen[shell_index]=1;
22055
switch (shell_index) {
22056
case 0: /* graph */
22057
shell_read_graph(&graph, optarg);
22059
case 1: /* kernel */
22060
shell_read_matrix(&kernel, optarg);
22063
shell_read_vector(&cats, optarg);
22065
case 3: /* logprobs */
22066
logprobs=&v_logprobs; igraph_vector_init(logprobs, 0);
22067
shell_arg_logprobs=strdup(optarg);
22069
case 4: /* logcited */
22070
logcited=&v_logcited; igraph_vector_init(logcited, 0);
22071
shell_arg_logcited=strdup(optarg);
22073
case 5: /* logciting */
22074
logciting=&v_logciting; igraph_vector_init(logciting, 0);
22075
shell_arg_logciting=strdup(optarg);
22078
shell_igraph_revolver_probs_de_usage(argv);
22087
/* Check that we have all arguments */
22088
for (shell_index=0; shell_index<6; shell_index++) {
22089
if (!shell_seen[shell_index]) {
22090
fprintf(stderr, "Error, argument missing: `--%s'.\n",
22091
shell_options[shell_index].name);
22096
/* Do the operation */
22097
shell_result=igraph_revolver_probs_de(&graph, &kernel, &cats, logprobs, logcited, logciting);
22099
/* Write the result */
22100
igraph_destroy(&graph);
22101
igraph_matrix_destroy(&kernel);
22102
igraph_vector_destroy(&cats);
22103
if (logprobs) { shell_write_vector(logprobs, shell_arg_logprobs);
22104
igraph_vector_destroy(logprobs); }
22105
if (logcited) { shell_write_vector(logcited, shell_arg_logcited);
22106
igraph_vector_destroy(logcited); }
22107
if (logciting) { shell_write_vector(logciting, shell_arg_logciting);
22108
igraph_vector_destroy(logciting); }
22113
/*-------------------------------------------/
22114
/ igraph_revolver_ml_ade /
22115
/-------------------------------------------*/
22116
void shell_igraph_revolver_ml_ade_usage(char **argv) {
22117
printf("%s --graph=<graph> --niter=<niter> --cats=<cats> --agebins=<agebins> --delta=<delta> --filter=<filter> --logprob=<logprob> --logmax=<logmax>\n", basename(argv[0]));
22121
int shell_igraph_revolver_ml_ade(int argc, char **argv) {
22124
igraph_integer_t niter;
22126
igraph_vector_t cats;
22128
igraph_integer_t agebins=300;
22129
igraph_real_t delta=1e-10;
22130
igraph_vector_t v_filter; igraph_vector_t *filter=0=NULL;
22131
igraph_real_t logprob;
22132
igraph_real_t logmax;
22133
char* shell_arg_kernel=0;
22134
char* shell_arg_cites=0;
22135
char* shell_arg_logprob=0;
22136
char* shell_arg_logmax=0;
22141
int shell_index=-1;
22142
struct option shell_options[]= { { "graph",required_argument,0,0 },
22143
{ "niter",required_argument,0,1 },
22144
{ "cats",required_argument,0,2 },
22145
{ "agebins",required_argument,0,3 },
22146
{ "delta",required_argument,0,4 },
22147
{ "filter",required_argument,0,5 },
22148
{ "logprob",required_argument,0,6 },
22149
{ "logmax",required_argument,0,7 },
22150
{ "help",no_argument,0,8 },
22154
/* 0 - not seen, 1 - seen as argument, 2 - seen as default */
22155
memset(shell_seen, 0, 8*sizeof(int));
22160
/* Parse arguments and read input */
22161
while (getopt_long(argc, argv, "", shell_options, &shell_index) != -1) {
22163
if (shell_index==-1) {
22167
if (shell_seen[shell_index]==1) {
22168
fprintf(stderr, "Error, `--%s' argument given twice.\n",
22169
shell_options[shell_index].name);
22172
shell_seen[shell_index]=1;
22174
switch (shell_index) {
22175
case 0: /* graph */
22176
shell_read_graph(&graph, optarg);
22178
case 1: /* niter */
22179
shell_read_integer(&niter, optarg);
22182
shell_read_vector(&cats, optarg);
22184
case 3: /* agebins */
22185
shell_read_integer(&agebins, optarg);
22187
case 4: /* delta */
22188
shell_read_real(&delta, optarg);
22190
case 5: /* filter */
22191
filter=&v_filter; shell_read_vector(filter, optarg);
22193
case 6: /* logprob */
22194
shell_arg_logprob=strdup(optarg);
22196
case 7: /* logmax */
22197
shell_arg_logmax=strdup(optarg);
22200
shell_igraph_revolver_ml_ade_usage(argv);
22209
/* Check that we have all arguments */
22210
for (shell_index=0; shell_index<8; shell_index++) {
22211
if (!shell_seen[shell_index]) {
22212
fprintf(stderr, "Error, argument missing: `--%s'.\n",
22213
shell_options[shell_index].name);
22218
/* Do the operation */
22219
shell_result=igraph_revolver_ml_ade(&graph, niter, 0, &cats, 0, agebins, delta, filter, &logprob, &logmax);
22221
/* Write the result */
22222
igraph_destroy(&graph);
22223
igraph_vector_destroy(&cats);
22224
if (filter) { igraph_vector_destroy(filter); }
22225
shell_write_real(logprob, shell_arg_logprob);
22226
shell_write_real(logmax, shell_arg_logmax);
22231
/*-------------------------------------------/
22232
/ igraph_revolver_probs_ade /
22233
/-------------------------------------------*/
22234
void shell_igraph_revolver_probs_ade_usage(char **argv) {
22235
printf("%s --graph=<graph> --cats=<cats> --logprobs=<logprobs> --logcited=<logcited> --logciting=<logciting>\n", basename(argv[0]));
22239
int shell_igraph_revolver_probs_ade(int argc, char **argv) {
22243
igraph_vector_t cats;
22244
igraph_vector_t v_logprobs; igraph_vector_t *logprobs=0;
22245
igraph_vector_t v_logcited; igraph_vector_t *logcited=0;
22246
igraph_vector_t v_logciting; igraph_vector_t *logciting=0;
22247
char* shell_arg_logprobs=0;
22248
char* shell_arg_logcited=0;
22249
char* shell_arg_logciting=0;
22254
int shell_index=-1;
22255
struct option shell_options[]= { { "graph",required_argument,0,0 },
22256
{ "cats",required_argument,0,1 },
22257
{ "logprobs",required_argument,0,2 },
22258
{ "logcited",required_argument,0,3 },
22259
{ "logciting",required_argument,0,4 },
22260
{ "help",no_argument,0,5 },
22264
/* 0 - not seen, 1 - seen as argument, 2 - seen as default */
22265
memset(shell_seen, 0, 5*sizeof(int));
22268
/* Parse arguments and read input */
22269
while (getopt_long(argc, argv, "", shell_options, &shell_index) != -1) {
22271
if (shell_index==-1) {
22275
if (shell_seen[shell_index]==1) {
22276
fprintf(stderr, "Error, `--%s' argument given twice.\n",
22277
shell_options[shell_index].name);
22280
shell_seen[shell_index]=1;
22282
switch (shell_index) {
22283
case 0: /* graph */
22284
shell_read_graph(&graph, optarg);
22287
shell_read_vector(&cats, optarg);
22289
case 2: /* logprobs */
22290
logprobs=&v_logprobs; igraph_vector_init(logprobs, 0);
22291
shell_arg_logprobs=strdup(optarg);
22293
case 3: /* logcited */
22294
logcited=&v_logcited; igraph_vector_init(logcited, 0);
22295
shell_arg_logcited=strdup(optarg);
22297
case 4: /* logciting */
22298
logciting=&v_logciting; igraph_vector_init(logciting, 0);
22299
shell_arg_logciting=strdup(optarg);
22302
shell_igraph_revolver_probs_ade_usage(argv);
22311
/* Check that we have all arguments */
22312
for (shell_index=0; shell_index<5; shell_index++) {
22313
if (!shell_seen[shell_index]) {
22314
fprintf(stderr, "Error, argument missing: `--%s'.\n",
22315
shell_options[shell_index].name);
22320
/* Do the operation */
22321
shell_result=igraph_revolver_probs_ade(&graph, 0, &cats, logprobs, logcited, logciting);
22323
/* Write the result */
22324
igraph_destroy(&graph);
22325
igraph_vector_destroy(&cats);
22326
if (logprobs) { shell_write_vector(logprobs, shell_arg_logprobs);
22327
igraph_vector_destroy(logprobs); }
22328
if (logcited) { shell_write_vector(logcited, shell_arg_logcited);
22329
igraph_vector_destroy(logcited); }
22330
if (logciting) { shell_write_vector(logciting, shell_arg_logciting);
22331
igraph_vector_destroy(logciting); }
22336
/*-------------------------------------------/
22337
/ igraph_revolver_ml_f /
22338
/-------------------------------------------*/
22339
void shell_igraph_revolver_ml_f_usage(char **argv) {
22340
printf("%s --graph=<graph> --niter=<niter> --kernel=<kernel> --cites=<cites> --delta=<delta> --logprob=<logprob> --logmax=<logmax>\n", basename(argv[0]));
22344
int shell_igraph_revolver_ml_f(int argc, char **argv) {
22347
igraph_integer_t niter;
22348
igraph_vector_t kernel;
22349
igraph_vector_t v_cites; igraph_vector_t *cites=0;
22350
igraph_real_t delta=1e-10;
22351
igraph_real_t logprob;
22352
igraph_real_t logmax;
22353
char* shell_arg_kernel=0;
22354
char* shell_arg_cites=0;
22355
char* shell_arg_logprob=0;
22356
char* shell_arg_logmax=0;
22361
int shell_index=-1;
22362
struct option shell_options[]= { { "graph",required_argument,0,0 },
22363
{ "niter",required_argument,0,1 },
22364
{ "kernel",required_argument,0,2 },
22365
{ "cites",required_argument,0,3 },
22366
{ "delta",required_argument,0,4 },
22367
{ "logprob",required_argument,0,5 },
22368
{ "logmax",required_argument,0,6 },
22369
{ "help",no_argument,0,7 },
22373
/* 0 - not seen, 1 - seen as argument, 2 - seen as default */
22374
memset(shell_seen, 0, 7*sizeof(int));
22377
/* Parse arguments and read input */
22378
while (getopt_long(argc, argv, "", shell_options, &shell_index) != -1) {
22380
if (shell_index==-1) {
22384
if (shell_seen[shell_index]==1) {
22385
fprintf(stderr, "Error, `--%s' argument given twice.\n",
22386
shell_options[shell_index].name);
22389
shell_seen[shell_index]=1;
22391
switch (shell_index) {
22392
case 0: /* graph */
22393
shell_read_graph(&graph, optarg);
22395
case 1: /* niter */
22396
shell_read_integer(&niter, optarg);
22398
case 2: /* kernel */
22399
shell_arg_kernel=strdup(optarg);
22400
igraph_vector_init(&kernel, 0);
22402
case 3: /* cites */
22403
cites=&v_cites; igraph_vector_init(cites, 0);
22404
shell_arg_cites=strdup(optarg);
22406
case 4: /* delta */
22407
shell_read_real(&delta, optarg);
22409
case 5: /* logprob */
22410
shell_arg_logprob=strdup(optarg);
22412
case 6: /* logmax */
22413
shell_arg_logmax=strdup(optarg);
22416
shell_igraph_revolver_ml_f_usage(argv);
22425
/* Check that we have all arguments */
22426
for (shell_index=0; shell_index<7; shell_index++) {
22427
if (!shell_seen[shell_index]) {
22428
fprintf(stderr, "Error, argument missing: `--%s'.\n",
22429
shell_options[shell_index].name);
22434
/* Do the operation */
22435
shell_result=igraph_revolver_ml_f(&graph, niter, &kernel, cites, delta, &logprob, &logmax);
22437
/* Write the result */
22438
igraph_destroy(&graph);
22439
shell_write_vector(&kernel, shell_arg_kernel);
22440
igraph_vector_destroy(&kernel);
22441
if (cites) { shell_write_vector(cites, shell_arg_cites);
22442
igraph_vector_destroy(cites); }
22443
shell_write_real(logprob, shell_arg_logprob);
22444
shell_write_real(logmax, shell_arg_logmax);
22449
/*-------------------------------------------/
22450
/ igraph_revolver_ml_df /
22451
/-------------------------------------------*/
22452
void shell_igraph_revolver_ml_df_usage(char **argv) {
22453
printf("%s --graph=<graph> --niter=<niter> --kernel=<kernel> --delta=<delta> --logprob=<logprob> --logmax=<logmax>\n", basename(argv[0]));
22457
int shell_igraph_revolver_ml_df(int argc, char **argv) {
22460
igraph_integer_t niter;
22461
igraph_matrix_t kernel;
22463
igraph_real_t delta=1e-10;
22464
igraph_real_t logprob;
22465
igraph_real_t logmax;
22466
char* shell_arg_kernel=0;
22467
char* shell_arg_cites=0;
22468
char* shell_arg_logprob=0;
22469
char* shell_arg_logmax=0;
22474
int shell_index=-1;
22475
struct option shell_options[]= { { "graph",required_argument,0,0 },
22476
{ "niter",required_argument,0,1 },
22477
{ "kernel",required_argument,0,2 },
22478
{ "delta",required_argument,0,3 },
22479
{ "logprob",required_argument,0,4 },
22480
{ "logmax",required_argument,0,5 },
22481
{ "help",no_argument,0,6 },
22485
/* 0 - not seen, 1 - seen as argument, 2 - seen as default */
22486
memset(shell_seen, 0, 6*sizeof(int));
22489
/* Parse arguments and read input */
22490
while (getopt_long(argc, argv, "", shell_options, &shell_index) != -1) {
22492
if (shell_index==-1) {
22496
if (shell_seen[shell_index]==1) {
22497
fprintf(stderr, "Error, `--%s' argument given twice.\n",
22498
shell_options[shell_index].name);
22501
shell_seen[shell_index]=1;
22503
switch (shell_index) {
22504
case 0: /* graph */
22505
shell_read_graph(&graph, optarg);
22507
case 1: /* niter */
22508
shell_read_integer(&niter, optarg);
22510
case 2: /* kernel */
22511
shell_arg_kernel=strdup(optarg);
22512
igraph_matrix_init(&kernel, 0, 0);
22514
case 3: /* delta */
22515
shell_read_real(&delta, optarg);
22517
case 4: /* logprob */
22518
shell_arg_logprob=strdup(optarg);
22520
case 5: /* logmax */
22521
shell_arg_logmax=strdup(optarg);
22524
shell_igraph_revolver_ml_df_usage(argv);
22533
/* Check that we have all arguments */
22534
for (shell_index=0; shell_index<6; shell_index++) {
22535
if (!shell_seen[shell_index]) {
22536
fprintf(stderr, "Error, argument missing: `--%s'.\n",
22537
shell_options[shell_index].name);
22542
/* Do the operation */
22543
shell_result=igraph_revolver_ml_df(&graph, niter, &kernel, 0, delta, &logprob, &logmax);
22545
/* Write the result */
22546
igraph_destroy(&graph);
22547
shell_write_matrix(&kernel, shell_arg_kernel);
22548
igraph_matrix_destroy(&kernel);
22549
shell_write_real(logprob, shell_arg_logprob);
22550
shell_write_real(logmax, shell_arg_logmax);
22555
/*-------------------------------------------/
22556
/ igraph_revolver_ml_l /
22557
/-------------------------------------------*/
22558
void shell_igraph_revolver_ml_l_usage(char **argv) {
22559
printf("%s --graph=<graph> --niter=<niter> --kernel=<kernel> --cites=<cites> --agebins=<agebins> --delta=<delta> --logprob=<logprob> --logmax=<logmax>\n", basename(argv[0]));
22563
int shell_igraph_revolver_ml_l(int argc, char **argv) {
22566
igraph_integer_t niter;
22567
igraph_vector_t kernel;
22568
igraph_vector_t v_cites; igraph_vector_t *cites=0;
22569
igraph_integer_t agebins=300;
22570
igraph_real_t delta=1e-10;
22571
igraph_real_t logprob;
22572
igraph_real_t logmax;
22573
char* shell_arg_kernel=0;
22574
char* shell_arg_cites=0;
22575
char* shell_arg_logprob=0;
22576
char* shell_arg_logmax=0;
22581
int shell_index=-1;
22582
struct option shell_options[]= { { "graph",required_argument,0,0 },
22583
{ "niter",required_argument,0,1 },
22584
{ "kernel",required_argument,0,2 },
22585
{ "cites",required_argument,0,3 },
22586
{ "agebins",required_argument,0,4 },
22587
{ "delta",required_argument,0,5 },
22588
{ "logprob",required_argument,0,6 },
22589
{ "logmax",required_argument,0,7 },
22590
{ "help",no_argument,0,8 },
22594
/* 0 - not seen, 1 - seen as argument, 2 - seen as default */
22595
memset(shell_seen, 0, 8*sizeof(int));
22599
/* Parse arguments and read input */
22600
while (getopt_long(argc, argv, "", shell_options, &shell_index) != -1) {
22602
if (shell_index==-1) {
22606
if (shell_seen[shell_index]==1) {
22607
fprintf(stderr, "Error, `--%s' argument given twice.\n",
22608
shell_options[shell_index].name);
22611
shell_seen[shell_index]=1;
22613
switch (shell_index) {
22614
case 0: /* graph */
22615
shell_read_graph(&graph, optarg);
22617
case 1: /* niter */
22618
shell_read_integer(&niter, optarg);
22620
case 2: /* kernel */
22621
shell_arg_kernel=strdup(optarg);
22622
igraph_vector_init(&kernel, 0);
22624
case 3: /* cites */
22625
cites=&v_cites; igraph_vector_init(cites, 0);
22626
shell_arg_cites=strdup(optarg);
22628
case 4: /* agebins */
22629
shell_read_integer(&agebins, optarg);
22631
case 5: /* delta */
22632
shell_read_real(&delta, optarg);
22634
case 6: /* logprob */
22635
shell_arg_logprob=strdup(optarg);
22637
case 7: /* logmax */
22638
shell_arg_logmax=strdup(optarg);
22641
shell_igraph_revolver_ml_l_usage(argv);
22650
/* Check that we have all arguments */
22651
for (shell_index=0; shell_index<8; shell_index++) {
22652
if (!shell_seen[shell_index]) {
22653
fprintf(stderr, "Error, argument missing: `--%s'.\n",
22654
shell_options[shell_index].name);
22659
/* Do the operation */
22660
shell_result=igraph_revolver_ml_l(&graph, niter, &kernel, cites, agebins, delta, &logprob, &logmax);
22662
/* Write the result */
22663
igraph_destroy(&graph);
22664
shell_write_vector(&kernel, shell_arg_kernel);
22665
igraph_vector_destroy(&kernel);
22666
if (cites) { shell_write_vector(cites, shell_arg_cites);
22667
igraph_vector_destroy(cites); }
22668
shell_write_real(logprob, shell_arg_logprob);
22669
shell_write_real(logmax, shell_arg_logmax);
22674
/*-------------------------------------------/
22675
/ igraph_revolver_ml_ad /
22676
/-------------------------------------------*/
22677
void shell_igraph_revolver_ml_ad_usage(char **argv) {
22678
printf("%s --graph=<graph> --niter=<niter> --kernel=<kernel> --agebins=<agebins> --delta=<delta> --filter=<filter> --logprob=<logprob> --logmax=<logmax>\n", basename(argv[0]));
22682
int shell_igraph_revolver_ml_ad(int argc, char **argv) {
22685
igraph_integer_t niter;
22686
igraph_matrix_t kernel;
22688
igraph_integer_t agebins=300;
22689
igraph_real_t delta=1e-10;
22690
igraph_vector_t v_filter; igraph_vector_t *filter=0=NULL;
22691
igraph_real_t logprob;
22692
igraph_real_t logmax;
22693
char* shell_arg_kernel=0;
22694
char* shell_arg_cites=0;
22695
char* shell_arg_logprob=0;
22696
char* shell_arg_logmax=0;
22701
int shell_index=-1;
22702
struct option shell_options[]= { { "graph",required_argument,0,0 },
22703
{ "niter",required_argument,0,1 },
22704
{ "kernel",required_argument,0,2 },
22705
{ "agebins",required_argument,0,3 },
22706
{ "delta",required_argument,0,4 },
22707
{ "filter",required_argument,0,5 },
22708
{ "logprob",required_argument,0,6 },
22709
{ "logmax",required_argument,0,7 },
22710
{ "help",no_argument,0,8 },
22714
/* 0 - not seen, 1 - seen as argument, 2 - seen as default */
22715
memset(shell_seen, 0, 8*sizeof(int));
22720
/* Parse arguments and read input */
22721
while (getopt_long(argc, argv, "", shell_options, &shell_index) != -1) {
22723
if (shell_index==-1) {
22727
if (shell_seen[shell_index]==1) {
22728
fprintf(stderr, "Error, `--%s' argument given twice.\n",
22729
shell_options[shell_index].name);
22732
shell_seen[shell_index]=1;
22734
switch (shell_index) {
22735
case 0: /* graph */
22736
shell_read_graph(&graph, optarg);
22738
case 1: /* niter */
22739
shell_read_integer(&niter, optarg);
22741
case 2: /* kernel */
22742
shell_arg_kernel=strdup(optarg);
22743
igraph_matrix_init(&kernel, 0, 0);
22745
case 3: /* agebins */
22746
shell_read_integer(&agebins, optarg);
22748
case 4: /* delta */
22749
shell_read_real(&delta, optarg);
22751
case 5: /* filter */
22752
filter=&v_filter; shell_read_vector(filter, optarg);
22754
case 6: /* logprob */
22755
shell_arg_logprob=strdup(optarg);
22757
case 7: /* logmax */
22758
shell_arg_logmax=strdup(optarg);
22761
shell_igraph_revolver_ml_ad_usage(argv);
22770
/* Check that we have all arguments */
22771
for (shell_index=0; shell_index<8; shell_index++) {
22772
if (!shell_seen[shell_index]) {
22773
fprintf(stderr, "Error, argument missing: `--%s'.\n",
22774
shell_options[shell_index].name);
22779
/* Do the operation */
22780
shell_result=igraph_revolver_ml_ad(&graph, niter, &kernel, 0, agebins, delta, filter, &logprob, &logmax);
22782
/* Write the result */
22783
igraph_destroy(&graph);
22784
shell_write_matrix(&kernel, shell_arg_kernel);
22785
igraph_matrix_destroy(&kernel);
22786
if (filter) { igraph_vector_destroy(filter); }
22787
shell_write_real(logprob, shell_arg_logprob);
22788
shell_write_real(logmax, shell_arg_logmax);
22793
/*-------------------------------------------/
22794
/ igraph_revolver_probs_ad /
22795
/-------------------------------------------*/
22796
void shell_igraph_revolver_probs_ad_usage(char **argv) {
22797
printf("%s --graph=<graph> --kernel=<kernel> --probs=<probs> --citedprobs=<citedprobs> --citingprobs=<citingprobs> --ntk=<ntk>\n", basename(argv[0]));
22801
int shell_igraph_revolver_probs_ad(int argc, char **argv) {
22804
igraph_matrix_t kernel;
22805
igraph_vector_t v_probs; igraph_vector_t *probs=0;
22806
igraph_vector_t v_citedprobs; igraph_vector_t *citedprobs=0;
22807
igraph_vector_t v_citingprobs; igraph_vector_t *citingprobs=0;
22808
igraph_bool_t ntk=0;
22809
char* shell_arg_probs=0;
22810
char* shell_arg_citedprobs=0;
22811
char* shell_arg_citingprobs=0;
22816
int shell_index=-1;
22817
struct option shell_options[]= { { "graph",required_argument,0,0 },
22818
{ "kernel",required_argument,0,1 },
22819
{ "probs",required_argument,0,2 },
22820
{ "citedprobs",required_argument,0,3 },
22821
{ "citingprobs",required_argument,0,4 },
22822
{ "ntk",required_argument,0,5 },
22823
{ "help",no_argument,0,6 },
22827
/* 0 - not seen, 1 - seen as argument, 2 - seen as default */
22828
memset(shell_seen, 0, 6*sizeof(int));
22831
/* Parse arguments and read input */
22832
while (getopt_long(argc, argv, "", shell_options, &shell_index) != -1) {
22834
if (shell_index==-1) {
22838
if (shell_seen[shell_index]==1) {
22839
fprintf(stderr, "Error, `--%s' argument given twice.\n",
22840
shell_options[shell_index].name);
22843
shell_seen[shell_index]=1;
22845
switch (shell_index) {
22846
case 0: /* graph */
22847
shell_read_graph(&graph, optarg);
22849
case 1: /* kernel */
22850
shell_read_matrix(&kernel, optarg);
22852
case 2: /* probs */
22853
probs=&v_probs; igraph_vector_init(probs, 0);
22854
shell_arg_probs=strdup(optarg);
22856
case 3: /* citedprobs */
22857
citedprobs=&v_citedprobs; igraph_vector_init(citedprobs, 0);
22858
shell_arg_citedprobs=strdup(optarg);
22860
case 4: /* citingprobs */
22861
citingprobs=&v_citingprobs; igraph_vector_init(citingprobs, 0);
22862
shell_arg_citingprobs=strdup(optarg);
22865
shell_read_boolean(&ntk, optarg);
22868
shell_igraph_revolver_probs_ad_usage(argv);
22877
/* Check that we have all arguments */
22878
for (shell_index=0; shell_index<6; shell_index++) {
22879
if (!shell_seen[shell_index]) {
22880
fprintf(stderr, "Error, argument missing: `--%s'.\n",
22881
shell_options[shell_index].name);
22886
/* Do the operation */
22887
shell_result=igraph_revolver_probs_ad(&graph, &kernel, probs, citedprobs, citingprobs, ntk);
22889
/* Write the result */
22890
igraph_destroy(&graph);
22891
igraph_matrix_destroy(&kernel);
22892
if (probs) { shell_write_vector(probs, shell_arg_probs);
22893
igraph_vector_destroy(probs); }
22894
if (citedprobs) { shell_write_vector(citedprobs, shell_arg_citedprobs);
22895
igraph_vector_destroy(citedprobs); }
22896
if (citingprobs) { shell_write_vector(citingprobs, shell_arg_citingprobs);
22897
igraph_vector_destroy(citingprobs); }
22902
/*-------------------------------------------/
22903
/ igraph_revolver_ml_D_alpha /
22904
/-------------------------------------------*/
22905
void shell_igraph_revolver_ml_D_alpha_usage(char **argv) {
22906
printf("%s --graph=<graph> --alpha=<alpha> --alpha-out=<alpha-out> --Fmin=<Fmin> --abstol=<abstol> --reltol=<reltol> --maxit=<maxit> --filter=<filter> --fncount=<fncount> --grcount=<grcount>\n", basename(argv[0]));
22910
int shell_igraph_revolver_ml_D_alpha(int argc, char **argv) {
22913
igraph_real_t alpha;
22914
igraph_real_t Fmin;
22915
igraph_real_t abstol=1e-8;
22916
igraph_real_t reltol=1e-8;
22918
igraph_vector_t v_filter; igraph_vector_t *filter=0=NULL;
22919
igraph_integer_t fncount;
22920
igraph_integer_t grcount;
22921
char* shell_arg_alpha=0;
22922
char* shell_arg_Fmin=0;
22923
char* shell_arg_fncount=0;
22924
char* shell_arg_grcount=0;
22928
int shell_seen[10];
22929
int shell_index=-1;
22930
struct option shell_options[]= { { "graph",required_argument,0,0 },
22931
{ "alpha",required_argument,0,1 },
22932
{ "alpha-out",required_argument,0,2 },
22933
{ "Fmin",required_argument,0,3 },
22934
{ "abstol",required_argument,0,4 },
22935
{ "reltol",required_argument,0,5 },
22936
{ "maxit",required_argument,0,6 },
22937
{ "filter",required_argument,0,7 },
22938
{ "fncount",required_argument,0,8 },
22939
{ "grcount",required_argument,0,9 },
22940
{ "help",no_argument,0,10 },
22944
/* 0 - not seen, 1 - seen as argument, 2 - seen as default */
22945
memset(shell_seen, 0, 10*sizeof(int));
22951
/* Parse arguments and read input */
22952
while (getopt_long(argc, argv, "", shell_options, &shell_index) != -1) {
22954
if (shell_index==-1) {
22958
if (shell_seen[shell_index]==1) {
22959
fprintf(stderr, "Error, `--%s' argument given twice.\n",
22960
shell_options[shell_index].name);
22963
shell_seen[shell_index]=1;
22965
switch (shell_index) {
22966
case 0: /* graph */
22967
shell_read_graph(&graph, optarg);
22969
case 1: /* alpha */
22970
shell_read_real(&alpha, optarg);
22972
case 2: /* alpha-out */
22973
shell_arg_alpha=strdup(optarg);
22976
shell_arg_Fmin=strdup(optarg);
22978
case 4: /* abstol */
22979
shell_read_real(&abstol, optarg);
22981
case 5: /* reltol */
22982
shell_read_real(&reltol, optarg);
22984
case 6: /* maxit */
22985
shell_read_int(&maxit, optarg);
22987
case 7: /* filter */
22988
filter=&v_filter; shell_read_vector(filter, optarg);
22990
case 8: /* fncount */
22991
shell_arg_fncount=strdup(optarg);
22993
case 9: /* grcount */
22994
shell_arg_grcount=strdup(optarg);
22997
shell_igraph_revolver_ml_D_alpha_usage(argv);
23006
/* Check that we have all arguments */
23007
for (shell_index=0; shell_index<10; shell_index++) {
23008
if (!shell_seen[shell_index]) {
23009
fprintf(stderr, "Error, argument missing: `--%s'.\n",
23010
shell_options[shell_index].name);
23015
/* Do the operation */
23016
shell_result=igraph_revolver_ml_D_alpha(&graph, &alpha, &Fmin, abstol, reltol, maxit, filter, &fncount, &grcount);
23018
/* Write the result */
23019
igraph_destroy(&graph);
23020
shell_write_real(alpha, shell_arg_alpha);
23021
shell_write_real(Fmin, shell_arg_Fmin);
23022
if (filter) { igraph_vector_destroy(filter); }
23023
shell_write_integer(fncount, shell_arg_fncount);
23024
shell_write_integer(grcount, shell_arg_grcount);
23029
/*-------------------------------------------/
23030
/ igraph_revolver_ml_D_alpha_a /
23031
/-------------------------------------------*/
23032
void shell_igraph_revolver_ml_D_alpha_a_usage(char **argv) {
23033
printf("%s --graph=<graph> --alpha=<alpha> --alpha-out=<alpha-out> --a=<a> --a-out=<a-out> --Fmin=<Fmin> --abstol=<abstol> --reltol=<reltol> --maxit=<maxit> --filter=<filter> --fncount=<fncount> --grcount=<grcount>\n", basename(argv[0]));
23037
int shell_igraph_revolver_ml_D_alpha_a(int argc, char **argv) {
23040
igraph_real_t alpha;
23042
igraph_real_t Fmin;
23043
igraph_real_t abstol=1e-8;
23044
igraph_real_t reltol=1e-8;
23046
igraph_vector_t v_filter; igraph_vector_t *filter=0=NULL;
23047
igraph_integer_t fncount;
23048
igraph_integer_t grcount;
23049
char* shell_arg_alpha=0;
23050
char* shell_arg_a=0;
23051
char* shell_arg_Fmin=0;
23052
char* shell_arg_fncount=0;
23053
char* shell_arg_grcount=0;
23057
int shell_seen[12];
23058
int shell_index=-1;
23059
struct option shell_options[]= { { "graph",required_argument,0,0 },
23060
{ "alpha",required_argument,0,1 },
23061
{ "alpha-out",required_argument,0,2 },
23062
{ "a",required_argument,0,3 },
23063
{ "a-out",required_argument,0,4 },
23064
{ "Fmin",required_argument,0,5 },
23065
{ "abstol",required_argument,0,6 },
23066
{ "reltol",required_argument,0,7 },
23067
{ "maxit",required_argument,0,8 },
23068
{ "filter",required_argument,0,9 },
23069
{ "fncount",required_argument,0,10 },
23070
{ "grcount",required_argument,0,11 },
23071
{ "help",no_argument,0,12 },
23075
/* 0 - not seen, 1 - seen as argument, 2 - seen as default */
23076
memset(shell_seen, 0, 12*sizeof(int));
23082
/* Parse arguments and read input */
23083
while (getopt_long(argc, argv, "", shell_options, &shell_index) != -1) {
23085
if (shell_index==-1) {
23089
if (shell_seen[shell_index]==1) {
23090
fprintf(stderr, "Error, `--%s' argument given twice.\n",
23091
shell_options[shell_index].name);
23094
shell_seen[shell_index]=1;
23096
switch (shell_index) {
23097
case 0: /* graph */
23098
shell_read_graph(&graph, optarg);
23100
case 1: /* alpha */
23101
shell_read_real(&alpha, optarg);
23103
case 2: /* alpha-out */
23104
shell_arg_alpha=strdup(optarg);
23107
shell_read_real(&a, optarg);
23109
case 4: /* a-out */
23110
shell_arg_a=strdup(optarg);
23113
shell_arg_Fmin=strdup(optarg);
23115
case 6: /* abstol */
23116
shell_read_real(&abstol, optarg);
23118
case 7: /* reltol */
23119
shell_read_real(&reltol, optarg);
23121
case 8: /* maxit */
23122
shell_read_int(&maxit, optarg);
23124
case 9: /* filter */
23125
filter=&v_filter; shell_read_vector(filter, optarg);
23127
case 10: /* fncount */
23128
shell_arg_fncount=strdup(optarg);
23130
case 11: /* grcount */
23131
shell_arg_grcount=strdup(optarg);
23134
shell_igraph_revolver_ml_D_alpha_a_usage(argv);
23143
/* Check that we have all arguments */
23144
for (shell_index=0; shell_index<12; shell_index++) {
23145
if (!shell_seen[shell_index]) {
23146
fprintf(stderr, "Error, argument missing: `--%s'.\n",
23147
shell_options[shell_index].name);
23152
/* Do the operation */
23153
shell_result=igraph_revolver_ml_D_alpha_a(&graph, &alpha, &a, &Fmin, abstol, reltol, maxit, filter, &fncount, &grcount);
23155
/* Write the result */
23156
igraph_destroy(&graph);
23157
shell_write_real(alpha, shell_arg_alpha);
23158
shell_write_real(a, shell_arg_a);
23159
shell_write_real(Fmin, shell_arg_Fmin);
23160
if (filter) { igraph_vector_destroy(filter); }
23161
shell_write_integer(fncount, shell_arg_fncount);
23162
shell_write_integer(grcount, shell_arg_grcount);
23167
/*-------------------------------------------/
23168
/ igraph_revolver_ml_DE_alpha_a /
23169
/-------------------------------------------*/
23170
void shell_igraph_revolver_ml_DE_alpha_a_usage(char **argv) {
23171
printf("%s --graph=<graph> --cats=<cats> --alpha=<alpha> --alpha-out=<alpha-out> --a=<a> --a-out=<a-out> --coeffs=<coeffs> --coeffs-out=<coeffs-out> --Fmin=<Fmin> --abstol=<abstol> --reltol=<reltol> --maxit=<maxit> --filter=<filter> --fncount=<fncount> --grcount=<grcount>\n", basename(argv[0]));
23175
int shell_igraph_revolver_ml_DE_alpha_a(int argc, char **argv) {
23178
igraph_vector_t cats;
23179
igraph_real_t alpha;
23181
igraph_vector_t coeffs;
23182
igraph_real_t Fmin;
23183
igraph_real_t abstol=1e-8;
23184
igraph_real_t reltol=1e-8;
23186
igraph_vector_t v_filter; igraph_vector_t *filter=0=NULL;
23187
igraph_integer_t fncount;
23188
igraph_integer_t grcount;
23189
char* shell_arg_alpha=0;
23190
char* shell_arg_a=0;
23191
char* shell_arg_coeffs=0;
23192
char* shell_arg_Fmin=0;
23193
char* shell_arg_fncount=0;
23194
char* shell_arg_grcount=0;
23198
int shell_seen[15];
23199
int shell_index=-1;
23200
struct option shell_options[]= { { "graph",required_argument,0,0 },
23201
{ "cats",required_argument,0,1 },
23202
{ "alpha",required_argument,0,2 },
23203
{ "alpha-out",required_argument,0,3 },
23204
{ "a",required_argument,0,4 },
23205
{ "a-out",required_argument,0,5 },
23206
{ "coeffs",required_argument,0,6 },
23207
{ "coeffs-out",required_argument,0,7 },
23208
{ "Fmin",required_argument,0,8 },
23209
{ "abstol",required_argument,0,9 },
23210
{ "reltol",required_argument,0,10 },
23211
{ "maxit",required_argument,0,11 },
23212
{ "filter",required_argument,0,12 },
23213
{ "fncount",required_argument,0,13 },
23214
{ "grcount",required_argument,0,14 },
23215
{ "help",no_argument,0,15 },
23219
/* 0 - not seen, 1 - seen as argument, 2 - seen as default */
23220
memset(shell_seen, 0, 15*sizeof(int));
23226
/* Parse arguments and read input */
23227
while (getopt_long(argc, argv, "", shell_options, &shell_index) != -1) {
23229
if (shell_index==-1) {
23233
if (shell_seen[shell_index]==1) {
23234
fprintf(stderr, "Error, `--%s' argument given twice.\n",
23235
shell_options[shell_index].name);
23238
shell_seen[shell_index]=1;
23240
switch (shell_index) {
23241
case 0: /* graph */
23242
shell_read_graph(&graph, optarg);
23245
shell_read_vector(&cats, optarg);
23247
case 2: /* alpha */
23248
shell_read_real(&alpha, optarg);
23250
case 3: /* alpha-out */
23251
shell_arg_alpha=strdup(optarg);
23254
shell_read_real(&a, optarg);
23256
case 5: /* a-out */
23257
shell_arg_a=strdup(optarg);
23259
case 6: /* coeffs */
23260
shell_read_vector(&coeffs, optarg);
23262
case 7: /* coeffs-out */
23263
shell_arg_coeffs=strdup(optarg);
23264
igraph_vector_init(&coeffs, 0);
23267
shell_arg_Fmin=strdup(optarg);
23269
case 9: /* abstol */
23270
shell_read_real(&abstol, optarg);
23272
case 10: /* reltol */
23273
shell_read_real(&reltol, optarg);
23275
case 11: /* maxit */
23276
shell_read_int(&maxit, optarg);
23278
case 12: /* filter */
23279
filter=&v_filter; shell_read_vector(filter, optarg);
23281
case 13: /* fncount */
23282
shell_arg_fncount=strdup(optarg);
23284
case 14: /* grcount */
23285
shell_arg_grcount=strdup(optarg);
23288
shell_igraph_revolver_ml_DE_alpha_a_usage(argv);
23297
/* Check that we have all arguments */
23298
for (shell_index=0; shell_index<15; shell_index++) {
23299
if (!shell_seen[shell_index]) {
23300
fprintf(stderr, "Error, argument missing: `--%s'.\n",
23301
shell_options[shell_index].name);
23306
/* Do the operation */
23307
shell_result=igraph_revolver_ml_DE_alpha_a(&graph, &cats, &alpha, &a, &coeffs, &Fmin, abstol, reltol, maxit, filter, &fncount, &grcount);
23309
/* Write the result */
23310
igraph_destroy(&graph);
23311
igraph_vector_destroy(&cats);
23312
shell_write_real(alpha, shell_arg_alpha);
23313
shell_write_real(a, shell_arg_a);
23314
igraph_vector_destroy(&coeffs);
23315
shell_write_vector(&coeffs, shell_arg_coeffs);
23316
igraph_vector_destroy(&coeffs);
23317
shell_write_real(Fmin, shell_arg_Fmin);
23318
if (filter) { igraph_vector_destroy(filter); }
23319
shell_write_integer(fncount, shell_arg_fncount);
23320
shell_write_integer(grcount, shell_arg_grcount);
23325
/*-------------------------------------------/
23326
/ igraph_revolver_ml_AD_alpha_a_beta /
23327
/-------------------------------------------*/
23328
void shell_igraph_revolver_ml_AD_alpha_a_beta_usage(char **argv) {
23329
printf("%s --graph=<graph> --alpha=<alpha> --alpha-out=<alpha-out> --a=<a> --a-out=<a-out> --beta=<beta> --beta-out=<beta-out> --Fmin=<Fmin> --abstol=<abstol> --reltol=<reltol> --maxit=<maxit> --agebins=<agebins> --filter=<filter> --fncount=<fncount> --grcount=<grcount>\n", basename(argv[0]));
23333
int shell_igraph_revolver_ml_AD_alpha_a_beta(int argc, char **argv) {
23336
igraph_real_t alpha;
23338
igraph_real_t beta;
23339
igraph_real_t Fmin;
23340
igraph_real_t abstol=1e-8;
23341
igraph_real_t reltol=1e-8;
23344
igraph_vector_t v_filter; igraph_vector_t *filter=0=NULL;
23345
igraph_integer_t fncount;
23346
igraph_integer_t grcount;
23347
char* shell_arg_alpha=0;
23348
char* shell_arg_a=0;
23349
char* shell_arg_beta=0;
23350
char* shell_arg_Fmin=0;
23351
char* shell_arg_fncount=0;
23352
char* shell_arg_grcount=0;
23356
int shell_seen[15];
23357
int shell_index=-1;
23358
struct option shell_options[]= { { "graph",required_argument,0,0 },
23359
{ "alpha",required_argument,0,1 },
23360
{ "alpha-out",required_argument,0,2 },
23361
{ "a",required_argument,0,3 },
23362
{ "a-out",required_argument,0,4 },
23363
{ "beta",required_argument,0,5 },
23364
{ "beta-out",required_argument,0,6 },
23365
{ "Fmin",required_argument,0,7 },
23366
{ "abstol",required_argument,0,8 },
23367
{ "reltol",required_argument,0,9 },
23368
{ "maxit",required_argument,0,10 },
23369
{ "agebins",required_argument,0,11 },
23370
{ "filter",required_argument,0,12 },
23371
{ "fncount",required_argument,0,13 },
23372
{ "grcount",required_argument,0,14 },
23373
{ "help",no_argument,0,15 },
23377
/* 0 - not seen, 1 - seen as argument, 2 - seen as default */
23378
memset(shell_seen, 0, 15*sizeof(int));
23385
/* Parse arguments and read input */
23386
while (getopt_long(argc, argv, "", shell_options, &shell_index) != -1) {
23388
if (shell_index==-1) {
23392
if (shell_seen[shell_index]==1) {
23393
fprintf(stderr, "Error, `--%s' argument given twice.\n",
23394
shell_options[shell_index].name);
23397
shell_seen[shell_index]=1;
23399
switch (shell_index) {
23400
case 0: /* graph */
23401
shell_read_graph(&graph, optarg);
23403
case 1: /* alpha */
23404
shell_read_real(&alpha, optarg);
23406
case 2: /* alpha-out */
23407
shell_arg_alpha=strdup(optarg);
23410
shell_read_real(&a, optarg);
23412
case 4: /* a-out */
23413
shell_arg_a=strdup(optarg);
23416
shell_read_real(&beta, optarg);
23418
case 6: /* beta-out */
23419
shell_arg_beta=strdup(optarg);
23422
shell_arg_Fmin=strdup(optarg);
23424
case 8: /* abstol */
23425
shell_read_real(&abstol, optarg);
23427
case 9: /* reltol */
23428
shell_read_real(&reltol, optarg);
23430
case 10: /* maxit */
23431
shell_read_int(&maxit, optarg);
23433
case 11: /* agebins */
23434
shell_read_int(&agebins, optarg);
23436
case 12: /* filter */
23437
filter=&v_filter; shell_read_vector(filter, optarg);
23439
case 13: /* fncount */
23440
shell_arg_fncount=strdup(optarg);
23442
case 14: /* grcount */
23443
shell_arg_grcount=strdup(optarg);
23446
shell_igraph_revolver_ml_AD_alpha_a_beta_usage(argv);
23455
/* Check that we have all arguments */
23456
for (shell_index=0; shell_index<15; shell_index++) {
23457
if (!shell_seen[shell_index]) {
23458
fprintf(stderr, "Error, argument missing: `--%s'.\n",
23459
shell_options[shell_index].name);
23464
/* Do the operation */
23465
shell_result=igraph_revolver_ml_AD_alpha_a_beta(&graph, &alpha, &a, &beta, &Fmin, abstol, reltol, maxit, agebins, filter, &fncount, &grcount);
23467
/* Write the result */
23468
igraph_destroy(&graph);
23469
shell_write_real(alpha, shell_arg_alpha);
23470
shell_write_real(a, shell_arg_a);
23471
shell_write_real(beta, shell_arg_beta);
23472
shell_write_real(Fmin, shell_arg_Fmin);
23473
if (filter) { igraph_vector_destroy(filter); }
23474
shell_write_integer(fncount, shell_arg_fncount);
23475
shell_write_integer(grcount, shell_arg_grcount);
23480
/*-------------------------------------------/
23481
/ igraph_revolver_ml_AD_dpareto /
23482
/-------------------------------------------*/
23483
void shell_igraph_revolver_ml_AD_dpareto_usage(char **argv) {
23484
printf("%s --graph=<graph> --alpha=<alpha> --alpha-out=<alpha-out> --a=<a> --a-out=<a-out> --paralpha=<paralpha> --paralpha-out=<paralpha-out> --parbeta=<parbeta> --parbeta-out=<parbeta-out> --parscale=<parscale> --parscale-out=<parscale-out> --Fmin=<Fmin> --abstol=<abstol> --reltol=<reltol> --maxit=<maxit> --agebins=<agebins> --filter=<filter> --fncount=<fncount> --grcount=<grcount>\n", basename(argv[0]));
23488
int shell_igraph_revolver_ml_AD_dpareto(int argc, char **argv) {
23491
igraph_real_t alpha;
23493
igraph_real_t paralpha;
23494
igraph_real_t parbeta;
23495
igraph_real_t parscale;
23496
igraph_real_t Fmin;
23497
igraph_real_t abstol=1e-8;
23498
igraph_real_t reltol=1e-8;
23501
igraph_vector_t v_filter; igraph_vector_t *filter=0=NULL;
23502
igraph_integer_t fncount;
23503
igraph_integer_t grcount;
23504
char* shell_arg_alpha=0;
23505
char* shell_arg_a=0;
23506
char* shell_arg_paralpha=0;
23507
char* shell_arg_parbeta=0;
23508
char* shell_arg_parscale=0;
23509
char* shell_arg_Fmin=0;
23510
char* shell_arg_fncount=0;
23511
char* shell_arg_grcount=0;
23515
int shell_seen[19];
23516
int shell_index=-1;
23517
struct option shell_options[]= { { "graph",required_argument,0,0 },
23518
{ "alpha",required_argument,0,1 },
23519
{ "alpha-out",required_argument,0,2 },
23520
{ "a",required_argument,0,3 },
23521
{ "a-out",required_argument,0,4 },
23522
{ "paralpha",required_argument,0,5 },
23523
{ "paralpha-out",required_argument,0,6 },
23524
{ "parbeta",required_argument,0,7 },
23525
{ "parbeta-out",required_argument,0,8 },
23526
{ "parscale",required_argument,0,9 },
23527
{ "parscale-out",required_argument,0,10 },
23528
{ "Fmin",required_argument,0,11 },
23529
{ "abstol",required_argument,0,12 },
23530
{ "reltol",required_argument,0,13 },
23531
{ "maxit",required_argument,0,14 },
23532
{ "agebins",required_argument,0,15 },
23533
{ "filter",required_argument,0,16 },
23534
{ "fncount",required_argument,0,17 },
23535
{ "grcount",required_argument,0,18 },
23536
{ "help",no_argument,0,19 },
23540
/* 0 - not seen, 1 - seen as argument, 2 - seen as default */
23541
memset(shell_seen, 0, 19*sizeof(int));
23548
/* Parse arguments and read input */
23549
while (getopt_long(argc, argv, "", shell_options, &shell_index) != -1) {
23551
if (shell_index==-1) {
23555
if (shell_seen[shell_index]==1) {
23556
fprintf(stderr, "Error, `--%s' argument given twice.\n",
23557
shell_options[shell_index].name);
23560
shell_seen[shell_index]=1;
23562
switch (shell_index) {
23563
case 0: /* graph */
23564
shell_read_graph(&graph, optarg);
23566
case 1: /* alpha */
23567
shell_read_real(&alpha, optarg);
23569
case 2: /* alpha-out */
23570
shell_arg_alpha=strdup(optarg);
23573
shell_read_real(&a, optarg);
23575
case 4: /* a-out */
23576
shell_arg_a=strdup(optarg);
23578
case 5: /* paralpha */
23579
shell_read_real(¶lpha, optarg);
23581
case 6: /* paralpha-out */
23582
shell_arg_paralpha=strdup(optarg);
23584
case 7: /* parbeta */
23585
shell_read_real(&parbeta, optarg);
23587
case 8: /* parbeta-out */
23588
shell_arg_parbeta=strdup(optarg);
23590
case 9: /* parscale */
23591
shell_read_real(&parscale, optarg);
23593
case 10: /* parscale-out */
23594
shell_arg_parscale=strdup(optarg);
23596
case 11: /* Fmin */
23597
shell_arg_Fmin=strdup(optarg);
23599
case 12: /* abstol */
23600
shell_read_real(&abstol, optarg);
23602
case 13: /* reltol */
23603
shell_read_real(&reltol, optarg);
23605
case 14: /* maxit */
23606
shell_read_int(&maxit, optarg);
23608
case 15: /* agebins */
23609
shell_read_int(&agebins, optarg);
23611
case 16: /* filter */
23612
filter=&v_filter; shell_read_vector(filter, optarg);
23614
case 17: /* fncount */
23615
shell_arg_fncount=strdup(optarg);
23617
case 18: /* grcount */
23618
shell_arg_grcount=strdup(optarg);
23621
shell_igraph_revolver_ml_AD_dpareto_usage(argv);
23630
/* Check that we have all arguments */
23631
for (shell_index=0; shell_index<19; shell_index++) {
23632
if (!shell_seen[shell_index]) {
23633
fprintf(stderr, "Error, argument missing: `--%s'.\n",
23634
shell_options[shell_index].name);
23639
/* Do the operation */
23640
shell_result=igraph_revolver_ml_AD_dpareto(&graph, &alpha, &a, ¶lpha, &parbeta, &parscale, &Fmin, abstol, reltol, maxit, agebins, filter, &fncount, &grcount);
23642
/* Write the result */
23643
igraph_destroy(&graph);
23644
shell_write_real(alpha, shell_arg_alpha);
23645
shell_write_real(a, shell_arg_a);
23646
shell_write_real(paralpha, shell_arg_paralpha);
23647
shell_write_real(parbeta, shell_arg_parbeta);
23648
shell_write_real(parscale, shell_arg_parscale);
23649
shell_write_real(Fmin, shell_arg_Fmin);
23650
if (filter) { igraph_vector_destroy(filter); }
23651
shell_write_integer(fncount, shell_arg_fncount);
23652
shell_write_integer(grcount, shell_arg_grcount);
23657
/*-------------------------------------------/
23658
/ igraph_revolver_ml_AD_dpareto_eval /
23659
/-------------------------------------------*/
23660
void shell_igraph_revolver_ml_AD_dpareto_eval_usage(char **argv) {
23661
printf("%s --graph=<graph> --alpha=<alpha> --a=<a> --paralpha=<paralpha> --parbeta=<parbeta> --parscale=<parscale> --value=<value> --deriv=<deriv> --agebins=<agebins> --filter=<filter>\n", basename(argv[0]));
23665
int shell_igraph_revolver_ml_AD_dpareto_eval(int argc, char **argv) {
23668
igraph_real_t alpha;
23670
igraph_real_t paralpha;
23671
igraph_real_t parbeta;
23672
igraph_real_t parscale;
23673
igraph_real_t value;
23674
igraph_vector_t deriv;
23676
igraph_vector_t v_filter; igraph_vector_t *filter=0=NULL;
23677
char* shell_arg_value=0;
23678
char* shell_arg_deriv=0;
23682
int shell_seen[10];
23683
int shell_index=-1;
23684
struct option shell_options[]= { { "graph",required_argument,0,0 },
23685
{ "alpha",required_argument,0,1 },
23686
{ "a",required_argument,0,2 },
23687
{ "paralpha",required_argument,0,3 },
23688
{ "parbeta",required_argument,0,4 },
23689
{ "parscale",required_argument,0,5 },
23690
{ "value",required_argument,0,6 },
23691
{ "deriv",required_argument,0,7 },
23692
{ "agebins",required_argument,0,8 },
23693
{ "filter",required_argument,0,9 },
23694
{ "help",no_argument,0,10 },
23698
/* 0 - not seen, 1 - seen as argument, 2 - seen as default */
23699
memset(shell_seen, 0, 10*sizeof(int));
23703
/* Parse arguments and read input */
23704
while (getopt_long(argc, argv, "", shell_options, &shell_index) != -1) {
23706
if (shell_index==-1) {
23710
if (shell_seen[shell_index]==1) {
23711
fprintf(stderr, "Error, `--%s' argument given twice.\n",
23712
shell_options[shell_index].name);
23715
shell_seen[shell_index]=1;
23717
switch (shell_index) {
23718
case 0: /* graph */
23719
shell_read_graph(&graph, optarg);
23721
case 1: /* alpha */
23722
shell_read_real(&alpha, optarg);
23725
shell_read_real(&a, optarg);
23727
case 3: /* paralpha */
23728
shell_read_real(¶lpha, optarg);
23730
case 4: /* parbeta */
23731
shell_read_real(&parbeta, optarg);
23733
case 5: /* parscale */
23734
shell_read_real(&parscale, optarg);
23736
case 6: /* value */
23737
shell_arg_value=strdup(optarg);
23739
case 7: /* deriv */
23740
shell_arg_deriv=strdup(optarg);
23741
igraph_vector_init(&deriv, 0);
23743
case 8: /* agebins */
23744
shell_read_int(&agebins, optarg);
23746
case 9: /* filter */
23747
filter=&v_filter; shell_read_vector(filter, optarg);
23750
shell_igraph_revolver_ml_AD_dpareto_eval_usage(argv);
23759
/* Check that we have all arguments */
23760
for (shell_index=0; shell_index<10; shell_index++) {
23761
if (!shell_seen[shell_index]) {
23762
fprintf(stderr, "Error, argument missing: `--%s'.\n",
23763
shell_options[shell_index].name);
23768
/* Do the operation */
23769
shell_result=igraph_revolver_ml_AD_dpareto_eval(&graph, alpha, a, paralpha, parbeta, parscale, &value, &deriv, agebins, filter);
23771
/* Write the result */
23772
igraph_destroy(&graph);
23773
shell_write_real(value, shell_arg_value);
23774
shell_write_vector(&deriv, shell_arg_deriv);
23775
igraph_vector_destroy(&deriv);
23776
if (filter) { igraph_vector_destroy(filter); }
23781
/*-------------------------------------------/
23782
/ igraph_revolver_ml_ADE_alpha_a_beta /
23783
/-------------------------------------------*/
23784
void shell_igraph_revolver_ml_ADE_alpha_a_beta_usage(char **argv) {
23785
printf("%s --graph=<graph> --cats=<cats> --alpha=<alpha> --alpha-out=<alpha-out> --a=<a> --a-out=<a-out> --beta=<beta> --beta-out=<beta-out> --coeffs=<coeffs> --coeffs-out=<coeffs-out> --Fmin=<Fmin> --abstol=<abstol> --reltol=<reltol> --maxit=<maxit> --agebins=<agebins> --filter=<filter> --fncount=<fncount> --grcount=<grcount>\n", basename(argv[0]));
23789
int shell_igraph_revolver_ml_ADE_alpha_a_beta(int argc, char **argv) {
23792
igraph_vector_t cats;
23793
igraph_real_t alpha;
23795
igraph_real_t beta;
23796
igraph_vector_t coeffs;
23797
igraph_real_t Fmin;
23798
igraph_real_t abstol=1e-8;
23799
igraph_real_t reltol=1e-8;
23802
igraph_vector_t v_filter; igraph_vector_t *filter=0=NULL;
23803
igraph_integer_t fncount;
23804
igraph_integer_t grcount;
23805
char* shell_arg_alpha=0;
23806
char* shell_arg_a=0;
23807
char* shell_arg_beta=0;
23808
char* shell_arg_coeffs=0;
23809
char* shell_arg_Fmin=0;
23810
char* shell_arg_fncount=0;
23811
char* shell_arg_grcount=0;
23815
int shell_seen[18];
23816
int shell_index=-1;
23817
struct option shell_options[]= { { "graph",required_argument,0,0 },
23818
{ "cats",required_argument,0,1 },
23819
{ "alpha",required_argument,0,2 },
23820
{ "alpha-out",required_argument,0,3 },
23821
{ "a",required_argument,0,4 },
23822
{ "a-out",required_argument,0,5 },
23823
{ "beta",required_argument,0,6 },
23824
{ "beta-out",required_argument,0,7 },
23825
{ "coeffs",required_argument,0,8 },
23826
{ "coeffs-out",required_argument,0,9 },
23827
{ "Fmin",required_argument,0,10 },
23828
{ "abstol",required_argument,0,11 },
23829
{ "reltol",required_argument,0,12 },
23830
{ "maxit",required_argument,0,13 },
23831
{ "agebins",required_argument,0,14 },
23832
{ "filter",required_argument,0,15 },
23833
{ "fncount",required_argument,0,16 },
23834
{ "grcount",required_argument,0,17 },
23835
{ "help",no_argument,0,18 },
23839
/* 0 - not seen, 1 - seen as argument, 2 - seen as default */
23840
memset(shell_seen, 0, 18*sizeof(int));
23847
/* Parse arguments and read input */
23848
while (getopt_long(argc, argv, "", shell_options, &shell_index) != -1) {
23850
if (shell_index==-1) {
23854
if (shell_seen[shell_index]==1) {
23855
fprintf(stderr, "Error, `--%s' argument given twice.\n",
23856
shell_options[shell_index].name);
23859
shell_seen[shell_index]=1;
23861
switch (shell_index) {
23862
case 0: /* graph */
23863
shell_read_graph(&graph, optarg);
23866
shell_read_vector(&cats, optarg);
23868
case 2: /* alpha */
23869
shell_read_real(&alpha, optarg);
23871
case 3: /* alpha-out */
23872
shell_arg_alpha=strdup(optarg);
23875
shell_read_real(&a, optarg);
23877
case 5: /* a-out */
23878
shell_arg_a=strdup(optarg);
23881
shell_read_real(&beta, optarg);
23883
case 7: /* beta-out */
23884
shell_arg_beta=strdup(optarg);
23886
case 8: /* coeffs */
23887
shell_read_vector(&coeffs, optarg);
23889
case 9: /* coeffs-out */
23890
shell_arg_coeffs=strdup(optarg);
23891
igraph_vector_init(&coeffs, 0);
23893
case 10: /* Fmin */
23894
shell_arg_Fmin=strdup(optarg);
23896
case 11: /* abstol */
23897
shell_read_real(&abstol, optarg);
23899
case 12: /* reltol */
23900
shell_read_real(&reltol, optarg);
23902
case 13: /* maxit */
23903
shell_read_int(&maxit, optarg);
23905
case 14: /* agebins */
23906
shell_read_int(&agebins, optarg);
23908
case 15: /* filter */
23909
filter=&v_filter; shell_read_vector(filter, optarg);
23911
case 16: /* fncount */
23912
shell_arg_fncount=strdup(optarg);
23914
case 17: /* grcount */
23915
shell_arg_grcount=strdup(optarg);
23918
shell_igraph_revolver_ml_ADE_alpha_a_beta_usage(argv);
23927
/* Check that we have all arguments */
23928
for (shell_index=0; shell_index<18; shell_index++) {
23929
if (!shell_seen[shell_index]) {
23930
fprintf(stderr, "Error, argument missing: `--%s'.\n",
23931
shell_options[shell_index].name);
23936
/* Do the operation */
23937
shell_result=igraph_revolver_ml_ADE_alpha_a_beta(&graph, &cats, &alpha, &a, &beta, &coeffs, &Fmin, abstol, reltol, maxit, agebins, filter, &fncount, &grcount);
23939
/* Write the result */
23940
igraph_destroy(&graph);
23941
igraph_vector_destroy(&cats);
23942
shell_write_real(alpha, shell_arg_alpha);
23943
shell_write_real(a, shell_arg_a);
23944
shell_write_real(beta, shell_arg_beta);
23945
igraph_vector_destroy(&coeffs);
23946
shell_write_vector(&coeffs, shell_arg_coeffs);
23947
igraph_vector_destroy(&coeffs);
23948
shell_write_real(Fmin, shell_arg_Fmin);
23949
if (filter) { igraph_vector_destroy(filter); }
23950
shell_write_integer(fncount, shell_arg_fncount);
23951
shell_write_integer(grcount, shell_arg_grcount);
23956
/*-------------------------------------------/
23957
/ igraph_revolver_ml_ADE_dpareto /
23958
/-------------------------------------------*/
23959
void shell_igraph_revolver_ml_ADE_dpareto_usage(char **argv) {
23960
printf("%s --graph=<graph> --cats=<cats> --alpha=<alpha> --alpha-out=<alpha-out> --a=<a> --a-out=<a-out> --paralpha=<paralpha> --paralpha-out=<paralpha-out> --parbeta=<parbeta> --parbeta-out=<parbeta-out> --parscale=<parscale> --parscale-out=<parscale-out> --coeffs=<coeffs> --coeffs-out=<coeffs-out> --Fmin=<Fmin> --abstol=<abstol> --reltol=<reltol> --maxit=<maxit> --agebins=<agebins> --filter=<filter> --fncount=<fncount> --grcount=<grcount>\n", basename(argv[0]));
23964
int shell_igraph_revolver_ml_ADE_dpareto(int argc, char **argv) {
23967
igraph_vector_t cats;
23968
igraph_real_t alpha;
23970
igraph_real_t paralpha;
23971
igraph_real_t parbeta;
23972
igraph_real_t parscale;
23973
igraph_vector_t coeffs;
23974
igraph_real_t Fmin;
23975
igraph_real_t abstol=1e-8;
23976
igraph_real_t reltol=1e-8;
23979
igraph_vector_t v_filter; igraph_vector_t *filter=0=NULL;
23980
igraph_integer_t fncount;
23981
igraph_integer_t grcount;
23982
char* shell_arg_alpha=0;
23983
char* shell_arg_a=0;
23984
char* shell_arg_paralpha=0;
23985
char* shell_arg_parbeta=0;
23986
char* shell_arg_parscale=0;
23987
char* shell_arg_coeffs=0;
23988
char* shell_arg_Fmin=0;
23989
char* shell_arg_fncount=0;
23990
char* shell_arg_grcount=0;
23994
int shell_seen[22];
23995
int shell_index=-1;
23996
struct option shell_options[]= { { "graph",required_argument,0,0 },
23997
{ "cats",required_argument,0,1 },
23998
{ "alpha",required_argument,0,2 },
23999
{ "alpha-out",required_argument,0,3 },
24000
{ "a",required_argument,0,4 },
24001
{ "a-out",required_argument,0,5 },
24002
{ "paralpha",required_argument,0,6 },
24003
{ "paralpha-out",required_argument,0,7 },
24004
{ "parbeta",required_argument,0,8 },
24005
{ "parbeta-out",required_argument,0,9 },
24006
{ "parscale",required_argument,0,10 },
24007
{ "parscale-out",required_argument,0,11 },
24008
{ "coeffs",required_argument,0,12 },
24009
{ "coeffs-out",required_argument,0,13 },
24010
{ "Fmin",required_argument,0,14 },
24011
{ "abstol",required_argument,0,15 },
24012
{ "reltol",required_argument,0,16 },
24013
{ "maxit",required_argument,0,17 },
24014
{ "agebins",required_argument,0,18 },
24015
{ "filter",required_argument,0,19 },
24016
{ "fncount",required_argument,0,20 },
24017
{ "grcount",required_argument,0,21 },
24018
{ "help",no_argument,0,22 },
24022
/* 0 - not seen, 1 - seen as argument, 2 - seen as default */
24023
memset(shell_seen, 0, 22*sizeof(int));
24030
/* Parse arguments and read input */
24031
while (getopt_long(argc, argv, "", shell_options, &shell_index) != -1) {
24033
if (shell_index==-1) {
24037
if (shell_seen[shell_index]==1) {
24038
fprintf(stderr, "Error, `--%s' argument given twice.\n",
24039
shell_options[shell_index].name);
24042
shell_seen[shell_index]=1;
24044
switch (shell_index) {
24045
case 0: /* graph */
24046
shell_read_graph(&graph, optarg);
24049
shell_read_vector(&cats, optarg);
24051
case 2: /* alpha */
24052
shell_read_real(&alpha, optarg);
24054
case 3: /* alpha-out */
24055
shell_arg_alpha=strdup(optarg);
24058
shell_read_real(&a, optarg);
24060
case 5: /* a-out */
24061
shell_arg_a=strdup(optarg);
24063
case 6: /* paralpha */
24064
shell_read_real(¶lpha, optarg);
24066
case 7: /* paralpha-out */
24067
shell_arg_paralpha=strdup(optarg);
24069
case 8: /* parbeta */
24070
shell_read_real(&parbeta, optarg);
24072
case 9: /* parbeta-out */
24073
shell_arg_parbeta=strdup(optarg);
24075
case 10: /* parscale */
24076
shell_read_real(&parscale, optarg);
24078
case 11: /* parscale-out */
24079
shell_arg_parscale=strdup(optarg);
24081
case 12: /* coeffs */
24082
shell_read_vector(&coeffs, optarg);
24084
case 13: /* coeffs-out */
24085
shell_arg_coeffs=strdup(optarg);
24086
igraph_vector_init(&coeffs, 0);
24088
case 14: /* Fmin */
24089
shell_arg_Fmin=strdup(optarg);
24091
case 15: /* abstol */
24092
shell_read_real(&abstol, optarg);
24094
case 16: /* reltol */
24095
shell_read_real(&reltol, optarg);
24097
case 17: /* maxit */
24098
shell_read_int(&maxit, optarg);
24100
case 18: /* agebins */
24101
shell_read_int(&agebins, optarg);
24103
case 19: /* filter */
24104
filter=&v_filter; shell_read_vector(filter, optarg);
24106
case 20: /* fncount */
24107
shell_arg_fncount=strdup(optarg);
24109
case 21: /* grcount */
24110
shell_arg_grcount=strdup(optarg);
24113
shell_igraph_revolver_ml_ADE_dpareto_usage(argv);
24122
/* Check that we have all arguments */
24123
for (shell_index=0; shell_index<22; shell_index++) {
24124
if (!shell_seen[shell_index]) {
24125
fprintf(stderr, "Error, argument missing: `--%s'.\n",
24126
shell_options[shell_index].name);
24131
/* Do the operation */
24132
shell_result=igraph_revolver_ml_ADE_dpareto(&graph, &cats, &alpha, &a, ¶lpha, &parbeta, &parscale, &coeffs, &Fmin, abstol, reltol, maxit, agebins, filter, &fncount, &grcount);
24134
/* Write the result */
24135
igraph_destroy(&graph);
24136
igraph_vector_destroy(&cats);
24137
shell_write_real(alpha, shell_arg_alpha);
24138
shell_write_real(a, shell_arg_a);
24139
shell_write_real(paralpha, shell_arg_paralpha);
24140
shell_write_real(parbeta, shell_arg_parbeta);
24141
shell_write_real(parscale, shell_arg_parscale);
24142
igraph_vector_destroy(&coeffs);
24143
shell_write_vector(&coeffs, shell_arg_coeffs);
24144
igraph_vector_destroy(&coeffs);
24145
shell_write_real(Fmin, shell_arg_Fmin);
24146
if (filter) { igraph_vector_destroy(filter); }
24147
shell_write_integer(fncount, shell_arg_fncount);
24148
shell_write_integer(grcount, shell_arg_grcount);
24153
/*-------------------------------------------/
24154
/ igraph_revolver_ml_ADE_dpareto_eval /
24155
/-------------------------------------------*/
24156
void shell_igraph_revolver_ml_ADE_dpareto_eval_usage(char **argv) {
24157
printf("%s --graph=<graph> --cats=<cats> --alpha=<alpha> --a=<a> --paralpha=<paralpha> --parbeta=<parbeta> --parscale=<parscale> --coeffs=<coeffs> --value=<value> --deriv=<deriv> --agebins=<agebins> --filter=<filter>\n", basename(argv[0]));
24161
int shell_igraph_revolver_ml_ADE_dpareto_eval(int argc, char **argv) {
24164
igraph_vector_t cats;
24165
igraph_real_t alpha;
24167
igraph_real_t paralpha;
24168
igraph_real_t parbeta;
24169
igraph_real_t parscale;
24170
igraph_vector_t coeffs;
24171
igraph_real_t value;
24172
igraph_vector_t deriv;
24174
igraph_vector_t v_filter; igraph_vector_t *filter=0=NULL;
24175
char* shell_arg_value=0;
24176
char* shell_arg_deriv=0;
24180
int shell_seen[12];
24181
int shell_index=-1;
24182
struct option shell_options[]= { { "graph",required_argument,0,0 },
24183
{ "cats",required_argument,0,1 },
24184
{ "alpha",required_argument,0,2 },
24185
{ "a",required_argument,0,3 },
24186
{ "paralpha",required_argument,0,4 },
24187
{ "parbeta",required_argument,0,5 },
24188
{ "parscale",required_argument,0,6 },
24189
{ "coeffs",required_argument,0,7 },
24190
{ "value",required_argument,0,8 },
24191
{ "deriv",required_argument,0,9 },
24192
{ "agebins",required_argument,0,10 },
24193
{ "filter",required_argument,0,11 },
24194
{ "help",no_argument,0,12 },
24198
/* 0 - not seen, 1 - seen as argument, 2 - seen as default */
24199
memset(shell_seen, 0, 12*sizeof(int));
24203
/* Parse arguments and read input */
24204
while (getopt_long(argc, argv, "", shell_options, &shell_index) != -1) {
24206
if (shell_index==-1) {
24210
if (shell_seen[shell_index]==1) {
24211
fprintf(stderr, "Error, `--%s' argument given twice.\n",
24212
shell_options[shell_index].name);
24215
shell_seen[shell_index]=1;
24217
switch (shell_index) {
24218
case 0: /* graph */
24219
shell_read_graph(&graph, optarg);
24222
shell_read_vector(&cats, optarg);
24224
case 2: /* alpha */
24225
shell_read_real(&alpha, optarg);
24228
shell_read_real(&a, optarg);
24230
case 4: /* paralpha */
24231
shell_read_real(¶lpha, optarg);
24233
case 5: /* parbeta */
24234
shell_read_real(&parbeta, optarg);
24236
case 6: /* parscale */
24237
shell_read_real(&parscale, optarg);
24239
case 7: /* coeffs */
24240
shell_read_vector(&coeffs, optarg);
24242
case 8: /* value */
24243
shell_arg_value=strdup(optarg);
24245
case 9: /* deriv */
24246
shell_arg_deriv=strdup(optarg);
24247
igraph_vector_init(&deriv, 0);
24249
case 10: /* agebins */
24250
shell_read_int(&agebins, optarg);
24252
case 11: /* filter */
24253
filter=&v_filter; shell_read_vector(filter, optarg);
24256
shell_igraph_revolver_ml_ADE_dpareto_eval_usage(argv);
24265
/* Check that we have all arguments */
24266
for (shell_index=0; shell_index<12; shell_index++) {
24267
if (!shell_seen[shell_index]) {
24268
fprintf(stderr, "Error, argument missing: `--%s'.\n",
24269
shell_options[shell_index].name);
24274
/* Do the operation */
24275
shell_result=igraph_revolver_ml_ADE_dpareto_eval(&graph, &cats, alpha, a, paralpha, parbeta, parscale, &coeffs, &value, &deriv, agebins, filter);
24277
/* Write the result */
24278
igraph_destroy(&graph);
24279
igraph_vector_destroy(&cats);
24280
igraph_vector_destroy(&coeffs);
24281
shell_write_real(value, shell_arg_value);
24282
shell_write_vector(&deriv, shell_arg_deriv);
24283
igraph_vector_destroy(&deriv);
24284
if (filter) { igraph_vector_destroy(filter); }
24289
/*-------------------------------------------/
24290
/ igraph_revolver_ml_ADE_dpareto_evalf /
24291
/-------------------------------------------*/
24292
void shell_igraph_revolver_ml_ADE_dpareto_evalf_usage(char **argv) {
24293
printf("%s --graph=<graph> --cats=<cats> --par=<par> --value=<value> --agebins=<agebins> --filter=<filter>\n", basename(argv[0]));
24297
int shell_igraph_revolver_ml_ADE_dpareto_evalf(int argc, char **argv) {
24300
igraph_vector_t cats;
24301
igraph_matrix_t par;
24302
igraph_vector_t value;
24304
igraph_vector_t v_filter; igraph_vector_t *filter=0=NULL;
24305
char* shell_arg_value=0;
24310
int shell_index=-1;
24311
struct option shell_options[]= { { "graph",required_argument,0,0 },
24312
{ "cats",required_argument,0,1 },
24313
{ "par",required_argument,0,2 },
24314
{ "value",required_argument,0,3 },
24315
{ "agebins",required_argument,0,4 },
24316
{ "filter",required_argument,0,5 },
24317
{ "help",no_argument,0,6 },
24321
/* 0 - not seen, 1 - seen as argument, 2 - seen as default */
24322
memset(shell_seen, 0, 6*sizeof(int));
24325
/* Parse arguments and read input */
24326
while (getopt_long(argc, argv, "", shell_options, &shell_index) != -1) {
24328
if (shell_index==-1) {
24332
if (shell_seen[shell_index]==1) {
24333
fprintf(stderr, "Error, `--%s' argument given twice.\n",
24334
shell_options[shell_index].name);
24337
shell_seen[shell_index]=1;
24339
switch (shell_index) {
24340
case 0: /* graph */
24341
shell_read_graph(&graph, optarg);
24344
shell_read_vector(&cats, optarg);
24347
shell_read_matrix(&par, optarg);
24349
case 3: /* value */
24350
shell_arg_value=strdup(optarg);
24351
igraph_vector_init(&value, 0);
24353
case 4: /* agebins */
24354
shell_read_int(&agebins, optarg);
24356
case 5: /* filter */
24357
filter=&v_filter; shell_read_vector(filter, optarg);
24360
shell_igraph_revolver_ml_ADE_dpareto_evalf_usage(argv);
24369
/* Check that we have all arguments */
24370
for (shell_index=0; shell_index<6; shell_index++) {
24371
if (!shell_seen[shell_index]) {
24372
fprintf(stderr, "Error, argument missing: `--%s'.\n",
24373
shell_options[shell_index].name);
24378
/* Do the operation */
24379
shell_result=igraph_revolver_ml_ADE_dpareto_evalf(&graph, &cats, &par, &value, agebins, filter);
24381
/* Write the result */
24382
igraph_destroy(&graph);
24383
igraph_vector_destroy(&cats);
24384
igraph_matrix_destroy(&par);
24385
shell_write_vector(&value, shell_arg_value);
24386
igraph_vector_destroy(&value);
24387
if (filter) { igraph_vector_destroy(filter); }
24392
/*-------------------------------------------/
24393
/ igraph_revolver_probs_ADE_dpareto /
24394
/-------------------------------------------*/
24395
void shell_igraph_revolver_probs_ADE_dpareto_usage(char **argv) {
24396
printf("%s --graph=<graph> --par=<par> --cats=<cats> --gcats=<gcats> --agebins=<agebins> --logprobs=<logprobs> --logcited=<logcited> --logciting=<logciting>\n", basename(argv[0]));
24400
int shell_igraph_revolver_probs_ADE_dpareto(int argc, char **argv) {
24403
igraph_matrix_t par;
24404
igraph_vector_t cats;
24405
igraph_vector_t gcats;
24407
igraph_vector_t v_logprobs; igraph_vector_t *logprobs=0;
24408
igraph_vector_t v_logcited; igraph_vector_t *logcited=0;
24409
igraph_vector_t v_logciting; igraph_vector_t *logciting=0;
24410
char* shell_arg_logprobs=0;
24411
char* shell_arg_logcited=0;
24412
char* shell_arg_logciting=0;
24417
int shell_index=-1;
24418
struct option shell_options[]= { { "graph",required_argument,0,0 },
24419
{ "par",required_argument,0,1 },
24420
{ "cats",required_argument,0,2 },
24421
{ "gcats",required_argument,0,3 },
24422
{ "agebins",required_argument,0,4 },
24423
{ "logprobs",required_argument,0,5 },
24424
{ "logcited",required_argument,0,6 },
24425
{ "logciting",required_argument,0,7 },
24426
{ "help",no_argument,0,8 },
24430
/* 0 - not seen, 1 - seen as argument, 2 - seen as default */
24431
memset(shell_seen, 0, 8*sizeof(int));
24434
/* Parse arguments and read input */
24435
while (getopt_long(argc, argv, "", shell_options, &shell_index) != -1) {
24437
if (shell_index==-1) {
24441
if (shell_seen[shell_index]==1) {
24442
fprintf(stderr, "Error, `--%s' argument given twice.\n",
24443
shell_options[shell_index].name);
24446
shell_seen[shell_index]=1;
24448
switch (shell_index) {
24449
case 0: /* graph */
24450
shell_read_graph(&graph, optarg);
24453
shell_read_matrix(&par, optarg);
24456
shell_read_vector(&cats, optarg);
24458
case 3: /* gcats */
24459
shell_read_vector(&gcats, optarg);
24461
case 4: /* agebins */
24462
shell_read_int(&agebins, optarg);
24464
case 5: /* logprobs */
24465
logprobs=&v_logprobs; igraph_vector_init(logprobs, 0);
24466
shell_arg_logprobs=strdup(optarg);
24468
case 6: /* logcited */
24469
logcited=&v_logcited; igraph_vector_init(logcited, 0);
24470
shell_arg_logcited=strdup(optarg);
24472
case 7: /* logciting */
24473
logciting=&v_logciting; igraph_vector_init(logciting, 0);
24474
shell_arg_logciting=strdup(optarg);
24477
shell_igraph_revolver_probs_ADE_dpareto_usage(argv);
24486
/* Check that we have all arguments */
24487
for (shell_index=0; shell_index<8; shell_index++) {
24488
if (!shell_seen[shell_index]) {
24489
fprintf(stderr, "Error, argument missing: `--%s'.\n",
24490
shell_options[shell_index].name);
24495
/* Do the operation */
24496
shell_result=igraph_revolver_probs_ADE_dpareto(&graph, &par, &cats, &gcats, agebins, logprobs, logcited, logciting);
24498
/* Write the result */
24499
igraph_destroy(&graph);
24500
igraph_matrix_destroy(&par);
24501
igraph_vector_destroy(&cats);
24502
igraph_vector_destroy(&gcats);
24503
if (logprobs) { shell_write_vector(logprobs, shell_arg_logprobs);
24504
igraph_vector_destroy(logprobs); }
24505
if (logcited) { shell_write_vector(logcited, shell_arg_logcited);
24506
igraph_vector_destroy(logcited); }
24507
if (logciting) { shell_write_vector(logciting, shell_arg_logciting);
24508
igraph_vector_destroy(logciting); }
24513
/*-------------------------------------------/
24514
/ igraph_convergence_degree /
24515
/-------------------------------------------*/
24516
void shell_igraph_convergence_degree_usage(char **argv) {
24517
printf("%s --graph=<graph> --result=<result>\n", basename(argv[0]));
24521
int shell_igraph_convergence_degree(int argc, char **argv) {
24524
igraph_vector_t result;
24525
char* shell_arg_result=0;
24530
int shell_index=-1;
24531
struct option shell_options[]= { { "graph",required_argument,0,0 },
24532
{ "result",required_argument,0,1 },
24533
{ "help",no_argument,0,2 },
24537
/* 0 - not seen, 1 - seen as argument, 2 - seen as default */
24538
memset(shell_seen, 0, 2*sizeof(int));
24541
/* Parse arguments and read input */
24542
while (getopt_long(argc, argv, "", shell_options, &shell_index) != -1) {
24544
if (shell_index==-1) {
24548
if (shell_seen[shell_index]==1) {
24549
fprintf(stderr, "Error, `--%s' argument given twice.\n",
24550
shell_options[shell_index].name);
24553
shell_seen[shell_index]=1;
24555
switch (shell_index) {
24556
case 0: /* graph */
24557
shell_read_graph(&graph, optarg);
24559
case 1: /* result */
24560
shell_arg_result=strdup(optarg);
24561
igraph_vector_init(&result, 0);
24564
shell_igraph_convergence_degree_usage(argv);
24573
/* Check that we have all arguments */
24574
for (shell_index=0; shell_index<2; shell_index++) {
24575
if (!shell_seen[shell_index]) {
24576
fprintf(stderr, "Error, argument missing: `--%s'.\n",
24577
shell_options[shell_index].name);
24582
/* Do the operation */
24583
shell_result=igraph_convergence_degree(&graph, &result);
24585
/* Write the result */
24586
igraph_destroy(&graph);
24587
shell_write_vector(&result, shell_arg_result);
24588
igraph_vector_destroy(&result);