public class Vertex extends java.lang.Object implements Serializable
Graph
.
Graph.getVertexByID(int)
to get the vertex of a specific id.
getIncomingEdgeCount()
and getIncomingEdge(int)
. Use
getOutgoingEdgeCount()
and getOutgoingEdge(int)
to find out which edges are outgoing ones.
Vertex
keep in mind that you should override serialize(Serializer)
and deserialize(Serializer)
so that the additional data of the new type can be stored in a graph file.Graph
,
Serializable
Constructor and Description |
---|
Vertex(java.lang.String caption)
Creates a new vertex.
|
Modifier and Type | Method and Description |
---|---|
void |
deserialize(Serializer s)
Deserializes (loads) the object data from the given serializer.
|
boolean |
equals(java.lang.Object o)
Indicates whether the given object equals this vertex.
|
boolean |
equals(Vertex v)
Indicates whether the given vertex equals this vertex.
|
java.lang.String |
getCaption()
Gets the caption of the vertex.
|
int |
getDegree()
Gets the degree of the vertex.
|
protected Graph<? extends Vertex,? extends Edge> |
getGraph()
Gets the associated graph of the vertex.
|
int |
getID()
Gets a unique identifier of this vertex based on the associated graph.
|
Edge |
getIncidentEdge(int index)
Gets an incident edge at the given index.
|
int |
getIncidentEdgeCount()
Gets the number of incident edges.
|
Edge |
getIncomingEdge(int index)
Gets an incoming edge at the given index.
|
int |
getIncomingEdgeCount()
Gets the number of incoming edges.
|
int |
getIndegree()
Gets the indegree of the vertex which is defined as: deg-(v) = number of incoming edges of v.
|
int |
getIndex()
Gets the current index of the vertex in the list of vertices of the associated graph meaning that
graph.getVertex(v.getIndex()) == v . |
int |
getOutdegree()
Gets the outdegree of the vertex which is defined as: deg+(v) = number of outgoing edges of v.
|
Edge |
getOutgoingEdge(int index)
Gets an outgoing edge at the given index.
|
int |
getOutgoingEdgeCount()
Gets the number of outgoing edges.
|
void |
serialize(Serializer s)
Serializes (saves) the object data to the given serializer.
|
void |
setCaption(java.lang.String caption)
Sets the caption of the vertex.
|
java.lang.String |
toString()
Returns a string representation of the vertex more precisely the caption of the vertex.
|
public Vertex(java.lang.String caption) throws java.lang.IllegalArgumentException
caption
- the caption of the vertexjava.lang.IllegalArgumentException
- public final int getID()
v1.getID() == v2.getID()
.
-1
if this vertex is not yet associated with a graphpublic final int getIndex()
graph.getVertex(v.getIndex()) == v
.-1
if the vertex is not associated with a graphpublic java.lang.String getCaption()
public void setCaption(java.lang.String caption) throws java.lang.IllegalArgumentException
caption
- the captionjava.lang.IllegalArgumentException
- public int getIncomingEdgeCount()
public Edge getIncomingEdge(int index) throws java.lang.IndexOutOfBoundsException
index
- the indexjava.lang.IndexOutOfBoundsException
- index < 0 || index >= getIncomingEdgesCount()
)Edge.getPredecessor(Vertex)
,
Edge.getSuccessor(Vertex)
public int getOutgoingEdgeCount()
public Edge getOutgoingEdge(int index) throws java.lang.IndexOutOfBoundsException
index
- the indexjava.lang.IndexOutOfBoundsException
- index < 0 || index >= getOutgoingEdgesCount()
)Edge.getPredecessor(Vertex)
,
Edge.getSuccessor(Vertex)
public int getIncidentEdgeCount()
public Edge getIncidentEdge(int index) throws java.lang.IndexOutOfBoundsException
index
- the indexjava.lang.IndexOutOfBoundsException
- index < 0 || index >= getIncidentEdgeCount()
)Edge.getPredecessor(Vertex)
,
Edge.getSuccessor(Vertex)
public int getDegree()
public int getIndegree()
public int getOutdegree()
public java.lang.String toString()
toString
in class java.lang.Object
public boolean equals(Vertex v)
v != null && v.caption.equals(this.caption)
.v
- the vertextrue
if v equals this vertex otherwise false
public boolean equals(java.lang.Object o)
equals
in class java.lang.Object
o
- the objecttrue
if o equals this vertex otherwise false
public void serialize(Serializer s)
Serializable
serialize
in interface Serializable
s
- the serializer for the objectpublic void deserialize(Serializer s)
Serializable
deserialize
in interface Serializable
s
- the serializer