Package dsa
Class SymbolDiGraph
- java.lang.Object
-
- dsa.SymbolDiGraph
-
public class SymbolDiGraph extends Object
An immutable data type to represent a directed symbol graph.
-
-
Constructor Summary
Constructors Constructor Description SymbolDiGraph(stdlib.In in, String delim)
Constructs a symbol digraph from the input streamin
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 digraph contains vertexs
, andfalse
otherwise.DiGraph
diGraph()
Returns the digraph associated with this symbol digraph.int
indexOf(String s)
Returns the integer associated with the vertexs
in this symbol digraph.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 digraph.String
toString()
Returns a string representation of this symbol digraph.
-
-
-
Constructor Detail
-
SymbolDiGraph
public SymbolDiGraph(stdlib.In in, String delim)
Constructs a symbol digraph from the input streamin
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 digraph contains vertexs
, andfalse
otherwise.- Parameters:
s
- the vertex name.- Returns:
true
if this symbol digraph contains vertexs
, andfalse
otherwise.
-
indexOf
public int indexOf(String s)
Returns the integer associated with the vertexs
in this symbol digraph.- Parameters:
s
- the vertex name.- Returns:
- the integer associated with the vertex
s
in this symbol digraph.
-
nameOf
public String nameOf(int v)
Returns the name of the vertex associated with the integerv
in this symbol digraph.- Parameters:
v
- the integer corresponding to a vertex.- Returns:
- the name of the vertex associated with the integer
v
in this symbol digraph.
-
diGraph
public DiGraph diGraph()
Returns the digraph associated with this symbol digraph.- Returns:
- the digraph associated with this symbol digraph.
-
toString
public String toString()
Returns a string representation of this symbol digraph.
-
main
public static void main(String[] args)
Unit tests the data type.- Parameters:
args
- the command-line arguments.
-
-