public class LabeledGraph<VertexLabelType,EdgeLabelType>
extends java.lang.Object
aima.util.Table
. This version is more dynamic, it requires no
initialization and can add new items whenever needed.Constructor and Description |
---|
LabeledGraph()
Creates a new empty graph.
|
Modifier and Type | Method and Description |
---|---|
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, or 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.
|
public void addVertex(VertexLabelType v)
v
- the vertex to addpublic void set(VertexLabelType from, VertexLabelType to, EdgeLabelType el)
from
- the first vertex of the edgeto
- the second vertex of the edgeel
- an edge labelpublic void remove(VertexLabelType from, VertexLabelType to)
from
- the first vertex of the edgeto
- the second vertex of the edgepublic EdgeLabelType get(VertexLabelType from, VertexLabelType to)
from
- the first vertex of the egeto
- the second vertex of the edgepublic java.util.List<VertexLabelType> getSuccessors(VertexLabelType v)
public java.util.List<VertexLabelType> getVertexLabels()
public boolean isVertexLabel(VertexLabelType v)
public void clear()