extremalOptimization
is a function executing the extremal optimization approach and its modifications for calculating modularity and detecting communities (modules of nodes) of a network via modularity maximizationpcseoss
is a function which uses extremal optimization, but also considers pairwise constraints when calculating the fitness function and the modularity. The violation of constraints is punished, leading to smaller fitness and modularity values for community structures that violate many pairwise constraints. The constraints are predefined as two matrices separately for must-links and cannot-links with punishment for violation.
extremalOptimization(adjacency, numRandom = 0, refine = c("none", "agents"), tau = FALSE, alpha_max = length(adjacency[1,]), steps = 3)
pcseoss(adjacency,constraints_ml,constraints_cl)
none
. See details below.
TRUE
, $\tau$-EO is executed where the vertices are ranked according to their fitness values and chosen by a probability depending on this ranking.
1
for the normal EO-algorithm and n
for the $\tau$-EO where n
is the number of vertices in the network
refine
is none
.
numRandom>0
numRandom>0
numRandom>0
The EO algorithm can be run with a certain refinement step, the local random search agent algorithm, applied at the end of one round of extremal where all communities have been split once.
This refinement algorithm is executed if refine
equals agent
, otherwise the generic EO algorithm is executed.
Azizifard, N., Mahdavi, M. and Nasersharif, B. Modularity optimization for clustering in social networks. 2011.
Li, L., Du, M., Liu, G., Hu, X. and Wu, G. Extremal optimization-based semi-supervised algorithm with conflict pairwise constraints for community detection. In Advances in Social Network Analysis and Mining (ASONAM), 2014 IEEE/ACM International Conference on, 2014.
#weighted network
randomgraph <- erdos.renyi.game(10, 0.3, type="gnp",directed = FALSE, loops = FALSE)
#to ensure that the graph is connected
vertices <- which(clusters(randomgraph)$membership==1)
graph <- induced.subgraph(randomgraph,vertices)
graph <- set.edge.attribute(graph, "weight", value=runif(ecount(graph),0,1))
adj <- get.adjacency(graph, attr="weight")
result <- extremalOptimization(adj)
Run the code above in your browser using DataLab