fi.joensuu.cs.tra
Class AbstractGraph

java.lang.Object
  extended by fi.joensuu.cs.tra.AbstractGraph
All Implemented Interfaces:
Iterable
Direct Known Subclasses:
DiGraph, Graph

public abstract class AbstractGraph
extends Object
implements Iterable


Nested Class Summary
 class AbstractGraph.EdgeIteratorWrapper
           
 class AbstractGraph.VertexIteratorWrapper
           
 
Field Summary
static int BLACK
          Named constant (0)
static int BLUE
          Named constant (5)
static int GRAY
          Named constant (2)
static int GREEN
          Named constant (4)
static int GREY
          Named constant (2)
static int NaN
          NaN is used to represent a missing color or weight.
static int RED
          Named constant (3)
static int WHITE
          Named constant (1)
 
Method Summary
 Vertex addVertex()
          Adds a Vertex to this graph with the specified attributes.
 Vertex addVertex(float weight)
          Adds a Vertex to this graph with the specified attributes.
 Vertex addVertex(float weight, int index)
          Adds a Vertex to this graph with the specified attributes.
 Vertex addVertex(int index)
          Adds a Vertex to this graph with the specified attributes.
 Vertex addVertex(int color, float weight)
          Adds a Vertex to this graph with the specified attributes.
 Vertex addVertex(int color, float weight, int index)
          Adds a Vertex to this graph with the specified attributes.
 Vertex addVertex(int color, int index)
          Adds a Vertex to this graph with the specified attributes.
 Vertex addVertex(String label)
          Adds a Vertex to this graph with the specified attributes.
 Vertex addVertex(String label, int index)
          Adds a Vertex to this graph with the specified attributes.
 Vertex addVertex(String label, int color, float weight)
          Adds a Vertex to this graph with the specified attributes.
 Vertex addVertex(String label, int color, float weight, int index)
          Adds a Vertex to this graph with the specified attributes.
 Vertex addVertex(String label, int color, int index)
          Adds a Vertex to this graph with the specified attributes.
 Iterator<Edge> edgeIterator()
          Returns an Iterator over the edges of this graph.
 Iterable<Edge> edges()
          Returns an Iterable over this graph's edges.
 Vertex firstVertex()
          Returns the first Vertex in this graph.
 boolean isDiGraph()
          Returns whether this is a directed graph
 Iterator<Vertex> iterator()
          Returns an Iterator over the vertices of this graph.
 void removeVertex(Vertex vertex)
          Removes the specified Vertex and all attached Edges from this graph.
 int size()
          Returns the number of vertices in this graph.
 String toString()
          Returns the string representation of this graph.
 int vertexCount()
          Returns the number of vertices in this graph.
 Iterator<Vertex> vertexIterator()
          Returns an Iterator over the vertices of this graph.
 Iterable<Vertex> vertices()
          Returns an Iterable over this graph's vertices.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

BLACK

public static final int BLACK
Named constant (0)

See Also:
Constant Field Values

WHITE

public static final int WHITE
Named constant (1)

See Also:
Constant Field Values

GRAY

public static final int GRAY
Named constant (2)

See Also:
Constant Field Values

GREY

public static final int GREY
Named constant (2)

See Also:
Constant Field Values

RED

public static final int RED
Named constant (3)

See Also:
Constant Field Values

GREEN

public static final int GREEN
Named constant (4)

See Also:
Constant Field Values

BLUE

public static final int BLUE
Named constant (5)

See Also:
Constant Field Values

NaN

public static final int NaN
NaN is used to represent a missing color or weight.

See Also:
Constant Field Values
Method Detail

size

public int size()
Returns the number of vertices in this graph.

Returns:
the number of vertices in this graph

isDiGraph

public boolean isDiGraph()
Returns whether this is a directed graph

Returns:
whether this is a directed graph

vertexCount

public int vertexCount()
Returns the number of vertices in this graph.

Returns:
the number of vertices in this graph

addVertex

public Vertex addVertex(String label,
                        int color,
                        float weight,
                        int index)
Adds a Vertex to this graph with the specified attributes.

