Package dsa

Class SymbolGraph


  • public class SymbolGraph
    extends Object
    An immutable data type to represent an undirected symbol graph.
    • Constructor Detail

      • 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 Detail

      • 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.