cl.cromer.estructuras

## Class Grafo.Vertex<T>

- java.lang.Object
- - cl.cromer.estructuras.Grafo.Vertex<T>

Type Parameters:
  `T` - Generic object

Enclosing class:
  Grafo

    public static final class Grafo.Vertex<T>
    extends java.lang.Object

A named graph vertex with optional data.

Version:
  $Revision$
Author:
  Scott.Stark@jboss.org

### Field Summary

Fields
`private T` `data`
`private java.util.List<Grafo.Edge<T>>` `incomingEdges`
`private boolean` `mark`
`private int` `markState`
`private java.lang.String` `name`
`private java.util.List<Grafo.Edge<T>>` `outgoingEdges`

### Constructor Summary

Constructors
Constructor and Description
`Vertex()` Calls this(null, null).
`Vertex(java.lang.String n)` Create a vertex with the given name and no data
`Vertex(java.lang.String n, T data)` Create a Vertex with name n and given data

### Method Summary

All Methods Instance Methods Concrete Methods
`boolean` `addEdge(Grafo.Edge<T> e)` Add an edge to the vertex.
`void` `addIncomingEdge(Grafo.Vertex<T> from, int cost)` Add an incoming edge starting at from
`void` `addOutgoingEdge(Grafo.Vertex<T> to, int cost)` Add an outgoing edge ending at to.
`void` `clearMark()` Clear the visited mark flag.
`int` `cost(Grafo.Vertex<T> dest)` What is the cost from this vertext to the dest vertex.
`Grafo.Edge<T>` `findEdge(Grafo.Edge<T> e)` Search the outgoing edges for a match to e.
`Grafo.Edge<T>` `findEdge(Grafo.Vertex<T> dest)` Search the outgoing edges looking for an edge whose's edge.to == dest.
`T` `getData()`
`Grafo.Edge<T>` `getIncomingEdge(int i)` Get the ith incoming edge
`int` `getIncomingEdgeCount()`
`java.util.List` `getIncomingEdges()` Get the incoming edges
`int` `getMarkState()` Get the mark state value.
`java.lang.String` `getName()`
`Grafo.Edge<T>` `getOutgoingEdge(int i)` Get the ith outgoing edge
`int` `getOutgoingEdgeCount()`
`java.util.List` `getOutgoingEdges()` Get the outgoing edges
`boolean` `hasEdge(Grafo.Edge<T> e)` Check the vertex for either an incoming or outgoing edge mathcing e.
`boolean` `hasEdge(Grafo.Vertex<T> dest)` Is there an outgoing edge ending at dest.
`void` `mark()` Set the vertex mark flag.
`boolean` `remove(Grafo.Edge<T> e)` Remove an edge from this vertex
`void` `setData(T data)`
`void` `setMarkState(int state)` Set the mark state to state.
`java.lang.String` `toString()`
`void` `visit()` Visit the vertex and set the mark flag to true.
`boolean` `visited()` Has this vertex been marked during a visit

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

### Field Detail

#### incomingEdges

    private java.util.List<Grafo.Edge<T>> incomingEdges

#### outgoingEdges

    private java.util.List<Grafo.Edge<T>> outgoingEdges

#### name

    private java.lang.String name

#### mark

    private boolean mark

#### markState

    private int markState

#### data

    private T data

### Constructor Detail

#### Vertex

    public Vertex()

Calls this(null, null).

#### Vertex

    public Vertex(java.lang.String n)

Create a vertex with the given name and no data

Parameters:
  `n` - - return n

#### Vertex

    public Vertex(java.lang.String n,
                  T data)

Create a Vertex with name n and given data

Parameters:
  `n` - - name of vertex
  `data` - - data associated with vertex

### Method Detail

#### getName

    public java.lang.String getName()

Returns:
  the possibly null name of the vertex

#### getData

    public T getData()

Returns:
  the possibly null data of the vertex

#### setData

    public void setData(T data)

Parameters:
  `data` - The data to set.

