com.tinkerpop.blueprints.Graph.getEdges()方法的使用及代码示例

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

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

Graph.getEdges介绍

[英]Return an iterable to all the edges in the graph. If this is not possible for the implementation, then an UnsupportedOperationException can be thrown.
[中]将iterable返回到图形中的所有边。如果这对于实现是不可能的,那么可以抛出UnsupportedOperationException。

代码示例

代码示例来源:origin: com.tinkerpop.blueprints/blueprints-graph-jung

public int getEdgeCount() {
  int count = 0;
  for (final Edge edge : this.graph.getEdges()) {
    count++;
  }
  return count;
}

代码示例来源:origin: com.tinkerpop.blueprints/blueprints-core

@Override
public Iterable<Edge> getEdges() {
  return graph.getEdges();
}

代码示例来源:origin: com.tinkerpop.blueprints/blueprints-core

@Override
public Iterable<Edge> getEdges(final String key, final Object value) {
  return graph.getEdges(key, value);
}

代码示例来源:origin: com.tinkerpop.blueprints/blueprints-graph-jung

public Collection<Edge> getEdges() {
  final Iterable<Edge> itty = this.graph.getEdges();
  if (itty instanceof Collection) {
    return (Collection<Edge>) itty;
  } else {
    final List<Edge> edges = new ArrayList<Edge>();
    for (final Edge e : itty) {
      edges.add(e);
    }
    return edges;
  }
}

代码示例来源:origin: com.tinkerpop.blueprints/blueprints-core

private void populateLists(final List<Vertex> vertices, final List<Edge> edges) {
  for (Vertex v : graph.getVertices()) {
    vertices.add(v);
  }
  for (Edge e : graph.getEdges()) {
    edges.add(e);
  }
}

代码示例来源:origin: org.jboss.windup/windup-grapher

private void writeGraphEdges(OutputStream os) throws IOException {
  IOUtils.write(GexfConstants.EDGES_OPEN, os);
  
  
  
  for(Edge edge : graph.getEdges()) {
    String id = ""+edge.getId().hashCode();
    String source = ""+edge.getVertex(Direction.IN).getId().hashCode();
    String target = ""+edge.getVertex(Direction.OUT).getId().hashCode();
    writeGraphEdge(id, source, target, os);
  }
  
  IOUtils.write(GexfConstants.EDGES_CLOSE, os);
}

代码示例来源:origin: org.jboss.windup.legacy.application/grapher

private void writeGraphEdges(OutputStream os) throws IOException {
  IOUtils.write(GexfConstants.EDGES_OPEN, os);
  
  
  
  for(Edge edge : graph.getEdges()) {
    String id = ""+edge.getId().hashCode();
    String source = ""+edge.getVertex(Direction.IN).getId().hashCode();
    String target = ""+edge.getVertex(Direction.OUT).getId().hashCode();
    writeGraphEdge(id, source, target, os);
  }
  
  IOUtils.write(GexfConstants.EDGES_CLOSE, os);
}

代码示例来源:origin: org.jboss.windup.legacy.application/grapher

private void writeGraphEdges(OutputStream os) throws IOException {
  
  for(Edge edge : graph.getEdges()) {
    String id = ""+edge.getId().hashCode();
    String source = ""+edge.getVertex(Direction.IN).getId().hashCode();
    String target = ""+edge.getVertex(Direction.OUT).getId().hashCode();
    String label = ""+edge.getLabel();
    writeGraphEdge(id, source, target, label, os);
  }
  
}

代码示例来源:origin: org.jboss.windup.legacy.application/grapher

private void writeGraphEdges(OutputStream os) throws IOException {
  for(Edge edge : graph.getEdges()) {
    String label = edge.getLabel();
    String source = ""+edge.getVertex(Direction.IN).getId().hashCode();
    String target = ""+edge.getVertex(Direction.OUT).getId().hashCode();
    writeGraphEdge(label, source, target, os);
  }
}

代码示例来源:origin: org.jboss.windup/windup-grapher

private void writeGraphEdges(OutputStream os) throws IOException {
  for(Edge edge : graph.getEdges()) {
    String label = edge.getLabel();
    String source = ""+edge.getVertex(Direction.IN).getId().hashCode();
    String target = ""+edge.getVertex(Direction.OUT).getId().hashCode();
    writeGraphEdge(label, source, target, os);
  }
}

代码示例来源:origin: SciGraph/SciGraph

