本文整理汇总了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;
}
示例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();
}
示例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);
}
示例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 ] );
}
示例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;
}
}