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>>
AWalkdescribes a graph traversal which begins at a vertex and comprises of:- a sequence of
Edgeobjects, where the source of one edge must follow on from the destination of the previous - an
optional sequence of
Entityobjects 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 classWalk.Builder
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(Object obj)ObjectgetDestinationVertex()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.ObjectgetSourceVertex()Set<Object>getVertexSet()Get theSetof vertices on the walk.List<Object>getVerticesOrdered()Get an orderedListof the vertices on the walk.inthashCode()booleanisPath()A walk is also a path if it contains no repeated vertices (i.e.booleanisTrail()A walk is also a trail if it contains no repeated edges.Iterator<Set<Edge>>iterator()intlength()StringtoString()-
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
Setof 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 orderedListof 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 theSetof 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:
trueif 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:
trueif the walk does not contain any repeated vertices, otherwisefalse
-
getSourceVertex
public Object getSourceVertex()
-
getDestinationVertex
public Object getDestinationVertex()
-
-