Skip to content

Commit

Permalink
Merge branch 'main' into fix/ncol-lgl
Browse files Browse the repository at this point in the history
  • Loading branch information
Antonov548 authored May 22, 2024
2 parents 40601e4 + d2095f3 commit dbef07f
Show file tree
Hide file tree
Showing 39 changed files with 440 additions and 294 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build-and-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,9 @@ jobs:
matrix:
config:
- {os: windows-latest, r: 'release'}
- {os: macOS-latest, r: 'release'}
# - {os: macOS-latest, r: 'release'}
- {os: ubuntu-20.04, r: 'release', rspm: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest"}
- {os: ubuntu-20.04, r: 'devel', rspm: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest"}
# - {os: ubuntu-20.04, r: 'devel', rspm: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest"}
- {os: ubuntu-20.04, r: 'oldrel-1', rspm: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest"}
- {os: ubuntu-20.04, r: 'oldrel-2', rspm: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest"}
- {os: ubuntu-20.04, r: 'oldrel-3', rspm: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest"}
Expand Down
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Package: igraph
Version: 2.0.3.9012
Version: 2.0.3.9018
Title: Network Analysis and Visualization
Authors@R: c(
person("Gábor", "Csárdi", , "csardi.gabor@gmail.com", role = "aut",
Expand Down
50 changes: 50 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,55 @@
<!-- NEWS.md is maintained by https://fledge.cynkra.com, contributors should not edit this file -->

# igraph 2.0.3.9018

## Bug fixes

- Fixed potential memory leak in `R_igraph_community_to_membership2()` (#1367).


# igraph 2.0.3.9017

## Bug fixes

- Comment failing ci (#1357).

## Testing

- Refactoring around `interface.R` (#1366).

## Uncategorized

- Fix `%\>%` typo in vignettes (#1343).


# igraph 2.0.3.9016

## doc

- Improve `eigen_centrality()` documentation.


# igraph 2.0.3.9015

## doc

- Further improved `cluster_edge_betweenness()` documentation.


# igraph 2.0.3.9014

## doc

- Improved `cluster_edge_betweenness()` documentation.


# igraph 2.0.3.9013

## Testing

- Improve sample_degseq() tests (#1315).


# igraph 2.0.3.9012

## Continuous integration
Expand Down
28 changes: 14 additions & 14 deletions R/centrality.R
Original file line number Diff line number Diff line change
Expand Up @@ -892,40 +892,40 @@ eigen_defaults <- function() {
)
}

#' Find Eigenvector Centrality Scores of Network Positions
#' Eigenvector centrality of vertices
#'
#' `eigen_centrality()` takes a graph (`graph`) and returns the
#' eigenvector centralities of positions `v` within it
#' eigenvector centralities of the vertices `v` within it.
#'
#' Eigenvector centrality scores correspond to the values of the first
#' eigenvector of the graph adjacency matrix; these scores may, in turn, be
#' Eigenvector centrality scores correspond to the values of the principal
#' eigenvector of the graph's adjacency matrix; these scores may, in turn, be
#' interpreted as arising from a reciprocal process in which the centrality of
#' each actor is proportional to the sum of the centralities of those actors to
#' whom he or she is connected. In general, vertices with high eigenvector
#' centralities are those which are connected to many other vertices which are,
#' in turn, connected to many others (and so on). (The perceptive may realize
#' in turn, connected to many others (and so on). The perceptive may realize
#' that this implies that the largest values will be obtained by individuals in
#' large cliques (or high-density substructures). This is also intelligible
#' from an algebraic point of view, with the first eigenvector being closely
#' related to the best rank-1 approximation of the adjacency matrix (a
#' relationship which is easy to see in the special case of a diagonalizable
#' symmetric real matrix via the \eqn{SLS^-1}{$S \Lambda S^{-1}$}
#' decomposition).)
#' decomposition).
#'
#' The adjacency matrix used in the eigenvector centrality calculation assumes
#' that loop edges are counted *twice*; this is because each loop edge has
#' *two* endpoints that are both connected to the same vertex, and you
#' could traverse the loop edge via either endpoint.
#' that loop edges are counted *twice* in undirected graphs; this is because
#' each loop edge has *two* endpoints that are both connected to the same vertex,
#' and you could traverse the loop edge via either endpoint.
#'
#' In the directed case, the left eigenvector of the adjacency matrix is
#' calculated. In other words, the centrality of a vertex is proportional to
#' the sum of centralities of vertices pointing to it.
#'
#' Eigenvector centrality is meaningful only for connected graphs. Graphs that
#' are not connected should be decomposed into connected components, and the
#' eigenvector centrality calculated for each separately. This function does
#' not verify that the graph is connected. If it is not, in the undirected case
#' the scores of all but one component will be zeros.
#' Eigenvector centrality is meaningful only for (strongly) connected graphs.
#' Undirected graphs that are not connected should be decomposed into connected
#' components, and the eigenvector centrality calculated for each separately.
#' This function does not verify that the graph is connected. If it is not, in
#' the undirected case the scores of all but one component will be zeros.
#'
#' Also note that the adjacency matrix of a directed acyclic graph or the
#' adjacency matrix of an empty graph does not possess positive eigenvalues,
Expand Down
38 changes: 18 additions & 20 deletions R/community.R
Original file line number Diff line number Diff line change
Expand Up @@ -1565,26 +1565,24 @@ cluster_walktrap <- function(graph, weights = NULL, steps = 4,

#' Community structure detection based on edge betweenness
#'
#' Many networks consist of modules which are densely connected themselves but
#' sparsely connected to other modules.
#'
#' The edge betweenness score of an edge measures the number of shortest paths
#' through it, see [edge_betweenness()] for details. The idea of the
#' edge betweenness based community structure detection is that it is likely
#' that edges connecting separate modules have high edge betweenness as all the
#' shortest paths from one module to another must traverse through them. So if
#' we gradually remove the edge with the highest edge betweenness score we will
#' get a hierarchical map, a rooted tree, called a dendrogram of the graph. The
#' leafs of the tree are the individual vertices and the root of the tree
#' represents the whole graph.
#'
#' `cluster_edge_betweenness()` performs this algorithm by calculating the
#' edge betweenness of the graph, removing the edge with the highest edge
#' betweenness score, then recalculating edge betweenness of the edges and
#' again removing the one with the highest score, etc.
#'
#' `edge.betweeness.community` returns various information collected
#' through the run of the algorithm. See the return value down here.
#' Community structure detection based on the betweenness of the edges
#' in the network. This method is also known as the Girvan-Newman
#' algorithm.
#'
#' The idea behind this method is that the betweenness of the edges connecting
#' two communities is typically high, as many of the shortest paths between
#' vertices in separate communities pass through them. The algorithm
#' successively removes edges with the highest betweenness, recalculating
#' betweenness values after each removal. This way eventually the network splits
#' into two components, then one of these components splits again, and so on,
#' until all edges are removed. The resulting hierarhical partitioning of the
#' vertices can be encoded as a dendrogram.
#'
#' `cluster_edge_betweenness()` returns various information collected
#' through the run of the algorithm. Specifically, `removed.edges` contains
#' the edge IDs in order of the edges' removal; `edge.betweenness` contains
#' the betweenness of each of these at the time of their removal; and
#' `bridges` contains the IDs of edges whose removal caused a split.
#'
#' @param graph The graph to analyze.
#' @param weights The weights of the edges. It must be a positive numeric vector,
Expand Down
34 changes: 16 additions & 18 deletions man/cluster_edge_betweenness.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 14 additions & 14 deletions man/eigen_centrality.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 9 additions & 6 deletions src/rinterface_extra.c
Original file line number Diff line number Diff line change
Expand Up @@ -4967,9 +4967,10 @@ SEXP R_igraph_degree_sequence_game(SEXP pout_seq, SEXP pin_seq,
igraph_integer_t method=(igraph_integer_t) REAL(pmethod)[0];
SEXP result;

R_SEXP_to_vector_int_copy(pout_seq, &outseq);
IGRAPH_R_CHECK(R_SEXP_to_vector_int_copy(pout_seq, &outseq));
IGRAPH_FINALLY(igraph_vector_int_destroy, &outseq);
if (!Rf_isNull(pin_seq)) {
R_SEXP_to_vector_int_copy(pin_seq, &inseq);
IGRAPH_R_CHECK(R_SEXP_to_vector_int_copy(pin_seq, &inseq));
} else {
IGRAPH_R_CHECK(igraph_vector_int_init(&inseq, 0));
}
Expand All @@ -4978,7 +4979,7 @@ SEXP R_igraph_degree_sequence_game(SEXP pout_seq, SEXP pin_seq,
PROTECT(result=R_igraph_to_SEXP(&g));
igraph_vector_int_destroy(&outseq);
igraph_vector_int_destroy(&inseq);
IGRAPH_FINALLY_CLEAN(1);
IGRAPH_FINALLY_CLEAN(2);
IGRAPH_I_DESTROY(&g);

UNPROTECT(1);
Expand Down Expand Up @@ -7341,16 +7342,18 @@ SEXP R_igraph_community_to_membership2(SEXP pmerges, SEXP pvcount,
igraph_vector_int_t membership;
SEXP result;

R_SEXP_to_matrix_int(pmerges, &merges);
igraph_vector_int_init(&membership, 0);
IGRAPH_R_CHECK(R_SEXP_to_matrix_int(pmerges, &merges));
IGRAPH_FINALLY(igraph_matrix_int_destroy, &merges);

IGRAPH_R_CHECK(igraph_vector_int_init(&membership, 0));
IGRAPH_FINALLY(igraph_vector_int_destroy, &membership);

IGRAPH_R_CHECK(igraph_community_to_membership(&merges, vcount, steps, &membership, 0));
PROTECT(result=R_igraph_vector_int_to_SEXP(&membership));

igraph_matrix_int_destroy(&merges);
igraph_vector_int_destroy(&membership);
IGRAPH_FINALLY_CLEAN(1);
IGRAPH_FINALLY_CLEAN(2);

UNPROTECT(1);
return result;
Expand Down
16 changes: 16 additions & 0 deletions tests/testthat/_snaps/games.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# sample_degseq() works -- exponential degree error

Code
sample_degseq(exponential_degrees, method = "vl")
Condition
Error in `sample_degseq()`:
! At vendor/cigraph/src/games/degree_sequence_vl/gengraph_mr-connected.cpp:<linenumber> : Cannot make a connected graph from the given degree sequence. Invalid value

# sample_degseq() works -- Power-law degree error

Code
sample_degseq(powerlaw_degrees, method = "vl")
Condition
Error in `sample_degseq()`:
! At vendor/cigraph/src/games/degree_sequence_vl/gengraph_mr-connected.cpp:<linenumber> : Cannot realize the given degree sequence as an undirected, simple graph. Invalid value

4 changes: 4 additions & 0 deletions tests/testthat/helper.R
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,7 @@ expect_that <- function(object, condition, info = NULL, label = NULL) {
condition(object)
)
}

expect_isomorphic <- function(g1, g2) {
expect_true(graph.isomorphic(g1, g2))
}
45 changes: 0 additions & 45 deletions tests/testthat/test-add.edges.R

This file was deleted.

Loading

0 comments on commit dbef07f

Please sign in to comment.