com.github.rinde.rinsim.geom.Graph.getRandomNode()方法的使用及代码示例

x33g5p2x  于2022-01-20 转载在 其他  
字(2.8k)|赞(0)|评价(0)|浏览(138)

本文整理了Java中com.github.rinde.rinsim.geom.Graph.getRandomNode()方法的一些代码示例,展示了Graph.getRandomNode()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Graph.getRandomNode()方法的具体详情如下:
包路径:com.github.rinde.rinsim.geom.Graph
类名称:Graph
方法名:getRandomNode

Graph.getRandomNode介绍

[英]Get a random node in graph.
[中]在图中获取一个随机节点。

代码示例

代码示例来源:origin: com.github.rinde/rinsim-geom

@Override
public Point getRandomNode(RandomGenerator generator) {
 return delegate.getRandomNode(generator);
}

代码示例来源:origin: rinde/RinSim

@Override
public Point getRandomNode(RandomGenerator generator) {
 return delegate.getRandomNode(generator);
}

代码示例来源:origin: rinde/RinSim

@Override
public Point getRandomPosition(RandomGenerator rnd) {
 return graph.getRandomNode(rnd);
}

代码示例来源:origin: rinde/RinSim

@Test(expected = IllegalStateException.class)
public void randomNodeEmptyGraph() {
 graph.getRandomNode(new MersenneTwister(234));
}

代码示例来源:origin: rinde/RinSim

@Override
public ImmutableList<AddParcelEvent> generate(long seed,
  TravelTimes travelModel, long endTime) {
 rng.setSeed(seed);
 final ImmutableList.Builder<AddParcelEvent> eventList = ImmutableList
  .builder();
 final List<Double> times = announceTimeGenerator.generate(rng.nextLong());
 final ImmutableList.Builder<Point> locsB = ImmutableList.builder();
 for (int i = 0; i < times.size() * 2; i++) {
  locsB.add(graph.getRandomNode(rng));
 }
 final Iterator<Point> locs = locsB.build().iterator();
 for (final double time : times) {
  final long arrivalTime = DoubleMath.roundToLong(time,
   RoundingMode.FLOOR);
  final Point origin = locs.next();
  final Point destination = locs.next();
  checkEndTime(time, endTime);
  final Parcel.Builder parcelBuilder = Parcel
   .builder(origin, destination)
   .orderAnnounceTime(arrivalTime)
   .pickupDuration(pickupDurationGenerator.get(rng.nextLong()))
   .deliveryDuration(deliveryDurationGenerator.get(rng.nextLong()))
   .neededCapacity(neededCapacityGenerator.get(rng.nextLong()));
  timeWindowGenerator.generate(rng.nextLong(), parcelBuilder,
   travelModel, endTime);
  eventList.add(AddParcelEvent.create(parcelBuilder.buildDTO()));
 }
 return eventList.build();
}

代码示例来源:origin: rinde/RinSim

@Test
public void testRandomNode() {
 final RandomGenerator rnd = new MersenneTwister(456);
 for (int i = 0; i < 500; i++) {
  Graphs.addBiPath(graph, new Point(rnd.nextInt(), rnd.nextInt()),
   new Point(rnd.nextInt(), rnd.nextInt()));
 }
 final Graph<LengthData> unmod = Graphs.unmodifiableGraph(graph);
 final Point p1 = graph.getRandomNode(new MersenneTwister(123));
 final Point p2 = unmod.getRandomNode(new MersenneTwister(123));
 assertEquals(p1, p2);
}

代码示例来源:origin: rinde/RinSim

boolean flag = false;
try {
 graph.getRandomNode(rg);
} catch (final IllegalStateException e) {
 flag = true;

代码示例来源:origin: rinde/RinSim

endTime * .8, RoundingMode.FLOOR));
b.addEvent(AddParcelEvent.create(Parcel
 .builder(g.getRandomNode(rng), g.getRandomNode(rng))
 .orderAnnounceTime(announceTime)
 .pickupTimeWindow(TimeWindow.create(announceTime, endTime))

相关文章