aima.util
Class LabeledGraph<VertexLabelType,EdgeLabelType>

java.lang.Object
  extended by aima.util.LabeledGraph<VertexLabelType,EdgeLabelType>

public class LabeledGraph<VertexLabelType,EdgeLabelType>
extends java.lang.Object

Represents a directed labeled graph. Vertices are represented by their unique labels and labeled edges by means of nested hashtables. Variant of class aima.util.Table. This version is more dynamic, it requires no initialization and can add new items whenever needed.


Constructor Summary
LabeledGraph()
          Creates a new empty graph.
 
Method Summary
 void addVertex(VertexLabelType v)
          Adds a new vertex to the graph if it is not already present.
 void clear()
          Removes all vertices and all edges from the graph.
 EdgeLabelType get(VertexLabelType from, VertexLabelType to)
          Returns the label of the edge between the specified vertices and null if there is no edge between them.
 java.util.List<VertexLabelType> getSuccessors(VertexLabelType v)
          Returns the labels of those vertices which can be obtained by following the edges starting at the specified vertex.
 java.util.List<VertexLabelType> getVertexLabels()
          Returns the labels of all vertices within the graph.
 boolean isVertexLabel(VertexLabelType v)
          Checks whether the given label is the label of one of the vertices.
 void remove(VertexLabelType from, VertexLabelType to)
          Removes an edge from the graph.
 void set(VertexLabelType from, VertexLabelType to, EdgeLabelType el)
          Adds a directed labeled edge to the graph.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LabeledGraph

public LabeledGraph()
Creates a new empty graph.

Method Detail

addVertex

public void addVertex(VertexLabelType v)
Adds a new vertex to the graph if it is not already present.


set

public void set(VertexLabelType from,
                VertexLabelType to,
                EdgeLabelType el)
Adds a directed labeled edge to the graph. The end points of the edge are specified by vertex labels. New vertices are automatically identified and added to the graph.


remove

public void remove(VertexLabelType from,
                   VertexLabelType to)
Removes an edge from the graph.


get

public EdgeLabelType get(VertexLabelType from,
                         VertexLabelType to)
Returns the label of the edge between the specified vertices and null if there is no edge between them.


getSuccessors

public java.util.List<VertexLabelType> getSuccessors(VertexLabelType v)
Returns the labels of those vertices which can be obtained by following the edges starting at the specified vertex.


getVertexLabels

public java.util.List<VertexLabelType> getVertexLabels()
Returns the labels of all vertices within the graph.


isVertexLabel

public boolean isVertexLabel(VertexLabelType v)
Checks whether the given label is the label of one of the vertices.


clear

public void clear()
Removes all vertices and all edges from the graph.