Created
November 16, 2011 22:43
-
-
Save okram/1371731 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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