Coverage Report

Created: 2025-09-04 06:27

/src/igraph/fuzzing/basic_properties_directed.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.16k
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
25
1.16k
    igraph_t graph;
26
1.16k
    igraph_vector_int_t edges;
27
28
1.16k
    igraph_set_warning_handler(igraph_warning_handler_ignore);
29
30
1.16k
    if (Size % 2 == 0 || Size > 512+1 || Size < 1) {
31
28
        return 0;
32
28
    }
33
34
1.14k
    igraph_vector_int_init(&edges, Size-1);
35
88.9k
    for (size_t i=0; i < Size-1; ++i) {
36
87.8k
        VECTOR(edges)[i] = Data[i+1];
37
87.8k
    }
38
39
    /* Directed */
40
1.14k
    if (igraph_create(&graph, &edges, Data[0], IGRAPH_DIRECTED) == IGRAPH_SUCCESS) {
41
1.14k
        igraph_bool_t bres, bres2, bres3;
42
1.14k
        igraph_real_t r;
43
44
1.14k
        igraph_has_multiple(&graph, &bres);
45
1.14k
        igraph_has_loop(&graph, &bres2);
46
1.14k
        igraph_has_mutual(&graph, &bres3, false);
47
1.14k
        igraph_invalidate_cache(&graph);
48
49
1.14k
        igraph_is_simple(&graph, &bres3, IGRAPH_DIRECTED);
50
1.14k
        igraph_invalidate_cache(&graph);
51
52
1.14k
        IGRAPH_ASSERT((bres || bres2) == !bres3);
53
54
1.14k
        igraph_is_complete(&graph, &bres);
55
1.14k
        igraph_invalidate_cache(&graph);
56
57
1.14k
        igraph_is_connected(&graph, &bres, IGRAPH_STRONG);
58
1.14k
        igraph_invalidate_cache(&graph);
59
60
1.14k
        igraph_is_dag(&graph, &bres);
61
1.14k
        igraph_invalidate_cache(&graph);
62
63
1.14k
        igraph_is_forest(&graph, &bres, NULL, IGRAPH_OUT);
64
1.14k
        igraph_invalidate_cache(&graph);
65
66
1.14k
        igraph_is_tree(&graph, &bres, NULL, IGRAPH_OUT);
67
1.14k
        igraph_invalidate_cache(&graph);
68
69
1.14k
        igraph_is_eulerian(&graph, &bres, &bres2);
70
1.14k
        igraph_invalidate_cache(&graph);
71
72
1.14k
        igraph_density(&graph, NULL, &r, true);
73
74
1.14k
        igraph_destroy(&graph);
75
1.14k
    }
76
77
1.14k
    igraph_vector_int_destroy(&edges);
78
79
1.14k
    IGRAPH_ASSERT(IGRAPH_FINALLY_STACK_EMPTY);
80
81
1.14k
    return 0;  // Non-zero return values are reserved for future use.
82
1.14k
}