private void verifyLineageGraph(
      String feedType,
      List<String> expectedFeeds,
      List<String> secureFeeds,
      List<String> ownedAndSecureFeeds) {
    // feeds owned by a user
    List<String> feedNamesOwnedByUser = getFeedsOwnedByAUser(feedType);
    Assert.assertTrue(feedNamesOwnedByUser.containsAll(expectedFeeds));

    Graph graph = service.getGraph();

    Iterator<Vertex> vertices =
        graph.getVertices("name", "impression-feed/2014-01-01T00:00Z").iterator();
    Assert.assertTrue(vertices.hasNext());
    Vertex feedInstanceVertex = vertices.next();
    Assert.assertEquals(
        feedInstanceVertex.getProperty(RelationshipProperty.TYPE.getName()),
        RelationshipType.FEED_INSTANCE.getName());

    Object vertexId = feedInstanceVertex.getId();
    Vertex vertexById = graph.getVertex(vertexId);
    Assert.assertEquals(vertexById, feedInstanceVertex);

    // feeds classified as secure
    verifyFeedsClassifiedAsSecure(feedType, secureFeeds);

    // feeds owned by a user and classified as secure
    verifyFeedsOwnedByUserAndClassification(feedType, "Financial", ownedAndSecureFeeds);
  }
Exemplo n.º 2
0
 private void populateLists(List<Vertex> verticies, List<Edge> edges) {
   for (Vertex v : graph.getVertices()) {
     verticies.add(v);
   }
   for (Edge e : graph.getEdges()) {
     edges.add(e);
   }
 }
  public long getVerticesCount(final Graph graph) {
    long count = 0;
    for (Vertex ignored : graph.getVertices()) {
      count++;
    }

    return count;
  }
Exemplo n.º 4
0
 static void addGraph(Graph graph, Graph addition) {
   for (Vertex vertex : addition.getVertices()) {
     addElement(graph, vertex);
   }
   for (Edge edge : addition.getEdges()) {
     addElement(graph, edge);
   }
 }
  public static void debug(final Graph graph) {
    System.out.println("*****Vertices of " + graph);
    for (Vertex vertex : graph.getVertices()) {
      System.out.println(GraphUtils.vertexString(vertex));
    }

    System.out.println("*****Edges of " + graph);
    for (Edge edge : graph.getEdges()) {
      System.out.println(GraphUtils.edgeString(edge));
    }
  }
  private void cleanupGraphStore(Graph graph) {
    for (Edge edge : graph.getEdges()) {
      graph.removeEdge(edge);
    }

    for (Vertex vertex : graph.getVertices()) {
      graph.removeVertex(vertex);
    }

    graph.shutdown();
  }
Exemplo n.º 7
0
 public static void project(Graph graph, Collection<String> projection) {
   if (projection.contains("*")) {
     return;
   }
   for (Vertex vertex : graph.getVertices()) {
     for (String key : vertex.getPropertyKeys()) {
       if (!projection.contains(key) && !PROTECTED_PROPERTY_KEYS.contains(key)) {
         vertex.removeProperty(key);
       }
     }
   }
 }
Exemplo n.º 8
0
  public static void dumpToLog(final Graph graph) {
    LOG.debug("*******************Graph Dump****************************");
    LOG.debug("Vertices of {}", graph);
    for (Vertex vertex : graph.getVertices()) {
      LOG.debug(vertexString(vertex));
    }

    LOG.debug("Edges of {}", graph);
    for (Edge edge : graph.getEdges()) {
      LOG.debug(edgeString(edge));
    }
    LOG.debug("*******************Graph Dump****************************");
  }
Exemplo n.º 9
0
 /**
  * Generates a synthetic network for all vertices in the given graph such that the provided
  * expected number of communities are generated with the specified expected number of edges.
  *
  * @param graph
  * @param expectedNumCommunities
  * @param expectedNumEdges
  * @return The actual number of edges generated. May be different from the expected number.
  */
 public int generate(Graph graph, int expectedNumCommunities, int expectedNumEdges) {
   return generate(graph, graph.getVertices(), expectedNumCommunities, expectedNumEdges);
 }
 @Override
 public Iterable<Vertex> vertices() {
   return graph.getVertices();
 }