Class Walk

  • All Implemented Interfaces:
    Iterable<Set<Edge>>

    public class Walk
    extends Object
    implements Iterable<Set<Edge>>
    A Walk 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]
     
     
    • Constructor Detail

      • Walk

        public Walk​(List<Set<Edge>> edges,
                    List<Map.Entry<Object,​Set<Entity>>> entities)
        Constructor used by Jackson.
        Parameters:
        edges - the edges to add to the walk
        entities - the entities to add to the walk
    • 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 ordered List 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 the Set 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, otherwise false
      • 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, otherwise false
      • getSourceVertex

        public Object getSourceVertex()
      • getDestinationVertex

        public Object getDestinationVertex()
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object