File: cattr_bool_bug.c

package info (click to toggle)
python-igraph 0.9.0-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 21,944 kB
  • sloc: ansic: 225,735; cpp: 23,208; python: 17,085; xml: 2,407; yacc: 1,164; sh: 531; lex: 486; pascal: 158; sed: 45; makefile: 23; javascript: 20; fortran: 8
file content (75 lines) | stat: -rw-r--r-- 1,909 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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75

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

#include "../unit/test_utilities.inc"

void check_attr(igraph_t *graph, int offset) {

    if (!igraph_cattribute_has_attr(graph, IGRAPH_ATTRIBUTE_GRAPH, "name")) {
        printf("No graph attribute `name`\n");
        exit(offset + 2);
    }
    if (!igraph_cattribute_has_attr(graph, IGRAPH_ATTRIBUTE_GRAPH, "type")) {
        printf("No graph attribute `type`\n");
        exit(offset + 3);
    }
    if (!igraph_cattribute_has_attr(graph, IGRAPH_ATTRIBUTE_GRAPH, "p")) {
        printf("No graph attribute `p`\n");
        exit(offset + 4);
    }
    if (!igraph_cattribute_has_attr(graph, IGRAPH_ATTRIBUTE_VERTEX,
                                    "name")) {
        printf("No vertex attribute `id`\n");
        exit(offset + 5);
    }
    if (!igraph_cattribute_has_attr(graph, IGRAPH_ATTRIBUTE_EDGE,
                                    "weight")) {
        printf("No edge attribute `weight'\n");
        exit(offset + 6);
    }
}

int main() {

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

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

    igraph_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);

    check_attr(&graph, 10);

    igraph_to_directed(&graph, IGRAPH_TO_DIRECTED_ARBITRARY);

    check_attr(&graph, 20);

    if (GAB(&graph, "loops")) {
        return 2;
    }

    igraph_destroy(&graph);

    VERIFY_FINALLY_STACK();

    return 0;
}