@Test
public void edges_queryIsEntailed() {
 Graph graph = graphApi.getEdges(OwlRelationships.RDFS_SUBCLASS_OF, true, 0L, 1L);
 assertThat(size(graph.getVertices()), is(2));
 assertThat(size(graph.getEdges()), is(1));
}

代码示例来源:origin: SciGraph/SciGraph

@Test
@Ignore // Not sorting works in production but not in test
public void edges_areSkipped() {
 Graph graph = graphApi.getEdges(OwlRelationships.RDFS_SUBCLASS_OF, false, Long.MAX_VALUE, 1L);
 assertThat(size(graph.getVertices()), is(0));
 assertThat(size(graph.getEdges()), is(0));
}

代码示例来源:origin: SciGraph/SciGraph

@Test
public void getReachableNodes_filtersCorrectly() {
 Graph graph = graphApi.getReachableNodes(c, Lists.newArrayList("*"), Sets.newHashSet("alabel"));
 assertThat(size(graph.getVertices()), is(1));
 assertThat(size(graph.getEdges()), is(0));
}

代码示例来源:origin: SciGraph/SciGraph

@Test
public void getReachableNodes_traverseAllRels() {
 Graph graph = graphApi.getReachableNodes(c, Lists.newArrayList(), Sets.newHashSet());
 assertThat(size(graph.getVertices()), is(1));
 assertThat(size(graph.getEdges()), is(0));
}

代码示例来源:origin: SciGraph/SciGraph

@Test
public void testPredicate() {
 Predicate<Node> testPredicate = new Predicate<Node>() {
  @Override
  public boolean apply(Node node) {
   return (node != c);
  }};
  Graph graph = graphApi.getNeighbors(newHashSet(b), 1, Collections.<DirectedRelationshipType>emptySet(), Optional.of(testPredicate));
  assertThat(graph.getVertices(), IsIterableWithSize.<Vertex>iterableWithSize(4));
  assertThat(graph.getEdges(), IsIterableWithSize.<Edge>iterableWithSize(3));
}

代码示例来源:origin: SciGraph/SciGraph

@Test
public void evidenceIsAdded() {
 assertThat(graph.getVertices(), IsIterableWithSize.<Vertex>iterableWithSize(5));
 assertThat(graph.getEdges(), IsIterableWithSize.<Edge>iterableWithSize(1));
 aspect.invoke(graph);
 assertThat(graph.getVertices(), IsIterableWithSize.<Vertex>iterableWithSize(6));
 assertThat(graph.getEdges(), IsIterableWithSize.<Edge>iterableWithSize(3));
}

代码示例来源:origin: SciGraph/SciGraph

@Test
public void getReachableNodes_nothingReturnedForFakeLabel() {
 Graph graph = graphApi.getReachableNodes(c,
   Lists.newArrayList(OwlRelationships.OWL_EQUIVALENT_CLASS.name(),
     OwlRelationships.RDFS_SUBCLASS_OF.name()),
   Sets.newHashSet("fakeLabel"));
 assertThat(size(graph.getVertices()), is(0));
 assertThat(size(graph.getEdges()), is(0));
}

代码示例来源:origin: SciGraph/SciGraph

@Test
public void testTypedNeighborhood() {
 Graph graph = graphApi.getNeighbors(newHashSet(b), 2, newHashSet(new DirectedRelationshipType(OwlRelationships.RDFS_SUBCLASS_OF, Direction.INCOMING)), absent);
 assertThat(graph.getVertices(), IsIterableWithSize.<Vertex>iterableWithSize(3));
 assertThat(graph.getEdges(), IsIterableWithSize.<Edge>iterableWithSize(2));
}

代码示例来源:origin: SciGraph/SciGraph

public static void dumpGraph(com.tinkerpop.blueprints.Graph graphDb) {
 for (Vertex node: graphDb.getVertices()) {
  dumpNode(node);
 }
 for (Edge relationship: graphDb.getEdges()) {
  dumpRelationship(relationship);
 }
}

代码示例来源:origin: SciGraph/SciGraph

@Test
public void testMultiTypedNeighborhood() {
 Graph graph = graphApi.getNeighbors(newHashSet(b), 1, 
   newHashSet(new DirectedRelationshipType(OwlRelationships.RDFS_SUBCLASS_OF, Direction.INCOMING),
     new DirectedRelationshipType(fizz, Direction.INCOMING)), absent);
 assertThat(graph.getVertices(), IsIterableWithSize.<Vertex>iterableWithSize(3));
 assertThat(graph.getEdges(), IsIterableWithSize.<Edge>iterableWithSize(2));
}

相关文章