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

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

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

Graph.getConnections介绍

暂无

代码示例

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

@Override
public Set<Connection<E>> getConnections() {
 return delegate.getConnections();
}

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

@Override
public Set<Connection<E>> getConnections() {
 return delegate.getConnections();
}

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

@Override
public Set<Connection<E>> getConnections() {
 return Collections.unmodifiableSet(delegate.getConnections());
}

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

@Override
public Set<Connection<E>> getConnections() {
 return Collections.unmodifiableSet(delegate.getConnections());
}

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

@Override
public Set<Connection<E>> getConnections() {
 return Collections.unmodifiableSet(delegate.getConnections());
}

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

@Override
public Set<Connection<E>> getConnections() {
 return Collections.unmodifiableSet(delegate.getConnections());
}

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

/**
 * Basic equals method.
 * @param g1 A graph.
 * @param other The object to compare for equality with g1.
 * @return <code>true</code> if the provided graphs are equal,
 *         <code>false</code> otherwise.
 */
public static boolean equal(Graph<?> g1, @Nullable Object other) {
 if (!(other instanceof Graph<?>)) {
  return false;
 }
 final Graph<?> g2 = (Graph<?>) other;
 return Objects.equal(g1.getConnections(), g2.getConnections());
}

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

/**
 * Basic equals method.
 * @param g1 A graph.
 * @param other The object to compare for equality with g1.
 * @return <code>true</code> if the provided graphs are equal,
 *         <code>false</code> otherwise.
 */
public static boolean equal(Graph<?> g1, @Nullable Object other) {
 if (!(other instanceof Graph<?>)) {
  return false;
 }
 final Graph<?> g2 = (Graph<?>) other;
 return Objects.equal(g1.getConnections(), g2.getConnections());
}

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

@Override
public void merge(Graph<E> other) {
 for (final Connection<E> connection : other.getConnections()) {
  addConnection(connection);
 }
}

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

@Override
public void merge(Graph<E> other) {
 for (final Connection<E> connection : other.getConnections()) {
  addConnection(connection);
 }
}

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

@Override
public void merge(Graph<E> other) {
 addConnections(other.getConnections());
}

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

@Override
public void merge(Graph<E> other) {
 addConnections(other.getConnections());
}

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

/**
 * Creates an immutable copy of the specified {@link Graph}. This method
 * recognizes when the supplied graph is an instance of {@link ImmutableGraph}
 * , and will avoid making a copy in this case.
 * @param graph A graph.
 * @param <E> The type of connection data.
 * @return An immutable copy of the graph.
 */
@SuppressWarnings("unchecked")
public static <E extends ConnectionData> ImmutableGraph<E> copyOf(
  Graph<? extends E> graph) {
 if (graph instanceof ImmutableGraph) {
  return (ImmutableGraph<E>) graph;
 }
 return new ImmutableGraph<>(graph.getConnections());
}

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

/**
 * Creates an immutable copy of the specified {@link Graph}. This method
 * recognizes when the supplied graph is an instance of {@link ImmutableGraph}
 * , and will avoid making a copy in this case.
 * @param graph A graph.
 * @param <E> The type of connection data.
 * @return An immutable copy of the graph.
 */
@SuppressWarnings("unchecked")
public static <E extends ConnectionData> ImmutableGraph<E> copyOf(
  Graph<? extends E> graph) {
 if (graph instanceof ImmutableGraph) {
  return (ImmutableGraph<E>) graph;
 }
 return new ImmutableGraph<>(graph.getConnections());
}

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

private Table<Point, Point, Connection<?>> filterConnections() {
 // filter connections to avoid double work for bidirectional roads
 final Table<Point, Point, Connection<?>> filteredConnections =
  HashBasedTable
   .create();
 for (final Connection<?> e : graph.getConnections()) {
  if (!filteredConnections.contains(e.to(), e.from())) {
   filteredConnections.put(e.from(), e.to(), e);
  }
 }
 return filteredConnections;
}

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

/**
 * Tests whether self cycles are indeed filtered out.
 * @throws IOException Should not happen.
 */
@SuppressWarnings("static-method")
@Test
public void testSelfCycleFilter() throws IOException {
 final StringReader sr = new StringReader(
  "n0[p=\"5,5\"]\nn1[p=\"4,4\"]\nn0 -> n0\nn0 -> n1");
 final Graph<?> g = DotGraphIO.getLengthGraphIO(Filters.selfCycleFilter())
  .read(sr);
 assertEquals(1, g.getConnections().size());
}

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

@Test
public void connectionOrder() {
 Point N, NE, E, SE, S, SW, W, NW;
 N = new Point(0, 5);
 NE = new Point(5, 5);
 E = new Point(5, 0);
 SE = new Point(5, -5);
 S = new Point(0, -5);
 SW = new Point(-5, -5);
 W = new Point(-5, 0);
 NW = new Point(-5, 5);
 Graphs.addPath(graph, N, NE, E, SE, S, SW, W, NW);
 final List<Point> points = Arrays.asList(N, NE, E, SE, S, SW, W, NW);
 final List<Connection<LengthData>> connections = newArrayList(graph
  .getConnections());
 for (int i = 1; i < points.size(); i++) {
  assertSame(connections.get(i - 1).from(), points.get(i - 1));
  assertSame(connections.get(i - 1).to(), points.get(i));
 }
}

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

@Test
public void removeNode() {
 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);
 final Graph<LengthData> unmod = Graphs.unmodifiableGraph(graph);
 assertEquals(graph, unmod);
 assertEquals(4, graph.getNodes().size());
 assertEquals(8, graph.getConnections().size());
 graph.removeNode(N);
 assertEquals(graph, unmod);
 assertEquals(3, graph.getNodes().size());
 assertEquals(4, graph.getConnections().size());
}

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

/**
 * Tests reading a dot file in legacy format.
 * @throws IOException In case of IO problems.
 */
@SuppressWarnings("static-method")
@Test
public void testLegacy() throws IOException {
 final Graph<LengthData> ldGraph = DotGraphIO.getLengthGraphIO().read(
  new StringReader(Joiner.on("\n").join(LEGACY_FORMAT)));
 final Graph<MultiAttributeData> maGraph =
  DotGraphIO.getMultiAttributeGraphIO()
   .read(new StringReader(Joiner.on("\n").join(LEGACY_FORMAT)));
 testLegacyFormat(ldGraph);
 testLegacyFormat(maGraph);
 final Point n0 = new Point(3296724.2131123254, 2.5725043247255992E7);
 final Point n19663 = new Point(3296782.7337179, 2.5724994399343655E7);
 for (final Connection<MultiAttributeData> conn : maGraph.getConnections()) {
  if (conn.from().equals(n0) && conn.to().equals(n19663)) {
   assertFalse(conn.data().get().getMaxSpeed().isPresent());
  } else {
   assertEquals(50000d, conn.data().get().getMaxSpeed().get()
    .doubleValue(),
    0);
  }
 }
}

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

@Test
public void unmodifiable() {
 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);
 final Graph<LengthData> g = Graphs.unmodifiableGraph(graph);
 g.hashCode();
 assertEquals(graph, g);
 assertEquals(g, graph);
 assertFalse(g.equals(new Object()));
 assertFalse(g.isEmpty());
 for (final Point p : g.getNodes()) {
  assertArrayEquals(graph.getIncomingConnections(p).toArray(), g
   .getIncomingConnections(p).toArray());
 }
 for (final Connection<LengthData> c : g.getConnections()) {
  assertEquals(graph.connectionLength(c.from(), c.to()),
   g.connectionLength(c.from(), c.to()), DELTA);
 }
}

相关文章