Package dsa
Class SymbolGraph
- java.lang.Object
-
- dsa.SymbolGraph
-
public class SymbolGraph extends Object
An immutable data type to represent an undirected symbol graph.
-
-
Constructor Summary
Constructors Constructor Description SymbolGraph(stdlib.In in, String delim)
Constructs a symbol graph from the input streamin
and usingdelim
as the delimiter.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
contains(String s)
Returnstrue
if this symbol graph contains vertexs
, andfalse
otherwise.Graph
graph()
Returns the graph associated with this symbol graph.int
indexOf(String s)
Returns the integer associated with the vertexs
in this symbol graph.static void
main(String[] args)
Unit tests the data type.String
nameOf(int v)
Returns the name of the vertex associated with the integerv
in this symbol graph.String
toString()
Returns a string representation of this symbol graph.
-
-
-
Constructor Detail
-
SymbolGraph
public SymbolGraph(stdlib.In in, String delim)
Constructs a symbol graph from the input streamin
and usingdelim
as the delimiter.- Parameters:
in
- the input stream.delim
- the delimiter between fields.
-
-
Method Detail
-
contains
public boolean contains(String s)
Returnstrue
if this symbol graph contains vertexs
, andfalse
otherwise.- Parameters:
s
- the vertex name.- Returns:
true
if this symbol graph contains vertexs
, andfalse
otherwise.
-
indexOf
public int indexOf(String s)
Returns the integer associated with the vertexs
in this symbol graph.- Parameters:
s
- the vertex name.- Returns:
- the integer associated with the vertex
s
in this symbol graph.
-
nameOf
public String nameOf(int v)
Returns the name of the vertex associated with the integerv
in this symbol graph.- Parameters:
v
- the integer corresponding to a vertex.- Returns:
- the name of the vertex associated with the integer
v
in this symbol graph.
-
graph
public Graph graph()
Returns the graph associated with this symbol graph.- Returns:
- the graph associated with this symbol graph.
-
toString
public String toString()
Returns a string representation of this symbol graph.
-
main
public static void main(String[] args)
Unit tests the data type.- Parameters:
args
- the command-line arguments.
-
-