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


Java IntArrays.fill方法代码示例

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


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

示例1: distancesFrom

import it.unimi.dsi.fastutil.ints.IntArrays; //导入方法依赖的package包/类
private int[] distancesFrom( final ImmutableGraph graph, final int from ) {
	final IntArrayFIFOQueue queue = new IntArrayFIFOQueue();
	final int n = graph.numNodes();
	final int[] dist = new int[ n ];
	IntArrays.fill( dist, Integer.MAX_VALUE ); // Initially, all distances are infinity.

	queue.enqueue( from );
	dist[ from ] = 0;

	LazyIntIterator successors;

	while( ! queue.isEmpty() ) {
		int curr = queue.dequeueInt();
		successors = graph.successors( curr );
		int d = graph.outdegree( curr );
		while( d-- != 0 ) {
			int succ = successors.nextInt();
			if ( dist[ succ ] == Integer.MAX_VALUE ) {
				dist[ succ ] = dist[ curr ] + 1;
				queue.enqueue( succ );
			}
		}
	}
	
	return dist;		
}
 
开发者ID:lhelwerd,项目名称:WebGraph,代码行数:27,代码来源:HyperBallTest.java

示例2: HittingDistanceMinimizer

import it.unimi.dsi.fastutil.ints.IntArrays; //导入方法依赖的package包/类
@CommandLine(argNames={"graph", "milestones"})
public HittingDistanceMinimizer(ImmutableGraph graph, IntSet milestones) {
	this.graph = Transform.transpose(graph);
	this.milestones = milestones;
	minMilestoneDistance = new int[graph.numNodes()];
	IntArrays.fill(minMilestoneDistance, Integer.MAX_VALUE);
	closestMilestone = new int[graph.numNodes()];
	IntArrays.fill(closestMilestone, -1);
	milestoneQueue = new IntArrayPriorityQueue(milestones.toIntArray());
	runningVisitors = new ObjectOpenHashSet<Visitor>();
	pl  = new ProgressLogger(LOGGER, "milestones");
	pl.expectedUpdates = milestones.size();
	
}
 
开发者ID:corradomonti,项目名称:llamafur,代码行数:15,代码来源:HittingDistanceMinimizer.java

示例3: run

import it.unimi.dsi.fastutil.ints.IntArrays; //导入方法依赖的package包/类
@Override
public void run() {
	final IntArrayFIFOQueue queue = new IntArrayFIFOQueue();
	
	IntArrays.fill( dists, Integer.MAX_VALUE ); // Initially, all distances are infinity.
	
	int curr, succ;
	queue.enqueue( start );
	dists[ start ] = 0;

	LazyIntIterator successors;

	while( ! queue.isEmpty() ) {
		curr = queue.dequeueInt();
		successors = graph.successors( curr );
		int d = graph.outdegree( curr );
		while( d-- != 0 ) {
			succ = successors.nextInt();
			if ( dists[ succ ] == Integer.MAX_VALUE  ) {
				dists[ succ ] = dists[ curr ] + 1;
				queue.enqueue( succ );
			}
		}
	}
	
	startNewThreadAfter(this);
}
 
开发者ID:corradomonti,项目名称:llamafur,代码行数:28,代码来源:HittingDistanceMinimizer.java

示例4: ImmutableSubgraph

import it.unimi.dsi.fastutil.ints.IntArrays; //导入方法依赖的package包/类
/** Creates a new immutable subgraph using a given backing node array.
 * 
 * <P>Note that <code>subgraphNode</code> is <em>not</em> copied: thus, it must not
 * be modified until this subgraph is no longer in use.
 * 
 * @param supergraph the supergraph.
 * @param subgraphNode an increasing array containing the nodes defining the induced subgraph. 
 */
public ImmutableSubgraph( final ImmutableGraph supergraph, final int subgraphNode[] ) {
	this.supergraph = supergraph;
	this.supergraphAsSubgraph = supergraph instanceof ImmutableSubgraph ? (ImmutableSubgraph)supergraph : null;
	this.subgraphNode = subgraphNode;
	this.subgraphSize = subgraphNode.length;
	this.supergraphNumNodes = supergraph.numNodes();
	this.supergraphNode = new int[ supergraphNumNodes ];
	IntArrays.fill( supergraphNode, -1 );
	for( int i = subgraphSize; i-- != 0; ) supergraphNode[ subgraphNode[ i ] ] = i;
	for ( int i = 1; i < subgraphSize; i++ )
		if ( subgraphNode[ i - 1 ] >= subgraphNode[ i ] )
			throw new IllegalArgumentException( "The provided integer array is not strictly increasing: " + (i-1) + "-th element is " + subgraphNode[ i - 1 ] + ", " + i + "-th element is " + subgraphNode[ i ] );
	if ( subgraphSize > 0 && subgraphNode[ subgraphSize - 1 ] >= supergraphNumNodes ) throw new IllegalArgumentException( "Subnode index out of bounds: " + subgraphNode[ subgraphSize - 1 ] );
}
 
开发者ID:lhelwerd,项目名称:WebGraph,代码行数:23,代码来源:ImmutableSubgraph.java

示例5: call

import it.unimi.dsi.fastutil.ints.IntArrays; //导入方法依赖的package包/类
public Void call() {
	// We cache frequently used fields.
	final int[] distance = this.distance;
	final IntArrayFIFOQueue queue = this.queue;
	final ImmutableGraph graph = GeometricCentralities.this.graph.copy();

	for( ;; ) {
		final int curr = nextNode.getAndIncrement();
		if ( GeometricCentralities.this.stop || curr >= graph.numNodes() ) return null;
		queue.clear();
		queue.enqueue( curr );
		IntArrays.fill( distance, -1 );
		distance[ curr ] = 0;
		int reachable = 0;

		while( ! queue.isEmpty() ) {
			final int node = queue.dequeueInt();
			reachable++;
			final int d = distance[ node ] + 1;
			final double hd = 1. / d;
			final LazyIntIterator successors = graph.successors( node );
			for( int s; ( s = successors.nextInt() ) != -1; ) {
				if ( distance[ s ] == -1 ) {
					queue.enqueue( s );
					distance[ s ] = d;
					closeness[ curr ] += d;
					harmonic[ curr ] += hd;
				}
			}
		}

		if ( GeometricCentralities.this.pl != null ) 
			synchronized ( GeometricCentralities.this.pl ) {
				GeometricCentralities.this.pl.update();
			}

		if ( closeness[ curr ] == 0 ) lin[ curr ] = 1; // Terminal node
		else {
			closeness[ curr ] = 1 / closeness[ curr ];
			lin[ curr ] = (double)reachable * reachable * closeness[ curr ];
		}

		GeometricCentralities.this.reachable[ curr ] = reachable;
	}
}
 
开发者ID:lhelwerd,项目名称:WebGraph,代码行数:46,代码来源:GeometricCentralities.java


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