org.apache.edgent.graph.Graph.getEdges()方法的使用及代码示例

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

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

Graph.getEdges介绍

[英]Return an unmodifiable view of all edges in this graph.
[中]返回此图中所有边的不可修改视图。

代码示例

代码示例来源:origin: apache/incubator-edgent

/**
 * Create an instance of {@link GraphType} using the specified 
 * {@link IdMapper} to generate unique object identifiers.
 * @param g the associated Graph
 * @param ids the id mapper
 */
public GraphType(Graph g, IdMapper<String> ids) {
  if (ids == null) {
    ids = new GraphType.Mapper();
  }
  ArrayList<VertexType<?,?>> vertices = 
      new ArrayList<VertexType<?,?>>();
  ArrayList<EdgeType> edges = new ArrayList<EdgeType>();
  
  for (Vertex<? extends Oplet<?,?>, ?, ?> v : g.getVertices()) {
    @SuppressWarnings({ "rawtypes", "unchecked" })
    VertexType<?,?> vertex = new VertexType(v, ids);
    vertices.add(vertex);
  }
  for (Edge e : g.getEdges()) {
    edges.add(new EdgeType(e, ids));
  }
  this.vertices = vertices;
  this.edges = edges;
}

代码示例来源:origin: org.apache.edgent/edgent-runtime-etiao

/**
 * Create an instance of {@link GraphType} using the specified 
 * {@link IdMapper} to generate unique object identifiers.
 * @param g the associated Graph
 * @param ids the id mapper
 */
public GraphType(Graph g, IdMapper<String> ids) {
  if (ids == null) {
    ids = new GraphType.Mapper();
  }
  ArrayList<VertexType<?,?>> vertices = 
      new ArrayList<VertexType<?,?>>();
  ArrayList<EdgeType> edges = new ArrayList<EdgeType>();
  
  for (Vertex<? extends Oplet<?,?>, ?, ?> v : g.getVertices()) {
    @SuppressWarnings({ "rawtypes", "unchecked" })
    VertexType<?,?> vertex = new VertexType(v, ids);
    vertices.add(vertex);
  }
  for (Edge e : g.getEdges()) {
    edges.add(new EdgeType(e, ids));
  }
  this.vertices = vertices;
  this.edges = edges;
}

代码示例来源:origin: apache/incubator-edgent

private void _testFanoutWithPeek(boolean after) throws Exception {
  Topology t = newTopology();
  Graph g = t.graph();
  /*                            -- Filter -- Sink(.)
   *                           / 
   * Source -- Peek -- FanOut ---- Modify -- Sink(@)
   * 
   */
  TStream<Integer> d = integers(t, 1, 2, 3);
  List<Integer> peekedValues = new ArrayList<>();
  
  if (!after)
    d.peek(tuple -> peekedValues.add(tuple));
  TStream<Integer> df = d.filter(tuple -> tuple.intValue() > 0);
  TStream<Integer> dm = d.modify(tuple -> new Integer(tuple.intValue() + 1));
  if (after)
    d.peek(tuple -> peekedValues.add(tuple));
  df.sink(tuple -> System.out.print("."));
  dm.sink(tuple -> System.out.print("@"));
  
  assertEquals(7, g.getVertices().size());
  assertEquals(6, g.getEdges().size());
  // Insert counter metrics into all the streams 
  Metrics.counter(t);
  printGraph(g);
  assertEquals(10, g.getVertices().size());
  assertEquals(9, g.getEdges().size());
}

代码示例来源:origin: apache/incubator-edgent

/**
 * Test Peek. This will only work with an embedded setup.
 * 
 * @throws Exception on failure
 */
@Test
public void metricsEverywherePeek() throws Exception {
  Topology t = newTopology();
  Graph g = t.graph();
  TStream<String> s = t.strings("a", "b", "c");
  List<String> peekedValues = new ArrayList<>();
  TStream<String> speek = s.peek(tuple -> peekedValues.add(tuple));
  speek.sink(tuple -> System.out.print("."));
  Collection<Vertex<? extends Oplet<?, ?>, ?, ?>> vertices = g.getVertices();
  assertEquals(3, vertices.size());
  Collection<Edge> edges = g.getEdges();
  assertEquals(2, edges.size());
  Metrics.counter(t);
  printGraph(g);
  // One single counter inserted after the peek 
  vertices = g.getVertices();
  assertEquals(4, vertices.size());
  edges = g.getEdges();
  assertEquals(3, edges.size());
}

代码示例来源:origin: apache/incubator-edgent

@Test
public void metricsEverywhereMultiplePeek() throws Exception {
  Topology t = newTopology();
  Graph g = t.graph();
  TStream<String> s = t.strings("a", "b", "c");
  List<String> peekedValues = new ArrayList<>();
  TStream<String> speek = s.peek(tuple -> peekedValues.add(tuple + "1st"));
  TStream<String> speek2 = speek.peek(tuple -> peekedValues.add(tuple + "2nd"));
  TStream<String> speek3 = speek2.peek(tuple -> peekedValues.add(tuple + "3rd"));
  speek3.sink(tuple -> System.out.print("."));
  Collection<Vertex<? extends Oplet<?, ?>, ?, ?>> vertices = g.getVertices();
  assertEquals(5, vertices.size());
  Collection<Edge> edges = g.getEdges();
  assertEquals(4, edges.size());
  Metrics.counter(t);
  printGraph(g);
  // One single counter inserted after the 3rd peek 
  vertices = g.getVertices();
  assertEquals(6, vertices.size());
  edges = g.getEdges();
  assertEquals(5, edges.size());
}

代码示例来源:origin: apache/incubator-edgent

@Test
public void metricsEverywhereSimple() throws Exception {
  
  Topology t = newTopology();
  Graph g = t.graph();
  // Source
  TStream<Integer> d = integers(t, 1, 2, 3);
  d.sink(tuple -> System.out.print("."));
  
  // Insert counter metrics into all the topology streams 
  Metrics.counter(t);
  printGraph(g);
  
  Collection<Vertex<? extends Oplet<?, ?>, ?, ?>> vertices = g.getVertices();
  assertEquals(3, vertices.size());
  
  Collection<Edge> edges = g.getEdges();
  assertEquals(2, edges.size());
}

代码示例来源:origin: apache/incubator-edgent

@Test
public void metricsEverywhereFanOut() {
  
  Topology t = newTopology();
  Graph g = t.graph();
  /*                   -- OP_3 (Sink)
   *                  / 
   * OP_0 -- FanOut ----- OP_4 (Sink)
   */
  TStream<Integer> d = integers(t, 1, 2, 3);
  d.sink(tuple -> System.out.print("."));
  d.sink(tuple -> System.out.print("@"));
  
  // Insert counter metrics into all the topology streams 
  Metrics.counter(t);
  printGraph(g);
  
  Collection<Vertex<? extends Oplet<?, ?>, ?, ?>> vertices = g.getVertices();
  assertEquals(5, vertices.size());
  
  Collection<Edge> edges = g.getEdges();
  assertEquals(4, edges.size());
}

代码示例来源:origin: apache/incubator-edgent

assertEquals(10, vertices.size());
Collection<Edge> edges = g.getEdges();
assertEquals(9, edges.size());

代码示例来源:origin: apache/incubator-edgent

assertTrue(getGraph().getEdges().isEmpty());
assertSame(v2, c.toArray()[1]);
assertTrue(getGraph().getEdges().isEmpty());
Collection<Edge> edges = getGraph().getEdges();
assertFalse(edges.isEmpty());
assertEquals(1, edges.size());

相关文章