Class MarkovClustering<V,​E>

  • Type Parameters:
    V - the type of nodes in the graph
    E - the type of edges in the graph
    All Implemented Interfaces:
    Clustering<V>

    public class MarkovClustering<V,​E>
    extends Object
    implements Clustering<V>
    Naïve implementation of the Markov Clustering (MCL) algorithm.

    This implementation assumes processing of relatively small graphs due to the lack of pruning optimizations.

    See Also:
    van Dongen (2008)
    • Field Detail

      • ITERATIONS

        public static final Integer ITERATIONS
        The default number of Markov Clustering iterations.
      • graph

        protected final org.jgrapht.Graph<V,​E> graph
        The graph.
      • e

        protected final int e
        The expansion parameter.
      • r

        protected final double r
        The inflation parameter.
      • inflateVisitor

        protected final MarkovClustering.InflateVisitor inflateVisitor
        The inflation visitor that raises each element of matrix to the power of r.
      • matrix

        protected org.apache.commons.math3.linear.RealMatrix matrix
        The stochastic matrix.
      • ones

        protected org.apache.commons.math3.linear.RealMatrix ones
        The row matrix filled by ones.
      • index

        protected Map<V,​Integer> index
        The mapping of graph nodes to the columns of matrix.
    • Constructor Detail

      • MarkovClustering

        public MarkovClustering​(org.jgrapht.Graph<V,​E> graph,
                                int e,
                                double r)
        Create an instance of the Markov Clustering algorithm.
        Parameters:
        graph - the graph
        e - the expansion parameter
        r - the inflation parameter
    • Method Detail

      • provider

        public static <V,​E> Function<org.jgrapht.Graph<V,​E>,​Clustering<V>> provider​(int e,
                                                                                                      double r)
        A factory function that sets up the algorithm for the given graph.
        Type Parameters:
        V - the type of nodes in the graph
        E - the type of edges in the graph
        Parameters:
        e - the expansion parameter
        r - the inflation parameter
        Returns:
        a factory function that sets up the algorithm for the given graph
      • fit

        public void fit()
        Description copied from interface: Clustering
        Run the algorithm to induce the parameters of the clusters.
        Specified by:
        fit in interface Clustering<V>
      • buildIndex

        protected Map<V,​Integer> buildIndex()
        Index the nodes of the input graph.
        Returns:
        a node index
      • buildMatrix

        protected org.apache.commons.math3.linear.RealMatrix buildMatrix​(Map<V,​Integer> index)
        Construct an adjacency matrix for the given graph.

        Note that the loops in the graph are ignored.

        Parameters:
        index - the node index
        Returns:
        an adjacency matrix
      • normalize

        protected void normalize()
        Normalize the matrix.
      • expand

        protected void expand()
        Perform the expansion step.
      • inflate

        protected void inflate()
        Perform the inflation step.