本文整理汇总了Java中org.apache.commons.collections15.functors.MapTransformer.getInstance方法的典型用法代码示例。如果您正苦于以下问题:Java MapTransformer.getInstance方法的具体用法?Java MapTransformer.getInstance怎么用?Java MapTransformer.getInstance使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.commons.collections15.functors.MapTransformer
的用法示例。
在下文中一共展示了MapTransformer.getInstance方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: lengthTransformation
import org.apache.commons.collections15.functors.MapTransformer; //导入方法依赖的package包/类
/** This method does the following length transformation:
*
* <pre> c'(v,w) = c(v,w) - d (s,w) + d (s,v) </pre>
*
* @param graph1 the graph
* @param slTrans The shortest length transformer
* @return the transformed graph
* @since 0.3.0 */
private Transformer<E, Double> lengthTransformation(Graph<V, E> graph1, Transformer<V, Number> slTrans)
{
Map<E, Double> map = new LinkedHashMap<E, Double>();
for (E link : graph1.getEdges())
{
double newWeight;
if (slTrans.transform(graph1.getSource(link)) == null)
{
newWeight = Double.MAX_VALUE;
} else
{
newWeight = nev.transform(link) - slTrans.transform(graph1.getDest(link)).doubleValue() + slTrans.transform(graph1.getSource(link)).doubleValue();
if (newWeight < 0 || newWeight > -1e-6) newWeight = 0; /* Numerical errors */
}
map.put(link, newWeight);
}
return MapTransformer.getInstance(map);
}
示例2: lengthTransformation
import org.apache.commons.collections15.functors.MapTransformer; //导入方法依赖的package包/类
/**
* This method does the following length transformation:
*
* <pre>
* c'(v,w) = c(v,w) - d (s,w) + d (s,v)
* </pre>
*
* @param graph1
* the graph
* @param slTrans
* The shortest length transformer
* @return the transformed graph
*/
private Transformer<E, Double> lengthTransformation(Graph<V, E> graph1,
Transformer<V, Number> slTrans) {
Map<E, Double> map = new HashMap<E, Double>();
for (E link : graph1.getEdges()) {
double newWeight = nev.transform(link).doubleValue()
- slTrans.transform(graph1.getDest(link)).doubleValue()
+ slTrans.transform(graph1.getSource(link)).doubleValue();
map.put(link, newWeight);
}
return MapTransformer.getInstance(map);
}
示例3: performPageRank
import org.apache.commons.collections15.functors.MapTransformer; //导入方法依赖的package包/类
@Override
protected PageRankWithPriors<Vertex, Edge> performPageRank() {
PageRankWithPriors<Vertex, Edge> pr = new PageRankWithPriors<Vertex, Edge>(
graph, MapTransformer.getInstance(edgeWeights),
getRootPrior(graph.getVertices()), 0.13);
pr.setMaxIterations(250);
pr.evaluate();
return pr;
}
示例4: performPageRank
import org.apache.commons.collections15.functors.MapTransformer; //导入方法依赖的package包/类
@Override
protected PageRankWithPriors<Vertex, Edge> performPageRank() {
PageRankWithPriors<Vertex, Edge> pr = new PageRankWithPriors<Vertex, Edge>(
graph, MapTransformer.getInstance(edgeWeights),
getRootPrior(graph.getVertices()), 0.09);
pr.setMaxIterations(iterations);
pr.evaluate();
return pr;
}
示例5: performPageRank
import org.apache.commons.collections15.functors.MapTransformer; //导入方法依赖的package包/类
@Override
protected PageRankWithPriors<Vertex, Edge> performPageRank() {
PageRankWithPriors<Vertex, Edge> pr = new PageRankWithPriors<Vertex, Edge>(
graph, MapTransformer.getInstance(edgeWeights),
getRootPrior(graph.getVertices()), 0.13);
pr.setMaxIterations(75);
pr.evaluate();
return pr;
}
示例6: performPageRank
import org.apache.commons.collections15.functors.MapTransformer; //导入方法依赖的package包/类
protected PageRankWithPriors<Vertex, Edge> performPageRank() {
PageRankWithPriors<Vertex, Edge> pr = new PageRankWithPriors<Vertex, Edge>(
graph, MapTransformer.getInstance(edgeWeights),
getRootPrior(graph.getVertices()), 0.15);
pr.setMaxIterations(200);
pr.evaluate();
return pr;
}
示例7: performPageRank
import org.apache.commons.collections15.functors.MapTransformer; //导入方法依赖的package包/类
protected PageRankWithPriors<Vertex, Edge> performPageRank() {
PageRankWithPriors<Vertex, Edge> pr = new PageRankWithPriors<Vertex, Edge>(graph,
MapTransformer.getInstance(edgeWeights), getRootPrior(graph.getVertices()), 0.15);
pr.setMaxIterations(200);
pr.evaluate();
return pr;
}
示例8: process
import org.apache.commons.collections15.functors.MapTransformer; //导入方法依赖的package包/类
@Override
public String process(Map<DisambiguatedEntity, Integer> map, Paragraph p, Languages lang) {
Set<String> entitySet = new HashSet<String>();
List<String> entities = new LinkedList<String>();
for (Map.Entry<DisambiguatedEntity, Integer> entry : map.entrySet()) {
entities.add(entry.getKey().getEntityUri());
entitySet.add(entry.getKey().getEntityUri());
}
if (entities.size() == 0) {
return "";
} else {
computeWord2VecSimilarities(entitySet);
DirectedGraph<Vertex, Edge> graph = buildGraph(entities);
PageRank<Vertex, Edge> pr = new PageRank<Vertex, Edge>(graph,
MapTransformer.getInstance(edgeWeights), 0.1);
pr.setMaxIterations(100);
pr.evaluate();
Collection<Vertex> vertexCol = graph.getVertices();
String topEntity = null;
double max = 0;
for (Vertex v : vertexCol) {
Double score = pr.getVertexScore(v);
if (score > max) {
topEntity = v.getUris().get(0);
max = score;
}
}
return topEntity;
}
}
示例9: lengthTransformation
import org.apache.commons.collections15.functors.MapTransformer; //导入方法依赖的package包/类
/**
* This method does the following length transformation:
* <p/>
* <pre>
* c'(v,w) = c(v,w) - d (s,w) + d (s,v)
* </pre>
*
* @param graph1 the graph
* @param slTrans The shortest length transformer
* @return the transformed graph
*/
private Transformer<E, Double> lengthTransformation(Graph<V, E> graph1,
Transformer<V, Number> slTrans) {
Map<E, Double> map = new HashMap<E, Double>();
for (E link : graph1.getEdges()) {
double newWeight = nev.transform(link).doubleValue()
- slTrans.transform(graph1.getDest(link)).doubleValue()
+ slTrans.transform(graph1.getSource(link)).doubleValue();
map.put(link, newWeight);
}
return MapTransformer.getInstance(map);
}
示例10: getStationaryDistribution
import org.apache.commons.collections15.functors.MapTransformer; //导入方法依赖的package包/类
/**
* Loads the stationary distribution into a vector if it was passed in,
* or calculates it if not.
*
* @return DoubleMatrix1D
*/
private DoubleMatrix1D getStationaryDistribution() {
DoubleMatrix1D piVector = new DenseDoubleMatrix1D(getVertexCount());
PageRank<V,E> pageRank = new PageRank<V,E>(getGraph(),
MapTransformer.getInstance(getEdgeWeights()), 0);
pageRank.evaluate();
for (V v : getGraph().getVertices())
piVector.set(mIndexer.get(v), pageRank.getVertexScore(v));
return piVector;
}
示例11: getSetToCollapsedVertexTransformer
import org.apache.commons.collections15.functors.MapTransformer; //导入方法依赖的package包/类
/**
* Returns a transformer from vertex sets in the original graph to collapsed vertices
* in the transformed graph.
*/
public Transformer<Set<V>, CV> getSetToCollapsedVertexTransformer()
{
return MapTransformer.getInstance(set_collapsedv);
}