cluster_redwalk: Berenhaut Community Detection on Networks

Description Usage Arguments Value Examples

Description

Performs community detection on networks using average shortest path distance of vertex neighbors as the set of dissimilarities for heirarcal clustering with "average" as the agglomeration method. If shortest paths are supplied, this function is ~50% faster. It is also best to use a symmetric "matrix" rather than a "dist" object if performance is critical. Time complexity is O(n^2 log n) and space complexity is O(n^2). This function returns an hclust object rather than an igraph communities object because the algorithm does not attempt to use modularity use or maximize modularity (although the resulting partitioning results in a maximum modularity that is competitive with the top community detection algorithms).

Usage

1
cluster_redwalk(graph, nodes = V(graph), short_paths = NULL)

Arguments

graph

an igraph object.

nodes

a subset of the nodes in the graph to cluster, defaults to all nodes (full community detection)

short_paths

either a |V|x|V| symmetric dissimilarity matrix of the vertices in graph or a dist object from the stats package. If NULL (default), the shortest paths will be calculated. Note: much faster if short_paths is provided and much faster if short_paths is of class "matrix" rather than "dist".

Value

cluster_redwalk returns a hclust object from the stats package.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
require(stats, quietly = TRUE)
require(Rcpp, quietly = TRUE)
cb <- cluster_redwalk(karate)
## cb is an hclust object
plot(cb)
## membership for different community sizes (k)
cutree(cb, k = 2)
cutree(cb, k = 3)

## using precomputed shortest paths
sp <- shortest_path_lengths(dolphins)
cbd <- cluster_redwalk(dolphins, short_paths = sp)
plot(cbd)
cutree(cbd, k = 2)
cutree(cbd, k = 4)

barrpet/gclust documentation built on May 11, 2019, 6:23 p.m.