当前位置: 首页>>代码示例>>Java>>正文


Java SingleSourceShortestPath类代码示例

本文整理汇总了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;
}
 
开发者ID:gsummer,项目名称:neoNetworkAnalyzer,代码行数:20,代码来源:BetweennessCentralityMulti.java

示例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);
				}
			}

		}

	}
 
开发者ID:gsummer,项目名称:neoNetworkAnalyzer,代码行数:19,代码来源:StressCentrality.java

示例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 );
    }
}
 
开发者ID:neo4j-contrib,项目名称:neo4j-mobile-android,代码行数:21,代码来源:Eccentricity.java

示例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 ) );
    }
}
 
开发者ID:neo4j-contrib,项目名称:neo4j-mobile-android,代码行数:26,代码来源:ClosenessCentrality.java

示例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();
    }

}
 
开发者ID:maxdemarzi,项目名称:graph_processing,代码行数:16,代码来源:Betweenness.java

示例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();
    }

}
 
开发者ID:maxdemarzi,项目名称:graph_processing,代码行数:28,代码来源:Closeness.java

示例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 );
}
 
开发者ID:maxdemarzi,项目名称:graph_processing,代码行数:15,代码来源:Utils.java

示例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));

}
 
开发者ID:gsummer,项目名称:neoNetworkAnalyzer,代码行数:37,代码来源:AverageShortestPathMulti.java

示例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 );
}
 
开发者ID:gsummer,项目名称:neoNetworkAnalyzer,代码行数:14,代码来源:StressCentrality.java

示例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;
}
 
开发者ID:neo4j-contrib,项目名称:neo4j-mobile-android,代码行数:17,代码来源:ParallellCentralityCalculation.java

示例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;
    }
}
 
开发者ID:neo4j-contrib,项目名称:neo4j-mobile-android,代码行数:13,代码来源:NetworkDiameter.java

示例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>() );
}
 
开发者ID:neo4j-contrib,项目名称:neo4j-mobile-android,代码行数:15,代码来源:BetweennessCentrality.java

示例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;
    }
}
 
开发者ID:neo4j-contrib,项目名称:neo4j-mobile-android,代码行数:13,代码来源:NetworkRadius.java

示例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>() );
}
 
开发者ID:neo4j-contrib,项目名称:neo4j-mobile-android,代码行数:15,代码来源:StressCentrality.java

示例15: LogParallelCentralityCalculation

import org.neo4j.graphalgo.impl.shortestpath.SingleSourceShortestPath; //导入依赖的package包/类
public LogParallelCentralityCalculation(
    SingleSourceShortestPath<ShortestPathCostType> singleSourceShortestPath,
    Set<Node> nodeSet )
{
    super(singleSourceShortestPath,nodeSet);
}
 
开发者ID:gsummer,项目名称:neoNetworkAnalyzer,代码行数:7,代码来源:LogParallelCentralityCalculation.java


注:本文中的org.neo4j.graphalgo.impl.shortestpath.SingleSourceShortestPath类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。