本文整理汇总了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;
}