Package classycle.graph
Class Vertex
- java.lang.Object
-
- classycle.graph.Vertex
-
- All Implemented Interfaces:
java.lang.Comparable<Vertex>
- Direct Known Subclasses:
AtomicVertex,StrongComponent
public class Vertex extends java.lang.Object implements java.lang.Comparable<Vertex>
The base class for any type of vertex in a directed graph.A Vertex holds an
Attributesobject which encapsulates all properties of the vertex which are not necessary to know for parsing a graph in aGraphProcessor. 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 Summary
Constructors Constructor Description Vertex(Attributes attributes)Create a new instance for the specified attributes.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddIncomingArcTo(Vertex tailVertex)Adds an incoming arc to the specified vertex.voidaddOutgoingArcTo(Vertex headVertex)Adds an outgoing arc to the specified vertex.intcompareTo(Vertex object)AttributesgetAttributes()Returns the attributes.VertexgetHeadVertex(int index)Returns the head vertex of the specified outgoing arc.intgetNumberOfIncomingArcs()Returns the number of incoming arcs.intgetNumberOfOutgoingArcs()Returns the number of outgoing arcs.VertexgetTailVertex(int index)Returns the tail vertex of the specified outgoing arc.booleanisVisited()Returns the visited flag.voidreset()Reset this vertex.java.lang.StringtoString()Returns toString() of the attributes and the number of incoming and outgoing arcs.voidvisit()Marks this instance as visited.
-
-
-
Constructor Detail
-
Vertex
public Vertex(Attributes attributes)
Create a new instance for the specified attributes.
-
-
Method Detail
-
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 callsaddIncomingArcTo(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 callsaddOutgoingArcTo(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 java.lang.String toString()
Returns toString() of the attributes and the number of incoming and outgoing arcs.- Overrides:
toStringin classjava.lang.Object
-
-