示例#1
0
 @Override
 public final Incidence getNextIncidenceAtVertex(Graph traversalContext, Direction direction) {
   Incidence i;
   try {
     i =
         localGraphDatabase.getIncidenceObject(
             storingGraphDatabase.getNextIncidenceIdAtVertexId(id));
   } catch (RemoteException e) {
     throw new RuntimeException(e);
   }
   if (traversalContext == null) {
     while (((i != null)
         && (direction != null)
         && (direction != Direction.BOTH)
         && (direction != i.getDirection()))) {
       i = i.getNextIncidenceAtVertex();
     }
   } else {
     if ((direction != null) && (direction != Direction.BOTH)) {
       while ((i != null)
           && ((!traversalContext.containsEdge(i.getEdge())) || (direction != i.getDirection()))) {
         i = i.getNextIncidenceAtVertex();
       }
     } else {
       while ((i != null) && (!traversalContext.containsEdge(i.getEdge()))) {
         i = i.getNextIncidenceAtVertex();
       }
     }
   }
   return i;
 }
示例#2
0
  @Override
  public Vertex getThat(Graph traversalContext) {
    Edge incidentEdge;
    try {
      incidentEdge =
          localGraphDatabase.getEdgeObject(storingGraphDatabase.getEdgeIdAtIncidenceId(id));
    } catch (RemoteException e) {
      throw new RuntimeException(e);
    }
    if (!incidentEdge.isBinary()) {
      throw new UnsupportedOperationException("This method is only supported by binary Edges.");
    }
    Vertex vertex = null;

    if (getDirection() == Direction.VERTEX_TO_EDGE) {
      vertex = ((BinaryEdge) incidentEdge).getOmega();
    } else {
      vertex = ((BinaryEdge) incidentEdge).getAlpha();
    }
    if (getGraph().getTraversalContext() == null
        || getGraph().getTraversalContext().containsVertex(vertex)) {
      return vertex;
    } else {
      return null;
    }
  }
示例#3
0
 @Override
 public Edge getEdge() {
   try {
     return localGraphDatabase.getEdgeObject(storingGraphDatabase.getEdgeIdAtIncidenceId(id));
   } catch (RemoteException e) {
     throw new RuntimeException(e);
   }
 }
示例#4
0
 @Override
 public void putBeforeAtEdge(Incidence i) {
   try {
     storingGraphDatabase.putIncidenceIdBeforeAtEdgeId(id, i.getGlobalId());
   } catch (RemoteException e) {
     throw new RuntimeException(e);
   }
 }
示例#5
0
 @Override
 public void putAfterAtVertex(Incidence i) {
   try {
     storingGraphDatabase.putIncidenceIdAfterAtVertexId(id, i.getGlobalId());
   } catch (RemoteException e) {
     throw new RuntimeException(e);
   }
 }
示例#6
0
 @Override
 public Incidence getPreviousIncidenceAtVertex(Graph traversalContext) {
   Incidence currentIncidence;
   try {
     currentIncidence =
         localGraphDatabase.getIncidenceObject(
             storingGraphDatabase.getPreviousIncidenceIdAtVertexId(
                 storingGraphDatabase.getVertexIdAtIncidenceId(id)));
   } catch (RemoteException e) {
     throw new RuntimeException(e);
   }
   while ((traversalContext != null)
       && (currentIncidence != null)
       && (!traversalContext.containsEdge(currentIncidence.getEdge()))) {
     currentIncidence = currentIncidence.getPreviousIncidenceAtVertex();
   }
   return currentIncidence;
 }
示例#7
0
 @Override
 public Iterable<Vertex> getThoseVertices(Graph traversalContext) {
   Edge edge;
   try {
     edge = localGraphDatabase.getEdgeObject(storingGraphDatabase.getEdgeIdAtIncidenceId(id));
   } catch (RemoteException e) {
     throw new RuntimeException(e);
   }
   assert getGraph().getTraversalContext() == null
       || getGraph().getTraversalContext().containsEdge(edge);
   return edge.getIncidentVertices(traversalContext, getDirection().getOppositeDirection());
 }
示例#8
0
 @Override
 public Vertex getThis(Graph traversalContext) {
   try {
     if (!localGraphDatabase
         .getEdgeObject(storingGraphDatabase.getEdgeIdAtIncidenceId(id))
         .isBinary()) {
       throw new UnsupportedOperationException("This method is only supported by binary Edges.");
     } else {
       Vertex vertex =
           localGraphDatabase.getVertexObject(storingGraphDatabase.getVertexIdAtIncidenceId(id));
       if (getGraph().getTraversalContext() == null
           || getGraph().getTraversalContext().containsVertex(vertex)) {
         return vertex;
       } else {
         return null;
       }
     }
   } catch (RemoteException e) {
     throw new RuntimeException(e);
   }
 }
示例#9
0
 @Override
 public Incidence getNextIncidenceAtEdge() {
   if (getGraph().getTraversalContext() == null) {
     try {
       return localGraphDatabase.getIncidenceObject(
           storingGraphDatabase.getNextIncidenceIdAtEdgeId(id));
     } catch (RemoteException e) {
       throw new RuntimeException(e);
     }
   } else {
     return getNextIncidenceAtEdge(getGraph().getTraversalContext());
   }
 }
示例#10
0
 @Override
 public Iterable<Edge> getThoseEdges(Graph traversalContext) {
   Vertex vertex;
   try {
     vertex =
         localGraphDatabase.getVertexObject(storingGraphDatabase.getVertexIdAtIncidenceId(id));
   } catch (RemoteException e) {
     throw new RuntimeException(e);
   }
   assert getGraph().getTraversalContext() == null
       || getGraph().getTraversalContext().containsVertex(vertex);
   return vertex.getIncidentEdges(traversalContext, getDirection().getOppositeDirection());
 }
示例#11
0
 @Override
 public final Incidence getNextIncidenceAtVertex(Direction direction) {
   if (getGraph().getTraversalContext() == null) {
     Incidence i;
     try {
       i =
           localGraphDatabase.getIncidenceObject(
               storingGraphDatabase.getNextIncidenceIdAtVertexId(id));
     } catch (RemoteException e) {
       throw new RuntimeException(e);
     }
     if ((direction != null) && (direction != Direction.BOTH)) {
       while ((i != null) && (direction != i.getDirection())) {
         i = i.getNextIncidenceAtVertex();
       }
     }
     return i;
   } else {
     return getNextIncidenceAtVertex(getGraph().getTraversalContext(), direction);
   }
 }