Parameters:
label - the label for the new Vertex
color - the color for the new Vertex
weight - the weight for the new Vertex
index - the index for the new Vertex
Returns:
the new Vertex

addVertex

public Vertex addVertex(String label,
                        int color,
                        int index)
Adds a Vertex to this graph with the specified attributes. The weight will default to NaN.

Parameters:
label - the label for the new Vertex
color - the color for the new Vertex
index - the index for the new Vertex
Returns:
the new Vertex

addVertex

public Vertex addVertex(String label,
                        int index)
Adds a Vertex to this graph with the specified attributes. The weight and color will default to NaN.

Parameters:
label - the label for the new Vertex
index - the index for the new Vertex
Returns:
the new Vertex

addVertex

public Vertex addVertex(int index)
Adds a Vertex to this graph with the specified attributes. The weight and color will default to NaN and the Vertex will have a sequential number as its label.

Parameters:
index - the index for the new Vertex
Returns:
the new Vertex

addVertex

public Vertex addVertex(int color,
                        float weight,
                        int index)
Adds a Vertex to this graph with the specified attributes. The Vertex will have a sequential number as its label.

Parameters:
color - the color for the new Vertex
weight - the weight for the new Vertex
index - the index for the new Vertex
Returns:
the new Vertex

addVertex

public Vertex addVertex(int color,
                        int index)
Adds a Vertex to this graph with the specified attributes. The Vertex will have a sequential number as its label and its weight will default to NaN.

Parameters:
color - the color for the new Vertex
index - the index for the new Vertex
Returns:
the new Vertex

addVertex

public Vertex addVertex(float weight,
                        int index)
Adds a Vertex to this graph with the specified attributes. The Vertex will have a sequential number as its label and its color will default to NaN.

Parameters:
weight - the weight for the new Vertex
index - the index for the new Vertex
Returns:
the new Vertex

addVertex

public Vertex addVertex(String label,
                        int color,
                        float weight)
Adds a Vertex to this graph with the specified attributes.

Parameters:
label - the label for the new Vertex
color - the color for the new Vertex
weight - the weight for the new Vertex
Returns:
the new Vertex

addVertex

public Vertex addVertex(String label)
Adds a Vertex to this graph with the specified attributes. The weight and color will default to NaN.

Parameters:
label - the label for the new Vertex
Returns:
the new Vertex

addVertex

public Vertex addVertex()
Adds a Vertex to this graph with the specified attributes. The weight and color will default to NaN and the Vertex will have a sequential number as its label.

Returns:
the new Vertex

addVertex

public Vertex addVertex(int color,
                        float weight)
Adds a Vertex to this graph with the specified attributes. The Vertex will have a sequential number as its label.

Parameters:
color - the color for the new Vertex
weight - the weight for the new Vertex
Returns:
the new Vertex

addVertex

public Vertex addVertex(float weight)
Adds a Vertex to this graph with the specified attributes. The Vertex will have a sequential number as its label and its color will default to NaN.

Parameters:
weight - the weight for the new Vertex
Returns:
the new Vertex

removeVertex

public void removeVertex(Vertex vertex)
Removes the specified Vertex and all attached Edges from this graph.

Parameters:
vertex - the Vertex to remove

iterator

public Iterator<Vertex> iterator()
Returns an Iterator over the vertices of this graph.

Specified by:
iterator in interface Iterable
Returns:
an Iterator over the vertices of this graph

vertexIterator

public Iterator<Vertex> vertexIterator()
Returns an Iterator over the vertices of this graph.

Returns:
an Iterator over the vertices of this graph

edgeIterator

public Iterator<Edge> edgeIterator()
Returns an Iterator over the edges of this graph.

Returns:
an Iterator over the edges of this graph

firstVertex

public Vertex firstVertex()
Returns the first Vertex in this graph.

Returns:
the first Vertex in this graph

vertices

public Iterable<Vertex> vertices()
Returns an Iterable over this graph's vertices.

Returns:
an Iterable over this graph's vertices

edges

public Iterable<Edge> edges()
Returns an Iterable over this graph's edges.

Returns:
an Iterable over this graph's edges

toString

public String toString()
Returns the string representation of this graph.

Overrides:
toString in class Object
Returns:
the string representation of this graph