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

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

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

Graph.setConnectionData介绍

[英]Set connection data. Precondition: connection from -> to exists.
[中]设置连接数据。前提条件:存在从->到的连接。

代码示例

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

@Override
public Optional<E> setConnectionData(Point from, Point to, E connData) {
 return delegate.setConnectionData(from, to, connData);
}

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

@Override
public Optional<E> setConnectionData(Point from, Point to, E connData) {
 return delegate.setConnectionData(from, to, connData);
}

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

@Override
public Optional<E> setConnectionData(Point from, Point to, E connectionData) {
 final Optional<E> val =
  delegate.setConnectionData(from, to, connectionData);
 eventDispatcher.dispatchEvent(new GraphEvent(
  EventTypes.CHANGE_CONNECTION_DATA, this, getConnection(from, to)));
 return val;
}

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

@Override
public Optional<E> setConnectionData(Point from, Point to, E connectionData) {
 final Optional<E> val =
  delegate.setConnectionData(from, to, connectionData);
 eventDispatcher.dispatchEvent(new GraphEvent(
  EventTypes.CHANGE_CONNECTION_DATA, this, getConnection(from, to)));
 return val;
}

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

@Test(expected = UnsupportedOperationException.class)
public void unmodSetConnData() {
 Graphs.unmodifiableGraph(graph).setConnectionData(null, null, null);
}

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

@Override
public void handleTimedEvent(ChangeConnectionSpeedEvent event,
  SimulatorAPI simulator) {
 final Graph<MultiAttributeData> graph =
  (Graph<MultiAttributeData>) ((Simulator) simulator)
   .getModelProvider().getModel(PDPDynamicGraphRoadModel.class)
   .getGraph();
 final MultiAttributeData data =
  graph.connectionData(event.getFrom(), event.getTo()).get();
 graph.setConnectionData(
  event.getFrom(),
  event.getTo(),
  MultiAttributeData.builder()
   .addAllAttributes(data.getAttributes())
   .setLength(data.getLength().get())
   .setMaxSpeed(data.getMaxSpeed().get() * event.getFactor())
   .build());
}

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

@Override
public void handleTimedEvent(ChangeConnectionSpeedEvent event,
  SimulatorAPI simulator) {
 final Graph<MultiAttributeData> graph =
  (Graph<MultiAttributeData>) ((Simulator) simulator)
   .getModelProvider().getModel(PDPDynamicGraphRoadModel.class)
   .getGraph();
 final MultiAttributeData data =
  graph.connectionData(event.getFrom(), event.getTo()).get();
 graph.setConnectionData(
  event.getFrom(),
  event.getTo(),
  MultiAttributeData.builder()
   .addAllAttributes(data.getAttributes())
   .setLength(data.getLength().get())
   .setMaxSpeed(data.getMaxSpeed().get() * event.getFactor())
   .build());
}

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

/**
 * The shortest path changes based on the connection data.
 */
@Test
public void shortestPathConnData() {
 final Point a = new Point(0, 0);
 final Point b = new Point(10, 0);
 final Point c = new Point(5, 5);
 Graphs.addBiPath(graph, a, b, c, a);
 assertEquals(asList(a, b),
  Graphs.shortestPathEuclideanDistance(graph, a, b));
 graph.setConnectionData(a, c, LengthData.create(1d));
 graph.setConnectionData(c, b, LengthData.create(1d));
 assertEquals(asList(a, c, b),
  Graphs.shortestPathEuclideanDistance(graph, a, b));
}

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

@Test
public void setConnData() {
 final Point N = new Point(0, 5);
 final Point E = new Point(5, 0);
 final Point S = new Point(0, -5);
 final Point W = new Point(-5, 0);
 Graphs.addBiPath(graph, N, E, S, W, N);
 assertFalse(graph.setConnectionData(N, E, LengthData.create(100))
  .isPresent());
 assertEquals(LengthData.create(100),
  graph.removeConnectionData(N, E).get());
}

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

/**
 * The fastest path changes based on the maximal allowed speed
 */
@Test
public void fastestPathConnData() {
 final Graph<MultiAttributeData> attributeGraph =
  new TableGraph<>();
 Point A, B, C, D;
 A = new Point(0, 0);
 B = new Point(0, 10);
 C = new Point(10, 10);
 D = new Point(10, 0);
 attributeGraph.addConnection(A, B,
  MultiAttributeData.builder().setMaxSpeed(2).build());
 attributeGraph.addConnection(B, C,
  MultiAttributeData.builder().setMaxSpeed(2).build());
 attributeGraph.addConnection(A, D,
  MultiAttributeData.builder().setMaxSpeed(1).build());
 attributeGraph.addConnection(D, C,
  MultiAttributeData.builder().setMaxSpeed(1).build());
 assertEquals(asList(A, B, C),
  Graphs.shortestPath(attributeGraph, A, C, GeomHeuristics.time(50d)));
 attributeGraph.setConnectionData(A, D,
  MultiAttributeData.builder().setMaxSpeed(10).build());
 attributeGraph.setConnectionData(D, C,
  MultiAttributeData.builder().setMaxSpeed(10).build());
 assertEquals(asList(A, D, C),
  Graphs.shortestPath(attributeGraph, A, C, GeomHeuristics.time(50d)));
}

相关文章