Class Modularity<U>
java.lang.Object
es.uam.eps.ir.relison.sna.metrics.communities.graph.Modularity<U>
- Type Parameters:
U
- The type of the users.
- All Implemented Interfaces:
CommunityMetric<U>
public class Modularity<U> extends java.lang.Object implements CommunityMetric<U>
Computes the modularity of a graph, given the communities.
Reference: M.E.J. Newman, M. Girvan. Finding and evaluating community structure in networks. Physical Review E 69(2), pp. 1-16 (2004)
-
Constructor Summary
Constructors Constructor Description Modularity()
-
Method Summary
Modifier and Type Method Description double
compute(Graph<U> graph, Communities<U> comm)
Computes the value of the metric in the graph.private double
computeDirected(DirectedGraph<U> graph, Communities<U> comm, MultiGraph<java.lang.Integer> commGraph)
Computes the value of the modularity for a directed graphprivate double
computeUndirected(UndirectedGraph<U> graph, Communities<U> comm, MultiGraph<java.lang.Integer> commGraph)
Computes the value of the modularity for an undirected graph.
-
Constructor Details
-
Modularity
public Modularity()
-
-
Method Details
-
compute
Description copied from interface:CommunityMetric
Computes the value of the metric in the graph.- Specified by:
compute
in interfaceCommunityMetric<U>
- Parameters:
graph
- Graph.comm
- Communities of the graph.- Returns:
- the value of the metric.
-
computeDirected
private double computeDirected(DirectedGraph<U> graph, Communities<U> comm, MultiGraph<java.lang.Integer> commGraph)Computes the value of the modularity for a directed graph- Parameters:
graph
- The directed graphcomm
- The communitiescommGraph
- The community graph- Returns:
- The value of the modularity
-
computeUndirected
private double computeUndirected(UndirectedGraph<U> graph, Communities<U> comm, MultiGraph<java.lang.Integer> commGraph)Computes the value of the modularity for an undirected graph.- Parameters:
graph
- The undirected graph.comm
- The communities.commGraph
- The community graph.- Returns:
- The value of the modularity of the graph.
-