本文整理汇总了Java中org.neo4j.graphalgo.impl.shortestpath.SingleSourceShortestPath类的典型用法代码示例。如果您正苦于以下问题:Java SingleSourceShortestPath类的具体用法?Java SingleSourceShortestPath怎么用?Java SingleSourceShortestPath使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
SingleSourceShortestPath类属于org.neo4j.graphalgo.impl.shortestpath包,在下文中一共展示了SingleSourceShortestPath类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: processShortestPaths
import org.neo4j.graphalgo.impl.shortestpath.SingleSourceShortestPath; //导入依赖的package包/类
@Override
public void processShortestPaths( Node node,
SingleSourceShortestPath<ShortestPathCostType> singleSourceShortestPath )
{
// Extract predecessors and successors
Map<Node,List<Relationship>> predecessors = singleSourceShortestPath
.getPredecessors();
filterMultiEdgePaths(predecessors);
Map<Node,List<Relationship>> successors = Util
.reversedPredecessors( predecessors );
PathCounter counter = new Util.PathCounter( predecessors );
getAndUpdateNodeDependency( node, true, successors, counter,
new HashMap<Node,Double>() );
++currNodeI;
}
示例2: processShortestPaths
import org.neo4j.graphalgo.impl.shortestpath.SingleSourceShortestPath; //导入依赖的package包/类
@Override
public void processShortestPaths(
Node node,
SingleSourceShortestPath<ShortestPathCostType> singleSourceShortestPath) {
for(Node n : nodeSet){
Set<List<Node>> paths = new HashSet<List<Node>>(singleSourceShortestPath.getPathsAsNodes(n));
// List<List<Node>> paths = singleSourceShortestPath.getPathsAsNodes(n);
for(List<Node> path : paths){
for(int i = 1; i < (path.size()-1); ++i){
addCentralityToNode(path.get(i), 1L);
}
}
}
}
示例3: processShortestPaths
import org.neo4j.graphalgo.impl.shortestpath.SingleSourceShortestPath; //导入依赖的package包/类
@Override
public void processShortestPaths( Node node,
SingleSourceShortestPath<ShortestPathCostType> singleSourceShortestPath )
{
ShortestPathCostType maximumDistance = null;
for ( Node targetNode : nodeSet )
{
ShortestPathCostType targetDistance = singleSourceShortestPath
.getCost( targetNode );
if ( maximumDistance == null
|| distanceComparator.compare( maximumDistance, targetDistance ) < 0 )
{
maximumDistance = targetDistance;
}
}
if ( maximumDistance != null )
{
setCentralityForNode( node, maximumDistance );
}
}
示例4: processShortestPaths
import org.neo4j.graphalgo.impl.shortestpath.SingleSourceShortestPath; //导入依赖的package包/类
@Override
public void processShortestPaths( Node node,
SingleSourceShortestPath<ShortestPathCostType> singleSourceShortestPath )
{
ShortestPathCostType shortestPathSum = null;
for ( Node targetNode : nodeSet )
{
if ( shortestPathSum == null )
{
shortestPathSum = singleSourceShortestPath.getCost( targetNode );
}
else
{
shortestPathSum = centralityAccumulator.addCosts(
shortestPathSum, singleSourceShortestPath
.getCost( targetNode ) );
}
}
// TODO: what should the result be when sum is 0 ?
if ( !shortestPathSum.equals( zeroValue ) )
{
setCentralityForNode( node, centralityDivider.divideByCost( 1.0,
shortestPathSum ) );
}
}
示例5: compute
import org.neo4j.graphalgo.impl.shortestpath.SingleSourceShortestPath; //导入依赖的package包/类
@Override
public void compute(String label, String type, int iterations) {
SingleSourceShortestPath<Double> singleSourceShortestPath = getSingleSourceShortestPath(DynamicRelationshipType.withName(type));
Set<Node> nodes = new HashSet<>();
try ( Transaction tx = db.beginTx()) {
ResourceIterator<Node> iterator = db.findNodes(Label.label(label));
while (iterator.hasNext()) {
nodes.add(iterator.next());
}
betweennessCentrality = new BetweennessCentrality<Double>(
singleSourceShortestPath, nodes);
betweennessCentrality.calculate();
}
}
示例6: compute
import org.neo4j.graphalgo.impl.shortestpath.SingleSourceShortestPath; //导入依赖的package包/类
@Override
public void compute(String label, String type, int iterations) {
SingleSourceShortestPath<Double> singleSourceShortestPath = getSingleSourceShortestPath(DynamicRelationshipType.withName(type));
Set<Node> nodes = new HashSet<>();
try ( Transaction tx = db.beginTx()) {
ResourceIterator<Node> iterator = db.findNodes(Label.label(label));
while (iterator.hasNext()) {
nodes.add(iterator.next());
}
closenessCentrality = new ClosenessCentrality<>(
singleSourceShortestPath, new DoubleAdder(), 0.0, nodes, new CostDivider<Double>()
{
public Double divideByCost( Double d, Double c )
{
return d / c;
}
public Double divideCost( Double c, Double d )
{
return c / d;
}
});
closenessCentrality.calculate();
}
}
示例7: getSingleSourceShortestPath
import org.neo4j.graphalgo.impl.shortestpath.SingleSourceShortestPath; //导入依赖的package包/类
public static SingleSourceShortestPath<Double> getSingleSourceShortestPath(RelationshipType relationshipType)
{
return new SingleSourceShortestPathDijkstra<Double>( 0.0, null,
new CostEvaluator<Double>()
{
public Double getCost( Relationship relationship,
Direction direction )
{
return 1.0;
}
}, new org.neo4j.graphalgo.impl.util.DoubleAdder(),
new org.neo4j.graphalgo.impl.util.DoubleComparator(),
Direction.BOTH, relationshipType );
}
示例8: processShortestPaths
import org.neo4j.graphalgo.impl.shortestpath.SingleSourceShortestPath; //导入依赖的package包/类
@Override
public void processShortestPaths(
Node node,
SingleSourceShortestPath<ShortestPathCostType> singleSourceShortestPath) {
long sum = 0;
long numPaths = 0;
Set<Node> visited = new HashSet<Node>();
for(Node n : nodeSet){
List<List<Node>> paths = singleSourceShortestPath.getPathsAsNodes(n);
// numPaths += paths.size();
for(List<Node> path : paths){
for(int i = 1; i < path.size(); ++i){
if(visited.contains(path.get(i)))
continue;
else {
sum += i;
++numPaths;
visited.add(path.get(i));
}
}
}
}
// double avgSP = sum / (double)numPaths;
// setCentralityForNode(node, avgSP);
// numPaths
numPathsMap.put(node,new Long(numPaths));
sumPathsMap.put(node, new Long(sum));
}
示例9: StressCentrality
import org.neo4j.graphalgo.impl.shortestpath.SingleSourceShortestPath; //导入依赖的package包/类
public StressCentrality(
SingleSourceShortestPath<ShortestPathCostType> singleSourceShortestPath,
Set<Node> nodeSet )
{
super( singleSourceShortestPath, new CostAccumulator<Long>(){
@Override
public Long addCosts(Long c1, Long c2) {
return c1 + c2;
}
}, 0L, nodeSet );
}
示例10: ParallellCentralityCalculation
import org.neo4j.graphalgo.impl.shortestpath.SingleSourceShortestPath; //导入依赖的package包/类
/**
* Default constructor.
* @param singleSourceShortestPath
* Underlying singleSourceShortestPath.
* @param nodeSet
* A set containing the nodes for which centrality values should
* be computed.
*/
public ParallellCentralityCalculation(
SingleSourceShortestPath<ShortestPathCostType> singleSourceShortestPath,
Set<Node> nodeSet )
{
super();
this.singleSourceShortestPath = singleSourceShortestPath;
this.nodeSet = nodeSet;
}
示例11: processShortestPaths
import org.neo4j.graphalgo.impl.shortestpath.SingleSourceShortestPath; //导入依赖的package包/类
@Override
public void processShortestPaths( Node node,
SingleSourceShortestPath<ShortestPathCostType> singleSourceShortestPath )
{
eccentricity.processShortestPaths( node, singleSourceShortestPath );
ShortestPathCostType centrality = eccentricity.getCentrality( node );
if ( diameter == null
|| distanceComparator.compare( centrality, diameter ) > 0 )
{
diameter = centrality;
}
}
示例12: processShortestPaths
import org.neo4j.graphalgo.impl.shortestpath.SingleSourceShortestPath; //导入依赖的package包/类
@Override
public void processShortestPaths( Node node,
SingleSourceShortestPath<ShortestPathCostType> singleSourceShortestPath )
{
// Extract predecessors and successors
Map<Node,List<Relationship>> predecessors = singleSourceShortestPath
.getPredecessors();
Map<Node,List<Relationship>> successors = Util
.reversedPredecessors( predecessors );
PathCounter counter = new Util.PathCounter( predecessors );
// Recursively update the node dependencies
getAndUpdateNodeDependency( node, true, successors, counter,
new HashMap<Node,Double>() );
}
示例13: processShortestPaths
import org.neo4j.graphalgo.impl.shortestpath.SingleSourceShortestPath; //导入依赖的package包/类
@Override
public void processShortestPaths( Node node,
SingleSourceShortestPath<ShortestPathCostType> singleSourceShortestPath )
{
eccentricity.processShortestPaths( node, singleSourceShortestPath );
ShortestPathCostType centrality = eccentricity.getCentrality( node );
if ( radius == null
|| distanceComparator.compare( centrality, radius ) < 0 )
{
radius = centrality;
}
}
示例14: processShortestPaths
import org.neo4j.graphalgo.impl.shortestpath.SingleSourceShortestPath; //导入依赖的package包/类
@Override
public void processShortestPaths( Node node,
SingleSourceShortestPath<ShortestPathCostType> singleSourceShortestPath )
{
// Extract predecessors and successors
Map<Node,List<Relationship>> predecessors = singleSourceShortestPath
.getPredecessors();
Map<Node,List<Relationship>> successors = Util
.reversedPredecessors( predecessors );
PathCounter counter = new Util.PathCounter( predecessors );
// Recursively update the node dependencies
getAndUpdateNodeStress( node, true, successors, counter,
new HashMap<Node,Double>() );
}
示例15: LogParallelCentralityCalculation
import org.neo4j.graphalgo.impl.shortestpath.SingleSourceShortestPath; //导入依赖的package包/类
public LogParallelCentralityCalculation(
SingleSourceShortestPath<ShortestPathCostType> singleSourceShortestPath,
Set<Node> nodeSet )
{
super(singleSourceShortestPath,nodeSet);
}