~ubuntu-branches/ubuntu/trusty/igraph/trusty-proposed

« back to all changes in this revision

Viewing changes to examples/simple/igraph_read_graph_dl.c

  • Committer: Package Import Robot
  • Author(s): Mathieu Malaterre
  • Date: 2013-05-27 14:01:54 UTC
  • mfrom: (4.1.1 experimental)
  • Revision ID: package-import@ubuntu.com-20130527140154-oxwwmr0gj3kdy4ol
Tags: 0.6.5-2
Upload to sid

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* -*- mode: C -*-  */
 
2
/* 
 
3
   IGraph library.
 
4
   Copyright (C) 2009-2012  Gabor Csardi <csardi.gabor@gmail.com>
 
5
   334 Harvard st, Cambridge MA, 02139 USA
 
6
   
 
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.
 
11
   
 
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.
 
16
   
 
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 
 
20
   02110-1301 USA
 
21
 
 
22
*/
 
23
 
 
24
#include <igraph.h>
 
25
#include <stdio.h>
 
26
#include <stdlib.h>
 
27
 
 
28
int main() {
 
29
  
 
30
  const char *files[] = { "fullmatrix1.dl", "fullmatrix2.dl", 
 
31
                          "fullmatrix3.dl", "fullmatrix4.dl",
 
32
                          "edgelist1.dl", "edgelist2.dl", "edgelist3.dl",
 
33
                          "edgelist4.dl", "edgelist5.dl", "edgelist6.dl",
 
34
                          "nodelist1.dl", "nodelist2.dl" };
 
35
  int no_files=sizeof(files)/sizeof(const char*);
 
36
  int i, ret;
 
37
  igraph_t g;
 
38
  FILE *infile;
 
39
 
 
40
  for (i=0; i<no_files; i++) {
 
41
    printf("Doing %s\n", files[i]);
 
42
    infile=fopen(files[i], "r");
 
43
    if (!infile) {
 
44
      printf("Cannot open file: %s\n", files[i]);
 
45
      exit(1+i);
 
46
    }
 
47
    igraph_read_graph_dl(&g, infile, /*directed=*/ 1);
 
48
    ret=fclose(infile);
 
49
    if (ret) {
 
50
      printf("Cannot close file: %s\n", files[i]);
 
51
      exit(11+i);
 
52
    }
 
53
    igraph_write_graph_edgelist(&g, stdout);
 
54
    igraph_destroy(&g);
 
55
  }
 
56
 
 
57
  if (IGRAPH_FINALLY_STACK_SIZE() != 0)
 
58
    return 1;
 
59
 
 
60
  return 0;
 
61
}