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 getEdgesCount(final Graph graph) { long count = 0; for (Edge ignored : graph.getEdges()) { count++; } return count; }
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(); }
@Override protected void onExecute() throws Exception { Graph g = getGraph(); Iterable<Edge> itr = g.getEdges(key, value); int count = 0; for (@SuppressWarnings("unused") Edge e : itr) count++; GraphUtils.close(itr); setResult(count); }
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****************************"); }
@Override public void outputGraph(Graph graph, OutputStream out) throws IOException { Iterable<Edge> iterable = graph.getEdges(); Iterator<Edge> it = iterable.iterator(); writeCSVField("SourceId", out, true, false); writeCSVField("SourceVirtual", out, false, false); writeCSVField("SourceFileType", out, false, false); writeCSVField("SourceName", out, false, false); writeCSVField("SourceAuthor", out, false, false); writeCSVField("SourceModified", out, false, false); writeCSVField("LinkType", out, false, false); writeCSVField("DestinationId", out, false, false); writeCSVField("DestinationVirtual", out, false, false); writeCSVField("DestinationFileType", out, false, false); writeCSVField("DestinationName", out, false, false); writeCSVField("DestinationAuthor", out, false, false); writeCSVField("DestinationModified", out, false, true); while (it.hasNext()) { Edge edge = it.next(); Vertex fromV = edge.getVertex(Direction.OUT); Vertex toV = edge.getVertex(Direction.IN); writeCSVField(fromV.getId(), out, true, false); writeCSVField(fromV.getProperty(DictionaryConst.NODE_VIRTUAL), out, false, false); writeCSVField(fromV.getProperty(DictionaryConst.PROPERTY_TYPE), out, false, false); writeCSVField(fromV.getProperty(DictionaryConst.PROPERTY_NAME), out, false, false); writeCSVField(fromV.getProperty(DictionaryConst.PROPERTY_AUTHOR), out, false, false); writeCSVField(fromV.getProperty(DictionaryConst.PROPERTY_LAST_MODIFIED), out, false, false); writeCSVField(edge.getLabel(), out, false, false); writeCSVField(toV.getId(), out, false, false); writeCSVField(toV.getProperty(DictionaryConst.NODE_VIRTUAL), out, false, false); writeCSVField(toV.getProperty(DictionaryConst.PROPERTY_TYPE), out, false, false); writeCSVField(toV.getProperty(DictionaryConst.PROPERTY_NAME), out, false, false); writeCSVField(toV.getProperty(DictionaryConst.PROPERTY_AUTHOR), out, false, false); writeCSVField(toV.getProperty(DictionaryConst.PROPERTY_LAST_MODIFIED), out, false, true); } }
@Override public Iterable<GraphEdge<Vertex, Edge>> edges() { return convertEdges(graph.getEdges()); }