Class Vertex

java.lang.Object
classycle.graph.Vertex
All Implemented Interfaces:
Comparable<Vertex>
Direct Known Subclasses:
AtomicVertex, StrongComponent

public class Vertex extends Object implements Comparable<Vertex>
The base class for any type of vertex in a directed graph.

A Vertex holds an Attributes object which encapsulates all properties of the vertex which are not necessary to know for parsing a graph in a GraphProcessor. Only the visited flag will be manipulated during parsing.

A Vertex knows the head and tail vertices of all its outgoing and incoming arcs. When a head vertex is added by the method addOutgoingArcTo(classycle.graph.Vertex) also the corresponding incoming arc is built in the head vertex. The same is true the other way around. Note, that multi-arcs are not possible. That is, adding an already added head/tail vertex again as a head/tail vertex will be ignored.

Author:
Franz-Josef Elmer
  • Constructor Details

    • Vertex

      public Vertex(Attributes attributes)
      Create a new instance for the specified attributes.
  • Method Details

    • getAttributes

      public Attributes getAttributes()
      Returns the attributes.
    • getNumberOfOutgoingArcs

      public int getNumberOfOutgoingArcs()
      Returns the number of outgoing arcs. This is equivalent to the number of head vertices.
    • getHeadVertex

      public Vertex getHeadVertex(int index)
      Returns the head vertex of the specified outgoing arc.
    • addOutgoingArcTo

      public void addOutgoingArcTo(Vertex headVertex)
      Adds an outgoing arc to the specified vertex. Also calls addIncomingArcTo(classycle.graph.Vertex) for headVertex with this as the argument. Does nothing if headVertex is the head vertex of an already existing outgoing arc.
      Parameters:
      headVertex - Head vertex to be added to establish a new outgoing arc. Null is not allowed.
    • getNumberOfIncomingArcs

      public int getNumberOfIncomingArcs()
      Returns the number of incoming arcs. This is equivalent to the number of tail vertices.
    • getTailVertex

      public Vertex getTailVertex(int index)
      Returns the tail vertex of the specified outgoing arc.
    • addIncomingArcTo

      public void addIncomingArcTo(Vertex tailVertex)
      Adds an incoming arc to the specified vertex. Also calls addOutgoingArcTo(classycle.graph.Vertex) for tailVertex with this as the argument. Does nothing if tailVertex is the tail vertex of an already existing incoming arc.
      Parameters:
      tailVertex - Tail vertex to be added to establish a new incoming arc. Null is not allowed.
    • reset

      public void reset()
      Reset this vertex. That is, the visited flag is set to false.
    • visit

      public void visit()
      Marks this instance as visited. That is, the visited flag becomes true.
    • isVisited

      public boolean isVisited()
      Returns the visited flag.
    • toString

      public String toString()
      Returns toString() of the attributes and the number of incoming and outgoing arcs.
      Overrides:
      toString in class Object
    • compareTo

      public int compareTo(Vertex object)
      Specified by:
      compareTo in interface Comparable<Vertex>