Skip to content

Instantly share code, notes, and snippets.

@okram
Created November 16, 2011 22:43
Show Gist options
  • Select an option

  • Save okram/1371731 to your computer and use it in GitHub Desktop.

Select an option

Save okram/1371731 to your computer and use it in GitHub Desktop.
package com.cisco.hmp.graph.gui;
import com.tinkerpop.blueprints.pgm.Edge;
import com.tinkerpop.blueprints.pgm.Graph;
import com.tinkerpop.blueprints.pgm.Vertex;
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
/**
* @author Marko A. Rodriguez (http://markorodriguez.com)
*/
public class GuiHelper {
private final Graph graph;
public GuiHelper(final Graph graph) {
this.graph = graph;
}
public ResultBundle getAdjacencies(final long id, final Collection<String> properties) {
Vertex vertex = this.graph.getVertex(id);
if (null == vertex) {
return null;
}
ResultBundle bundle = new ResultBundle();
for (String property : properties) {
bundle.properties.put(property, vertex.getProperty(property));
}
bundle.outgoing = vertex.getOutEdges();
bundle.incoming = vertex.getInEdges();
return bundle;
}
public class ResultBundle {
public Map<String, Object> properties = new HashMap<String, Object>();
public Iterable<Edge> outgoing;
public Iterable<Edge> incoming;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment