Package dsa
Class SymbolGraph
java.lang.Object
dsa.SymbolGraph
An immutable data type to represent an undirected symbol graph.
-
Constructor Summary
ConstructorDescriptionSymbolGraph
(stdlib.In in, String delim) Constructs a symbol graph from the input streamin
and usingdelim
as the delimiter. -
Method Summary
Modifier and TypeMethodDescriptionboolean
Returnstrue
if this symbol graph contains vertexs
, andfalse
otherwise.graph()
Returns the graph associated with this symbol graph.int
Returns the integer associated with the vertexs
in this symbol graph.static void
Unit tests the data type.nameOf
(int v) Returns the name of the vertex associated with the integerv
in this symbol graph.toString()
Returns a string representation of this symbol graph.
-
Constructor Details
-
SymbolGraph
Constructs a symbol graph from the input streamin
and usingdelim
as the delimiter.- Parameters:
in
- the input stream.delim
- the delimiter between fields.
-
-
Method Details
-
contains
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
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
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
Returns the graph associated with this symbol graph.- Returns:
- the graph associated with this symbol graph.
-
toString
Returns a string representation of this symbol graph. -
main
Unit tests the data type.- Parameters:
args
- the command-line arguments.
-