Coverage Report

Created: 2025-12-05 06:36

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/igraph/fuzzing/basic_properties_undirected.cpp
Line
Count
Source
1
/*
2
   igraph library.
3
   Copyright (C) 2024  The igraph development team
4
5
   This program is free software; you can redistribute it and/or modify
6
   it under the terms of the GNU General Public License as published by
7
   the Free Software Foundation; either version 2 of the License, or
8
   (at your option) any later version.
9
10
   This program is distributed in the hope that it will be useful,
11
   but WITHOUT ANY WARRANTY; without even the implied warranty of
12
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
   GNU General Public License for more details.
14
15
   You should have received a copy of the GNU General Public License
16
   along with this program; if not, write to the Free Software
17
   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18
   02110-1301 USA
19
*/
20
21
#include <igraph.h>
22
#include <cstdlib>
23
24
1.15k
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
25
1.15k
    igraph_t graph;
26
1.15k
    igraph_vector_int_t edges;
27
28
1.15k
    igraph_set_warning_handler(igraph_warning_handler_ignore);
29
30
1.15k
    if (Size % 2 == 0 || Size > 512+1 || Size < 1) {
31
28
        return 0;
32
28
    }
33
34
1.13k
    igraph_vector_int_init(&edges, Size-1);
35
86.3k
    for (size_t i=0; i < Size-1; ++i) {
36
85.2k
        VECTOR(edges)[i] = Data[i+1];
37
85.2k
    }
38
39
    /* Undirected */
40
1.13k
    if (igraph_create(&graph, &edges, Data[0], IGRAPH_UNDIRECTED) == IGRAPH_SUCCESS) {
41
1.13k
        igraph_bool_t bres, bres2, bres3;
42
1.13k
        igraph_real_t r;
43
44
1.13k
        igraph_has_multiple(&graph, &bres);
45
1.13k
        igraph_has_loop(&graph, &bres2);
46
1.13k
        igraph_invalidate_cache(&graph);
47
48
1.13k
        igraph_is_simple(&graph, &bres3, IGRAPH_DIRECTED);
49
1.13k
        igraph_invalidate_cache(&graph);
50
51
1.13k
        IGRAPH_ASSERT((bres || bres2) == !bres3);
52
53
1.13k
        igraph_is_complete(&graph, &bres);
54
1.13k
        igraph_invalidate_cache(&graph);
55
56
1.13k
        igraph_is_bipartite(&graph, &bres, NULL);
57
1.13k
        igraph_invalidate_cache(&graph);
58
59
1.13k
        igraph_is_connected(&graph, &bres, IGRAPH_WEAK);
60
1.13k
        igraph_invalidate_cache(&graph);
61
62
1.13k
        igraph_is_acyclic(&graph, &bres);
63
1.13k
        igraph_invalidate_cache(&graph);
64
65
1.13k
        igraph_is_tree(&graph, &bres, NULL, IGRAPH_ALL);
66
1.13k
        igraph_invalidate_cache(&graph);
67
68
1.13k
        igraph_is_eulerian(&graph, &bres, &bres2);
69
1.13k
        igraph_invalidate_cache(&graph);
70
71
1.13k
        igraph_is_biconnected(&graph, &bres);
72
1.13k
        igraph_invalidate_cache(&graph);
73
74
1.13k
        igraph_is_chordal(&graph, NULL, NULL, &bres, NULL, NULL);
75
1.13k
        igraph_invalidate_cache(&graph);
76
77
1.13k
        igraph_density(&graph, NULL, &r, true);
78
79
1.13k
        igraph_destroy(&graph);
80
1.13k
    }
81
82
1.13k
    igraph_vector_int_destroy(&edges);
83
84
1.13k
    IGRAPH_ASSERT(IGRAPH_FINALLY_STACK_EMPTY);
85
86
1.13k
    return 0;  // Non-zero return values are reserved for future use.
87
1.13k
}