File: cattr_bool_bug2.c

package info (click to toggle)
igraph 0.8.5%2Bds1-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 11,284 kB
  • sloc: ansic: 97,287; cpp: 22,541; yacc: 1,150; makefile: 546; lex: 478; xml: 450; pascal: 82; sh: 9
file content (48 lines) | stat: -rw-r--r-- 1,134 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48

#include <igraph.h>
#include <stdio.h>

#include "test_utilities.inc"

#define FILENAME "mybool.graphml.xml"

int main() {

    igraph_t graph;
    igraph_error_handler_t* oldhandler;
    int result;
    FILE* ifile = fopen("cattr_bool_bug2.graphml", "r");

    if (!ifile) {
        printf("Cannot open input file");
        return 1;
    }

    igraph_i_set_attribute_table(&igraph_cattribute_table);

    oldhandler = igraph_set_error_handler(igraph_error_handler_ignore);
    if ((result = igraph_read_graph_graphml(&graph, ifile, 0))) {
        /* maybe it is simply disabled at compile-time */
        if (result == IGRAPH_UNIMPLEMENTED) {
            return 77;
        }
        return 1;
    }
    igraph_set_error_handler(oldhandler);

    fclose(ifile);

    if (!igraph_cattribute_has_attr(&graph, IGRAPH_ATTRIBUTE_GRAPH, "mybool")) {
        printf("boolean value mybool not found\n");
        return 2;
    } else {
        igraph_bool_t value = igraph_cattribute_GAB(&graph, "mybool");
        printf("found boolean value %d\n", value);
    }

    igraph_destroy(&graph);

    VERIFY_FINALLY_STACK();

    return 0;
}