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


Java LongArrays.EMPTY_ARRAY属性代码示例

本文整理汇总了Java中it.unimi.dsi.fastutil.longs.LongArrays.EMPTY_ARRAY属性的典型用法代码示例。如果您正苦于以下问题:Java LongArrays.EMPTY_ARRAY属性的具体用法?Java LongArrays.EMPTY_ARRAY怎么用?Java LongArrays.EMPTY_ARRAY使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在it.unimi.dsi.fastutil.longs.LongArrays的用法示例。


在下文中一共展示了LongArrays.EMPTY_ARRAY属性的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: computeExact

/** Computes and returns the neighbourhood function of the specified graph by multiple breadth-first visits.
 * 
 * <p>This method returns an array of longs. When some values of the function are near 2<sup>63</sup>, it
 * provides an exact value, as opposed to {@link #compute(ImmutableGraph, int, ProgressLogger)}.
 * 
 * @param g a graph.
 * @param threads the requested number of threads (0 for {@link Runtime#availableProcessors()}).
 * @param pl a progress logger, or <code>null</code>.
 * @return the neighbourhood function of the specified graph as an array of longs.
 */
public static long[] computeExact( final ImmutableGraph g, final int threads, final ProgressLogger pl ) {
	final int n = g.numNodes();
	long count[] = LongArrays.EMPTY_ARRAY;
	
	ParallelBreadthFirstVisit visit = new ParallelBreadthFirstVisit( g, threads, true, null );

	if ( pl != null ) {
		pl.itemsName = "nodes";
		pl.expectedUpdates = n;
		pl.start();
	}

	for( int i = 0; i < n; i++ ) {
		visit.clear();
		visit.visit( i );
		final int maxDistance = visit.maxDistance();
		if ( count.length <= maxDistance ) count = LongArrays.grow( count, maxDistance + 1 );
		for( int d = maxDistance + 1; d-- != 0; ) count[ d ] += visit.cutPoints.getInt( d + 1 ) - visit.cutPoints.getInt( d ); 
		if ( pl != null ) pl.update();
	}

	if ( pl != null ) pl.done();
	
	int last;
	for( last = count.length; last-- != 0 && count[ last ] == 0; );
	last++;
	final long[] result = new long[ last ];
	result[ 0 ] = count[ 0 ];
	for( int i = 1; i < last; i++ ) result[ i ] = result[ i - 1 ] + count[ i ];
	return result;
}
 
开发者ID:lhelwerd,项目名称:WebGraph,代码行数:41,代码来源:NeighbourhoodFunction.java


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