Package uk.gov.gchq.gaffer.data.graph
Class Walk
- java.lang.Object
-
- uk.gov.gchq.gaffer.data.graph.Walk
-
public class Walk extends Object implements Iterable<Set<Edge>>
AWalk
describes a graph traversal which begins at a vertex and comprises of:- a sequence of
Edge
objects, where the source of one edge must follow on from the destination of the previous - an
optional sequence of
Entity
objects which are associated to each of the vertices visited on the Walk. Vertices with no associated entities are still represented, but only as empty collections.
For example, a Walk through a simple graph could look like:
A --> B --> C \ \ \ (Entity2, Entity3) \ (Entity1) Edges: A -> B, B -> C Entities: [], [Entity1], [Entity2, Entity3]
- a sequence of
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
Walk.Builder
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(Object obj)
Object
getDestinationVertex()
List<Set<Edge>>
getEdges()
List<Set<Entity>>
getEntities()
List<Map.Entry<Object,Set<Entity>>>
getEntitiesAsEntries()
Set<Entity>
getEntitiesAtDistance(int n)
Get all of the entities at some distance from the start of the walk.Set<Entity>
getEntitiesForVertex(Object vertex)
Retrieve all of the entities associated with a particular vertex on the walk.Object
getSourceVertex()
Set<Object>
getVertexSet()
Get theSet
of vertices on the walk.List<Object>
getVerticesOrdered()
Get an orderedList
of the vertices on the walk.int
hashCode()
boolean
isPath()
A walk is also a path if it contains no repeated vertices (i.e.boolean
isTrail()
A walk is also a trail if it contains no repeated edges.Iterator<Set<Edge>>
iterator()
int
length()
String
toString()
-
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
-
-
-
Method Detail
-
getEntitiesForVertex
public Set<Entity> getEntitiesForVertex(Object vertex)
Retrieve all of the entities associated with a particular vertex on the walk.- Parameters:
vertex
- the vertex of interest- Returns:
- a
Set
of all of the entities associated with the vertex
-
getEntitiesAtDistance
public Set<Entity> getEntitiesAtDistance(int n)
Get all of the entities at some distance from the start of the walk.- Parameters:
n
- the distance from the start of the walk (in terms of the number of edges that would have to be traversed)- Returns:
- the entities at the specified distance
-
getVerticesOrdered
public List<Object> getVerticesOrdered()
Get an orderedList
of the vertices on the walk.This will include any repeated vertices.
- Returns:
- a list of the vertices on the walk
-
getVertexSet
public Set<Object> getVertexSet()
Get theSet
of vertices on the walk.- Returns:
- a set of the vertices on the walk.
-
length
public int length()
-
isTrail
public boolean isTrail()
A walk is also a trail if it contains no repeated edges.- Returns:
true
if the walk does not contain any repeated edges, otherwisefalse
-
isPath
public boolean isPath()
A walk is also a path if it contains no repeated vertices (i.e. does not contain any loops).- Returns:
true
if the walk does not contain any repeated vertices, otherwisefalse
-
getSourceVertex
public Object getSourceVertex()
-
getDestinationVertex
public Object getDestinationVertex()
-
-