本文整理汇总了Java中org.apache.commons.collections15.functors.MapTransformer类的典型用法代码示例。如果您正苦于以下问题:Java MapTransformer类的具体用法?Java MapTransformer怎么用?Java MapTransformer使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
MapTransformer类属于org.apache.commons.collections15.functors包,在下文中一共展示了MapTransformer类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: groupCluster
import org.apache.commons.collections15.functors.MapTransformer; //导入依赖的package包/类
private static void groupCluster(AggregateLayout<VisualNode,VisualEdge> layout, Set<VisualNode> vertices) {
if(vertices.size() < layout.getGraph().getVertexCount()) {
Point2D center = layout.transform(vertices.iterator().next());
Graph<VisualNode,VisualEdge> subGraph = DirectedSparseGraph.<VisualNode,VisualEdge>getFactory().create();
for(VisualNode v : vertices) {
subGraph.addVertex(v);
}
Layout<VisualNode,VisualEdge> subLayout = new VisualCirclesLayout(subGraph);
subLayout.setInitializer(HecataeusViewer.getActiveViewer().getGraphLayout());
subLayout.setSize(new Dimension(40,40));
layout.put(subLayout,center);
HecataeusViewer.vv.getRenderContext().setVertexFillPaintTransformer(MapTransformer.<VisualNode,Paint>getInstance(vertexPaints));
HecataeusViewer.getActiveViewer().repaint();
}
}
示例3: 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);
}
示例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.13);
pr.setMaxIterations(250);
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.09);
pr.setMaxIterations(iterations);
pr.evaluate();
return pr;
}
示例6: 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;
}
示例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: 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;
}
示例9: 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;
}
}
示例10: 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);
}
示例11: 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;
}
示例12: getDisjointPaths
import org.apache.commons.collections15.functors.MapTransformer; //导入依赖的package包/类
/** <p>Returns the shortest link-disjoint path pair (in increasing order of weight).</p> <p><b>Important</b>: If only one path can be found, only such a path will be returned.</p>
*
* @param startVertex Start vertex of the calculated paths
* @param endVertex Target vertex of the calculated paths
* @return List of paths in increasing order of weight */
private List<List<E>> getDisjointPaths(V startVertex, V endVertex)
{
List<List<E>> linkDisjointSPs = new LinkedList<List<E>>();
if (!graph.containsVertex(startVertex) || !graph.containsVertex(endVertex) || startVertex.equals(endVertex)) return linkDisjointSPs;
/* If target is not reachable, return */
if (dijkstra.getDistance(startVertex, endVertex) == null) return linkDisjointSPs;
List<E> sp = dijkstra.getPath(startVertex, endVertex);
/* Determine length of shortest path from "source" to any other node */
Map<V, Number> lengthMap = dijkstra.getDistanceMap(startVertex);
/* Length transformation */
Transformer<E, Double> lengthTrans = lengthTransformation(graph, MapTransformer.getInstance(lengthMap));
/* Get shortest path in g with reversed shortest path... */
Graph<V, E> revG = reverseEdges(graph, sp);
DijkstraShortestPath<V, E> revDijkstra = new DijkstraShortestPath<V, E>(revG, lengthTrans, cached);
Number revDistance = revDijkstra.getDistance(startVertex, endVertex);
if (revDistance == null || revDistance.doubleValue() == Double.MAX_VALUE)
{
/* no alternate path, return */
linkDisjointSPs.add(sp);
return linkDisjointSPs;
}
List<E> revSp = revDijkstra.getPath(startVertex, endVertex);
validatePath(graph, startVertex, endVertex, sp);
validatePath(revG, startVertex, endVertex, revSp);
List<E> spCopy = new LinkedList<E>(sp);
List<List<E>> paths = findDisjointPaths(sp, revSp);
if (paths == null)
{
/* no disjoint solution found, just return shortest path */
linkDisjointSPs.add(spCopy);
return linkDisjointSPs;
}
/* Check path validity */
for (List<E> path : paths)
validatePath(graph, startVertex, endVertex, path);
return paths;
}
示例13: 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);
}