Skip to content

Commit

Permalink
vendor: Update vendored sources to igraph/igraph@10ef19b
Browse files Browse the repository at this point in the history
Merge pull request igraph/igraph#2716 from igraph/feat/triangle-count
  • Loading branch information
krlmlr authored and szhorvat committed Feb 21, 2025
1 parent 1176a04 commit 6086f74
Show file tree
Hide file tree
Showing 8 changed files with 246 additions and 104 deletions.
27 changes: 25 additions & 2 deletions R/aaa-auto.R
Original file line number Diff line number Diff line change
Expand Up @@ -2712,14 +2712,25 @@ triad_census_impl <- function(graph) {
res
}

adjacent_triangles_impl <- function(graph, vids=V(graph)) {
count_adjacent_triangles_impl <- function(graph, vids=V(graph)) {
# Argument checks
ensure_igraph(graph)
vids <- as_igraph_vs(graph, vids)

on.exit( .Call(R_igraph_finalizer) )
# Function call
res <- .Call(R_igraph_adjacent_triangles, graph, vids-1)
res <- .Call(R_igraph_count_adjacent_triangles, graph, vids-1)

res
}

count_triangles_impl <- function(graph) {
# Argument checks
ensure_igraph(graph)

on.exit( .Call(R_igraph_finalizer) )
# Function call
res <- .Call(R_igraph_count_triangles, graph)

res
}
Expand Down Expand Up @@ -3916,3 +3927,15 @@ vertex_path_from_edge_path_impl <- function(graph, start, edge.path, mode=c("out
res
}

adjacent_triangles_impl <- function() {
# Argument checks


on.exit( .Call(R_igraph_finalizer) )
# Function call
res <- .Call(R_igraph_adjacent_triangles)


res
}

8 changes: 6 additions & 2 deletions src/cpp11.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ extern SEXP R_igraph_address(SEXP);
extern SEXP R_igraph_adhesion(SEXP, SEXP);
extern SEXP R_igraph_adjacency(SEXP, SEXP, SEXP);
extern SEXP R_igraph_adjacency_spectral_embedding(SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP);
extern SEXP R_igraph_adjacent_triangles(SEXP, SEXP);
extern SEXP R_igraph_adjacent_triangles(void);
extern SEXP R_igraph_adjacent_vertices(SEXP, SEXP, SEXP);
extern SEXP R_igraph_adjlist(SEXP, SEXP, SEXP);
extern SEXP R_igraph_all_minimal_st_separators(SEXP);
Expand Down Expand Up @@ -112,12 +112,14 @@ extern SEXP R_igraph_copy_to(SEXP);
extern SEXP R_igraph_coreness(SEXP, SEXP);
extern SEXP R_igraph_correlated_game(SEXP, SEXP, SEXP, SEXP);
extern SEXP R_igraph_correlated_pair_game(SEXP, SEXP, SEXP, SEXP, SEXP);
extern SEXP R_igraph_count_adjacent_triangles(SEXP, SEXP);
extern SEXP R_igraph_count_automorphisms(SEXP, SEXP, SEXP);
extern SEXP R_igraph_count_isomorphisms_vf2(SEXP, SEXP, SEXP, SEXP, SEXP, SEXP);
extern SEXP R_igraph_count_loops(SEXP);
extern SEXP R_igraph_count_multiple(SEXP, SEXP);
extern SEXP R_igraph_count_reachable(SEXP, SEXP);
extern SEXP R_igraph_count_subisomorphisms_vf2(SEXP, SEXP, SEXP, SEXP, SEXP, SEXP);
extern SEXP R_igraph_count_triangles(SEXP);
extern SEXP R_igraph_create(SEXP, SEXP, SEXP);
extern SEXP R_igraph_create_bipartite(SEXP, SEXP, SEXP);
extern SEXP R_igraph_de_bruijn(SEXP, SEXP);
Expand Down Expand Up @@ -487,7 +489,7 @@ static const R_CallMethodDef CallEntries[] = {
{"R_igraph_adhesion", (DL_FUNC) &R_igraph_adhesion, 2},
{"R_igraph_adjacency", (DL_FUNC) &R_igraph_adjacency, 3},
{"R_igraph_adjacency_spectral_embedding", (DL_FUNC) &R_igraph_adjacency_spectral_embedding, 7},
{"R_igraph_adjacent_triangles", (DL_FUNC) &R_igraph_adjacent_triangles, 2},
{"R_igraph_adjacent_triangles", (DL_FUNC) &R_igraph_adjacent_triangles, 0},
{"R_igraph_adjacent_vertices", (DL_FUNC) &R_igraph_adjacent_vertices, 3},
{"R_igraph_adjlist", (DL_FUNC) &R_igraph_adjlist, 3},
{"R_igraph_all_minimal_st_separators", (DL_FUNC) &R_igraph_all_minimal_st_separators, 1},
Expand Down Expand Up @@ -567,12 +569,14 @@ static const R_CallMethodDef CallEntries[] = {
{"R_igraph_coreness", (DL_FUNC) &R_igraph_coreness, 2},
{"R_igraph_correlated_game", (DL_FUNC) &R_igraph_correlated_game, 4},
{"R_igraph_correlated_pair_game", (DL_FUNC) &R_igraph_correlated_pair_game, 5},
{"R_igraph_count_adjacent_triangles", (DL_FUNC) &R_igraph_count_adjacent_triangles, 2},
{"R_igraph_count_automorphisms", (DL_FUNC) &R_igraph_count_automorphisms, 3},
{"R_igraph_count_isomorphisms_vf2", (DL_FUNC) &R_igraph_count_isomorphisms_vf2, 6},
{"R_igraph_count_loops", (DL_FUNC) &R_igraph_count_loops, 1},
{"R_igraph_count_multiple", (DL_FUNC) &R_igraph_count_multiple, 2},
{"R_igraph_count_reachable", (DL_FUNC) &R_igraph_count_reachable, 2},
{"R_igraph_count_subisomorphisms_vf2", (DL_FUNC) &R_igraph_count_subisomorphisms_vf2, 6},
{"R_igraph_count_triangles", (DL_FUNC) &R_igraph_count_triangles, 1},
{"R_igraph_create", (DL_FUNC) &R_igraph_create, 3},
{"R_igraph_create_bipartite", (DL_FUNC) &R_igraph_create_bipartite, 3},
{"R_igraph_de_bruijn", (DL_FUNC) &R_igraph_de_bruijn, 2},
Expand Down
50 changes: 47 additions & 3 deletions src/rinterface.c
Original file line number Diff line number Diff line change
Expand Up @@ -8589,9 +8589,9 @@ SEXP R_igraph_triad_census(SEXP graph) {
}

/*-------------------------------------------/
/ igraph_adjacent_triangles /
/ igraph_count_adjacent_triangles /
/-------------------------------------------*/
SEXP R_igraph_adjacent_triangles(SEXP graph, SEXP vids) {
SEXP R_igraph_count_adjacent_triangles(SEXP graph, SEXP vids) {
/* Declarations */
igraph_t c_graph;
igraph_vector_t c_res;
Expand All @@ -8606,7 +8606,7 @@ SEXP R_igraph_adjacent_triangles(SEXP graph, SEXP vids) {
igraph_vector_int_t c_vids_data;
R_SEXP_to_igraph_vs(vids, &c_graph, &c_vids, &c_vids_data);
/* Call igraph */
IGRAPH_R_CHECK(igraph_adjacent_triangles(&c_graph, &c_res, c_vids));
IGRAPH_R_CHECK(igraph_count_adjacent_triangles(&c_graph, &c_res, c_vids));

/* Convert output */
PROTECT(res=R_igraph_vector_to_SEXP(&c_res));
Expand All @@ -8620,6 +8620,30 @@ SEXP R_igraph_adjacent_triangles(SEXP graph, SEXP vids) {
return(r_result);
}

/*-------------------------------------------/
/ igraph_count_triangles /
/-------------------------------------------*/
SEXP R_igraph_count_triangles(SEXP graph) {
/* Declarations */
igraph_t c_graph;
igraph_real_t c_res;
SEXP res;

SEXP r_result;
/* Convert input */
R_SEXP_to_igraph(graph, &c_graph);
/* Call igraph */
IGRAPH_R_CHECK(igraph_count_triangles(&c_graph, &c_res));

/* Convert output */
PROTECT(res=NEW_NUMERIC(1));
REAL(res)[0]=c_res;
r_result = res;

UNPROTECT(1);
return(r_result);
}

/*-------------------------------------------/
/ igraph_local_scan_0 /
/-------------------------------------------*/
Expand Down Expand Up @@ -11718,6 +11742,26 @@ SEXP R_igraph_vertex_path_from_edge_path(SEXP graph, SEXP start, SEXP edge_path,
IGRAPH_FINALLY_CLEAN(1);
r_result = vertex_path;

UNPROTECT(1);
return(r_result);
}

/*-------------------------------------------/
/ igraph_adjacent_triangles /
/-------------------------------------------*/
SEXP R_igraph_adjacent_triangles(void) {
/* Declarations */
igraph_error_t c_result;
SEXP r_result;
/* Convert input */

/* Call igraph */
IGRAPH_R_CHECK(igraph_adjacent_triangles());

/* Convert output */



UNPROTECT(1);
return(r_result);
}
7 changes: 7 additions & 0 deletions src/vendor/cigraph/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,23 @@

## [master]

### Added

- `igraph_count_triangles()` counts undirected triangles in a graph.
- `igraph_count_adjacent_triangles()` (rename of `igraph_adjacent_triangles()`)

### Deprecated

- The undocumented function `igraph_vector_sumsq()` is deprecated. Use `igraph_blas_dnrm2()` to compute the Euclidean norm of real vectors.
- `igraph_adjacent_triangles()` is deprecated and scheduled for removal in 1.0.

### Other

- Workaround for bug in CMake 3.31.0, see https://gitlab.kitware.com/cmake/cmake/-/issues/26449
- Updated the vendored `plfit` library to version 1.0.0. This works around a bug in some MSVC / Windows SDK versions that define a `NAN` macro that is not a compile-time constant.
- Updated vendored BLAS to 3.12.0 and vendored ARPACK to ARPACK-NG 3.7.0.
- Re-translated vendored BLAS/LAPACK/ARPACK sources with f2c version 20240504.
- The performance of `igraph_transitivity_undirected()` is improved by a factor of about 2.5.
- Documentation improvements.

## [0.10.15]
Expand Down
8 changes: 7 additions & 1 deletion src/vendor/cigraph/include/igraph_motifs.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,13 +89,19 @@ IGRAPH_EXPORT igraph_error_t igraph_dyad_census(const igraph_t *graph, igraph_re
igraph_real_t *asym, igraph_real_t *null);
IGRAPH_EXPORT igraph_error_t igraph_triad_census(const igraph_t *igraph, igraph_vector_t *res);

IGRAPH_EXPORT igraph_error_t igraph_adjacent_triangles(const igraph_t *graph,
IGRAPH_EXPORT igraph_error_t igraph_count_adjacent_triangles(const igraph_t *graph,
igraph_vector_t *res,
const igraph_vs_t vids);

IGRAPH_EXPORT IGRAPH_DEPRECATED igraph_error_t igraph_adjacent_triangles(const igraph_t *graph,
igraph_vector_t *res,
const igraph_vs_t vids);

IGRAPH_EXPORT igraph_error_t igraph_list_triangles(const igraph_t *graph,
igraph_vector_int_t *res);

IGRAPH_EXPORT igraph_error_t igraph_count_triangles(const igraph_t *graph, igraph_real_t *res);

__END_DECLS

#endif
5 changes: 4 additions & 1 deletion src/vendor/cigraph/interfaces/functions.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1972,10 +1972,13 @@ igraph_triad_census:
PARAMS: GRAPH graph, OUT VECTOR res
RETURN: ERROR

igraph_adjacent_triangles:
igraph_count_adjacent_triangles:
PARAMS: GRAPH graph, OUT VECTOR res, VERTEX_SELECTOR vids=ALL
DEPS: vids ON graph

igraph_count_triangles:
PARAMS: GRAPH graph, OUT REAL res

igraph_local_scan_0:
PARAMS: |-
GRAPH graph, OUT VECTOR res, OPTIONAL EDGEWEIGHTS weights,
Expand Down
Loading

0 comments on commit 6086f74

Please sign in to comment.