Java Code Examples for com.tinkerpop.blueprints.Graph#getEdges()

The following examples show how to use com.tinkerpop.blueprints.Graph#getEdges() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TinkerGraphUtil.java    From SciGraph with Apache License 2.0 5 votes vote down vote up
public void addGraph(Graph addition) {
  for (Vertex vertex : addition.getVertices()) {
    addElement(vertex);
  }
  for (Edge edge : addition.getEdges()) {
    addElement(edge);
  }
}
 
Example 2
Source File: GraphHelper.java    From org.openntf.domino with Apache License 2.0 5 votes vote down vote up
/**
 * Copy the vertex/edges of one graph over to another graph.
 * The id of the elements in the from graph are attempted to be used in the to graph.
 * This method only works for graphs where the user can control the element ids.
 *
 * @param from the graph to copy from
 * @param to   the graph to copy to
 */
public static void copyGraph(final Graph from, final Graph to) {
    for (final Vertex fromVertex : from.getVertices()) {
        final Vertex toVertex = to.addVertex(fromVertex.getId());
        ElementHelper.copyProperties(fromVertex, toVertex);
    }
    for (final Edge fromEdge : from.getEdges()) {
        final Vertex outVertex = to.getVertex(fromEdge.getVertex(Direction.OUT).getId());
        final Vertex inVertex = to.getVertex(fromEdge.getVertex(Direction.IN).getId());
        final Edge toEdge = to.addEdge(fromEdge.getId(), outVertex, inVertex, fromEdge.getLabel());
        ElementHelper.copyProperties(fromEdge, toEdge);
    }
}