InfiniteGraph: getNeighbors or getEdges?

InfiniteGraph: getNeighbors or getEdges?

Contributed by Asher Moody, Development Support Engineer When writing an application using IG you will likely run into a situation where you want to see who or what is connected to a particular vertex. For example, you could have a social network and want to see who a person’s friends are. When looking at the Vertex API you will see a few options: List<EdgeHandle> findEdgesToNeighbor(long neighborId) Retrieves a list of all edges that connect this vertex to a vertex with the given id. Iterable<EdgeHandle> getEdges() Retrieves an iterator for all edges connected to this vertex. Iterable<EdgeHandle> getEdges(Qualifier edgeQualifier) Retrieves an iterator for all edges connected to this vertex that satisfy the provided Qualifier. Iterable<Hop> getNeighborHops() Retrieves an iterator for all neighboring hops (edge-vertex pairs). Iterable<Hop> getNeighborHops(Qualifier qualifier) Retrieves an iterator for all neighboring hops (edge-vertex pairs) that satisfy the supplied Qualifier. Iterable<VertexHandle> getNeighbors() Retrieves an iterator for all neighboring (or adjacent) vertices. Iterable<VertexHandle> getNeighbors(Qualifier qualifier) Retrieves an iterator for all neighboring (or adjacent) vertices that satisfy the provided qualifier. boolean isNeighbor(long neighborId) Indicates whether a vertex with the given id is a neighbor of (or adjacent to) this vertex. The easiest choice would be to call getNeighbors to retrieve an iterator of the person’s neighbors. But what if they are also connected to groups, books, places, employers, schools, music, and movies? You aren’t interested in all that other stuff if you are just looking for their friends. You could pass in a Qualifier when you call getNeighbors to only search for neighbors of class Friend. It turns out that this might not always be the best solution. It all comes down to vertices and edges. Everything in IG is...