Package org.nlpub.watset.graph
Class MarkovClusteringExternal<V,E>
- java.lang.Object
-
- org.nlpub.watset.graph.MarkovClusteringExternal<V,E>
-
- Type Parameters:
V- the type of nodes in the graphE- the type of edges in the graph
- All Implemented Interfaces:
Clustering<V>
public class MarkovClusteringExternal<V,E> extends Object implements Clustering<V>
A wrapper for the official implementation of the Markov Clustering (MCL) algorithm in C.This is a weird thing. The official implementation of MCL is very fast, but we need to run the separate process and speak to it over standard input/output redirection.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classMarkovClusteringExternal.Builder<V,E>Builder forMarkovClusteringExternal.
-
Field Summary
Fields Modifier and Type Field Description protected org.jgrapht.Graph<V,E>graphThe graph.protected Map<V,Integer>mappingThe mapping of nodes to indices.protected FileoutputThe output file.protected PathpathThe path to the MCL binary.protected doublerThe inflation parameter.protected intthreadsThe number of threads.
-
Constructor Summary
Constructors Constructor Description MarkovClusteringExternal(org.jgrapht.Graph<V,E> graph, Path path, double r)MarkovClusteringExternal(org.jgrapht.Graph<V,E> graph, Path path, double r, int threads)Create an instance of the Markov Clustering algorithm wrapper.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voidfit()Run the algorithm to induce the parameters of the clusters.Collection<Collection<V>>getClusters()Return a collection of clusters, each cluster is a collection of objects.static <V,E>
Function<org.jgrapht.Graph<V,E>,Clustering<V>>provider(Path mcl, double r)Deprecated.Replaced withprovider(Path, double, int)static <V,E>
Function<org.jgrapht.Graph<V,E>,Clustering<V>>provider(Path mcl, double r, int threads)A factory function that sets up the algorithm for the given graph.
-
-
-
Constructor Detail
-
MarkovClusteringExternal
public MarkovClusteringExternal(org.jgrapht.Graph<V,E> graph, Path path, double r, int threads)
Create an instance of the Markov Clustering algorithm wrapper.- Parameters:
graph- the graphpath- the path to the MCL binaryr- the inflation parameterthreads- the number of threads
-
MarkovClusteringExternal
@Deprecated public MarkovClusteringExternal(org.jgrapht.Graph<V,E> graph, Path path, double r)
Create an instance of the Markov Clustering algorithm wrapper.- Parameters:
graph- the graphpath- the path to the MCL binaryr- the inflation parameter
-
-
Method Detail
-
provider
public static <V,E> Function<org.jgrapht.Graph<V,E>,Clustering<V>> provider(Path mcl, double r, int threads)
A factory function that sets up the algorithm for the given graph.- Type Parameters:
V- the type of nodes in the graphE- the type of edges in the graph- Parameters:
mcl- the path to the MCL binaryr- the inflation parameterthreads- the number of threads- Returns:
- a factory function that sets up the algorithm for the given graph
-
provider
@Deprecated public static <V,E> Function<org.jgrapht.Graph<V,E>,Clustering<V>> provider(Path mcl, double r)
Deprecated.Replaced withprovider(Path, double, int)A factory function that sets up the algorithm for the given graph.- Type Parameters:
V- the type of nodes in the graphE- the type of edges in the graph- Parameters:
mcl- the path to the MCL binaryr- the inflation parameter- Returns:
- a factory function that sets up the algorithm for the given graph
-
getClusters
public Collection<Collection<V>> getClusters()
Description copied from interface:ClusteringReturn a collection of clusters, each cluster is a collection of objects. Usually this method is called after theClustering.fit()method.- Specified by:
getClustersin interfaceClustering<V>- Returns:
- clusters
-
fit
public void fit()
Description copied from interface:ClusteringRun the algorithm to induce the parameters of the clusters.- Specified by:
fitin interfaceClustering<V>
-
-