1 /* -*- mode: C -*-  */
2 /*
3    IGraph library.
4    Copyright (C) 2009-2012  Gabor Csardi <csardi.gabor@gmail.com>
5    334 Harvard street, 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 #ifndef IGRAPH_MOTIFS_H
25 #define IGRAPH_MOTIFS_H
26 
27 #include "igraph_decls.h"
28 #include "igraph_types.h"
29 #include "igraph_datatype.h"
30 #include "igraph_iterators.h"
31 
32 __BEGIN_DECLS
33 
34 /* -------------------------------------------------- */
35 /* Graph motifs                                       */
36 /* -------------------------------------------------- */
37 
38 /**
39  * \typedef igraph_motifs_handler_t
40  * Callback type for \c igraph_motifs_randesu_callback
41  *
42  * \ref igraph_motifs_randesu_callback() calls a specified callback
43  * function whenever a new motif is found during a motif search. This
44  * callback function must be of type \c igraph_motifs_handler_t. It has
45  * the following arguments:
46  * \param graph The graph that that algorithm is working on. Of course
47  *   this must not be modified.
48  * \param vids The IDs of the vertices in the motif that has just been
49  *   found. This vector is owned by the motif search algorithm, so do not
50  *   modify or destroy it; make a copy of it if you need it later.
51  * \param isoclass The isomorphism class of the motif that has just been
52  *   found. Use \ref igraph_isoclass or \ref igraph_isoclass_subgraph to find
53  *   out which isomorphism class belongs to a given motif.
54  * \param extra The extra argument that was passed to \ref
55  *   igraph_motifs_randesu_callback().
56  * \return A logical value, if TRUE (=non-zero), that is interpreted
57  *    as a request to stop the motif search and return to the caller.
58  *
59  * \sa \ref igraph_motifs_randesu_callback()
60  */
61 
62 typedef igraph_bool_t igraph_motifs_handler_t(const igraph_t *graph,
63         igraph_vector_t *vids,
64         int isoclass,
65         void* extra);
66 
67 IGRAPH_EXPORT int igraph_motifs_randesu(const igraph_t *graph, igraph_vector_t *hist,
68                                         int size, const igraph_vector_t *cut_prob);
69 
70 IGRAPH_EXPORT int igraph_motifs_randesu_callback(const igraph_t *graph, int size,
71                                                  const igraph_vector_t *cut_prob,
72                                                  igraph_motifs_handler_t *callback,
73                                                  void* extra);
74 
75 IGRAPH_EXPORT int igraph_motifs_randesu_estimate(const igraph_t *graph, igraph_integer_t *est,
76                                                  int size, const igraph_vector_t *cut_prob,
77                                                  igraph_integer_t sample_size,
78                                                  const igraph_vector_t *sample);
79 IGRAPH_EXPORT int igraph_motifs_randesu_no(const igraph_t *graph, igraph_integer_t *no,
80                                            int size, const igraph_vector_t *cut_prob);
81 
82 IGRAPH_EXPORT int igraph_dyad_census(const igraph_t *graph, igraph_integer_t *mut,
83                                      igraph_integer_t *asym, igraph_integer_t *null);
84 IGRAPH_EXPORT int igraph_triad_census(const igraph_t *igraph, igraph_vector_t *res);
85 IGRAPH_EXPORT int igraph_triad_census_24(const igraph_t *graph, igraph_real_t *res2,
86                                          igraph_real_t *res4);
87 
88 IGRAPH_EXPORT int igraph_adjacent_triangles(const igraph_t *graph,
89                                             igraph_vector_t *res,
90                                             const igraph_vs_t vids);
91 
92 IGRAPH_EXPORT int igraph_list_triangles(const igraph_t *graph,
93                                         igraph_vector_int_t *res);
94 
95 __END_DECLS
96 
97 #endif
98