#### addEdge

    public boolean addEdge(Grafo.Edge<T> e)

Add an edge to the vertex. If edge.from is this vertex, its an outgoing edge. If edge.to is this vertex, its an incoming edge. If neither from or to is this vertex, the edge is not added.

Parameters:
  `e` - - the edge to add
Returns:
  true if the edge was added, false otherwise

#### addOutgoingEdge

    public void addOutgoingEdge(Grafo.Vertex<T> to,
                                int cost)

Add an outgoing edge ending at to.

Parameters:
  `to` - - the destination vertex
  `cost` - the edge cost

#### addIncomingEdge

    public void addIncomingEdge(Grafo.Vertex<T> from,
                                int cost)

Add an incoming edge starting at from

Parameters:
  `from` - - the starting vertex
  `cost` - the edge cost

#### hasEdge

    public boolean hasEdge(Grafo.Edge<T> e)

Check the vertex for either an incoming or outgoing edge mathcing e.

Parameters:
  `e` - the edge to check
Returns:
  true it has an edge

#### remove

    public boolean remove(Grafo.Edge<T> e)

Remove an edge from this vertex

Parameters:
  `e` - - the edge to remove
Returns:
  true if the edge was removed, false if the edge was not connected to this vertex

#### getIncomingEdgeCount

    public int getIncomingEdgeCount()

Returns:
  the count of incoming edges

#### getIncomingEdge

    public Grafo.Edge<T> getIncomingEdge(int i)

Get the ith incoming edge

Parameters:
  `i` - the index into incoming edges
Returns:
  ith incoming edge

#### getIncomingEdges

    public java.util.List getIncomingEdges()

Get the incoming edges

Returns:
  incoming edge list

#### getOutgoingEdgeCount

    public int getOutgoingEdgeCount()

Returns:
  the count of incoming edges

#### getOutgoingEdge

    public Grafo.Edge<T> getOutgoingEdge(int i)

Get the ith outgoing edge

Parameters:
  `i` - the index into outgoing edges
Returns:
  ith outgoing edge

#### getOutgoingEdges

    public java.util.List getOutgoingEdges()

Get the outgoing edges

Returns:
  outgoing edge list

#### findEdge

    public Grafo.Edge<T> findEdge(Grafo.Vertex<T> dest)

Search the outgoing edges looking for an edge whose's edge.to == dest.

Parameters:
  `dest` - the destination
Returns:
  the outgoing edge going to dest if one exists, null otherwise.

#### findEdge

    public Grafo.Edge<T> findEdge(Grafo.Edge<T> e)

Search the outgoing edges for a match to e.

Parameters:
  `e` - - the edge to check
Returns:
  e if its a member of the outgoing edges, null otherwise.

#### cost

    public int cost(Grafo.Vertex<T> dest)

What is the cost from this vertext to the dest vertex.

Parameters:
  `dest` - - the destination vertex.
Returns:
  Return Integer.MAX_VALUE if we have no edge to dest, 0 if dest is this vertex, the cost of the outgoing edge otherwise.

#### hasEdge

    public boolean hasEdge(Grafo.Vertex<T> dest)

Is there an outgoing edge ending at dest.

Parameters:
  `dest` - - the vertex to check
Returns:
  true if there is an outgoing edge ending at vertex, false otherwise.

#### visited

    public boolean visited()

Has this vertex been marked during a visit

Returns:
  true is visit has been called

#### mark

    public void mark()

Set the vertex mark flag.

#### setMarkState

    public void setMarkState(int state)

Set the mark state to state.

Parameters:
  `state` - the state

#### getMarkState

    public int getMarkState()

Get the mark state value.

Returns:
  the mark state

#### visit

    public void visit()

Visit the vertex and set the mark flag to true.

#### clearMark

    public void clearMark()

Clear the visited mark flag.

#### toString

    public java.lang.String toString()

Overrides:
  `toString` in class `java.lang.Object`
Returns:
  a string form of the vertex with in and out edges.