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

    Modifier and Type
    Method
    Description
    boolean
    Returns true if this symbol graph contains vertex s, and false otherwise.
    Returns the graph associated with this symbol graph.
    int
    Returns the integer associated with the vertex s in this symbol graph.
    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 graph.
    Returns a string representation of this symbol graph.

    Methods inherited from class java.lang.Object

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

    • SymbolGraph

      public SymbolGraph(stdlib.In in, String delim)
      Constructs a symbol graph from the input stream in and 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 graph contains vertex s, and false otherwise.
      Parameters:
      s - the vertex name.
      Returns:
      true if this symbol graph contains vertex s, and false otherwise.
    • indexOf

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