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 stream in using delim as the delimiter.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    Returns true if this symbol digraph contains vertex s, and false otherwise.
    Returns the digraph associated with this symbol digraph.
    int
    Returns the integer associated with the vertex s in this symbol digraph.
    static void
    main(String[] args)
    Unit tests the data type.
    nameOf(int v)
    Returns the name of the vertex associated with the integer v in this symbol digraph.
    Returns a string representation of this symbol digraph.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • SymbolDiGraph

      public SymbolDiGraph(stdlib.In in, String delim)
      Constructs a symbol digraph from the input stream in using delim as the delimiter.
      Parameters:
      in - the input stream.
      delim - the delimiter between fields.
  • Method Details

    • contains

      public boolean contains(String s)
      Returns true if this symbol digraph contains vertex s, and false otherwise.
      Parameters:
      s - the vertex name.
      Returns:
      true if this symbol digraph contains vertex s, and false otherwise.
    • indexOf

      public int indexOf(String s)
      Returns the integer associated with the vertex s 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 integer v 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.
      Overrides:
      toString in class Object
      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.