aboutsummaryrefslogtreecommitdiffstats
path: root/spike
diff options
context:
space:
mode:
authorLaurent Ghigonis <laurent@p1sec.com>2012-12-06 14:31:41 +0100
committerLaurent Ghigonis <laurent@p1sec.com>2012-12-06 14:31:41 +0100
commit0652a0bb828b699573c5ace92b8434c7e284d36f (patch)
treeb4e26d60106dc318a74d4284a04cf6a05a32f5e8 /spike
parenthand notes on gg_map architecture (diff)
downloadglouglou-0652a0bb828b699573c5ace92b8434c7e284d36f.tar.xz
glouglou-0652a0bb828b699573c5ace92b8434c7e284d36f.zip
more tests
Diffstat (limited to 'spike')
-rw-r--r--spike/igraph_graph.c59
1 files changed, 34 insertions, 25 deletions
diff --git a/spike/igraph_graph.c b/spike/igraph_graph.c
index bd76d93..998cb5e 100644
--- a/spike/igraph_graph.c
+++ b/spike/igraph_graph.c
@@ -40,45 +40,54 @@ int main() {
long int i, n;
igraph_vector_t v;
int ret;
+ int c;
printf("[-] create graph\n");
- /*igraph_vector_init(&v, 8);
- VECTOR(v)[0]=0; VECTOR(v)[1]=1;
+ /*VECTOR(v)[0]=0; VECTOR(v)[1]=1;
VECTOR(v)[2]=1; VECTOR(v)[3]=2;
VECTOR(v)[4]=2; VECTOR(v)[5]=3;
VECTOR(v)[6]=2; VECTOR(v)[7]=3;
igraph_create(&g, &v, 0, 0);*/ /* Creates a graph with the specified edges */
- igraph_empty(&g, 30, 0);
+ igraph_empty(&g, 0, 0);
printf("[-] add edges\n");
- //igraph_add_vertices(&g, 2, 0);
+ igraph_add_vertices(&g, 1, 0);
+ igraph_add_vertices(&g, 1, 0);
igraph_add_edge(&g, 0, 1);
+ igraph_add_vertices(&g, 1, 0);
+ igraph_add_edge(&g, 0, 2);
+ igraph_add_vertices(&g, 1, 0);
+ igraph_add_edge(&g, 0, 3);
+ igraph_add_vertices(&g, 1, 0);
+ igraph_add_edge(&g, 0, 4);
+ igraph_add_vertices(&g, 1, 0);
+ igraph_add_edge(&g, 4, 5);
- //printf("[-] check result\n");
- //igraph_get_edgelist(&g, &v, 0);
- //igraph_vector_sort(&v);
- //print_vector(&v, stdout);
+ printf("[-] entering loop\n");
- printf("[-] add edges\n");
- igraph_add_edge(&g, 0, 3);
-
- //printf("[-] check result\n");
- //igraph_get_edgelist(&g, &v, 0);
- //igraph_vector_sort(&v);
- //print_vector(&v, stdout);
+ for (c=0; c<=2; c++) {
+ printf("[*] === loop %d ===\n", c);
+ printf("[-] add one edges\n");
+ igraph_add_vertices(&g, 1, 0);
+ igraph_add_edge(&g, 4, 6 + c);
- printf("[-] apply layout\n");
- //f=fopen("igraph_layout_reingold_tilford.in", "r");
- //igraph_read_graph_edgelist(&g, f, 0, 1);
- igraph_matrix_init(&coords, 0, 0);
- igraph_layout_reingold_tilford(&g, &coords, IGRAPH_IN, 0, 0);
+ printf("[-] check edges\n");
+ printf("edge count: %d\n", igraph_ecount(&g));
+ igraph_vector_init(&v, igraph_ecount(&g));
+ igraph_get_edgelist(&g, &v, 0);
+ print_vector(&v, stdout);
- printf("[-] show vertices\n");
- n=igraph_vcount(&g);
- for (i=0; i<n; i++) {
- printf("%6.3f %6.3f\n", MATRIX(coords, i, 0), MATRIX(coords, i, 1));
+ printf("[-] apply layout\n");
+ igraph_matrix_init(&coords, 0, 0);
+ igraph_layout_reingold_tilford(&g, &coords, IGRAPH_IN, 0, 0);
+
+ printf("[-] show vertices\n");
+ n=igraph_vcount(&g);
+ for (i=0; i<n; i++) {
+ printf("%d: %6.3f %6.3f\n", i, MATRIX(coords, i, 0), MATRIX(coords, i, 1));
+ }
}
-
+
printf("[*] destroying graph\n");
//igraph_vector_destroy(&v);
igraph_matrix_destroy(&coords);