Package moss

Class Notation

java.lang.Object
moss.Notation
All Implemented Interfaces:
Serializable
Direct Known Subclasses:
FreeNtn, MoleculeNtn

public abstract class Notation extends Object implements Serializable
Class for notations for attributed graphs.
Since:
2006.08.12
See Also:
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected int
    the number of unread/pushed back characters
    protected TypeMgr
    the manager for the edge types
    protected TypeMgr
    the manager for the node types
    protected Reader
    the reader from which to read the graph description
    protected int[]
    the stack of unread/pushed back characters
  • Constructor Summary

    Constructors
    Constructor
    Description
    Create a notation.
  • Method Summary

    Modifier and Type
    Method
    Description
    static Notation
    Create a graph notation corresponding to a given name.
    abstract String
    describe(Graph graph)
    Create a string description of a graph.
    int
    Get the delimiter character.
    Get the edge type manager.
    Get the node type manager.
    abstract boolean
    Whether this notation has a fixed set of (node and edge) types.
    abstract boolean
    Whether this is a line notation (single line description).
    protected static void
    mark(Node node)
    Mark the visits of each node.
    abstract Graph
    parse(Reader reader)
    Parse a description of an attributed graph.
    protected int
    Read the next character.
    void
    Set the edge type manager.
    void
    Set the node type manager.
    protected void
    setReader(Reader reader)
    Set the reader to read from.
    void
    Set the type managers from another notation.
    protected static void
    unmark(Node node)
    Unmark a connected component.
    protected void
    unread(int c)
    Unread/push back a character.
    abstract void
    write(Graph graph, Writer writer)
    Write a description of an attributed graph.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • nodemgr

      protected TypeMgr nodemgr
      the manager for the node types
    • edgemgr

      protected TypeMgr edgemgr
      the manager for the edge types
    • reader

      protected transient Reader reader
      the reader from which to read the graph description
    • stack

      protected int[] stack
      the stack of unread/pushed back characters
    • cnt

      protected int cnt
      the number of unread/pushed back characters
  • Constructor Details

    • Notation

      public Notation()
      Create a notation.
      Since:
      2023.07.31 (Christian Borgelt)
  • Method Details

    • isLine

      public abstract boolean isLine()
      Whether this is a line notation (single line description).

      A notation that describes an attributed graph in a single line (like SMILES or SLN) returns true, a notation that needs multiple lines (like Ctab) returns false.

      Returns:
      whether this is a line notation
      Since:
      2007.03.04 (Christian Borgelt)
    • hasFixedTypes

      public abstract boolean hasFixedTypes()
      Whether this notation has a fixed set of (node and edge) types.
      Returns:
      whether this notation has a fixed set of types
      Since:
      2007.06.29 (Christian Borgelt)
    • getNodeMgr

      public TypeMgr getNodeMgr()
      Get the node type manager.
      Returns:
      the node type manager
      Since:
      2007.06.21 (Christian Borgelt)
    • setNodeMgr

      public void setNodeMgr(TypeMgr nodemgr)
      Set the node type manager.

      This function should only have an effect if the function hasFixedTyes() returns false.

      Parameters:
      nodemgr - the new node type manager
      Since:
      2007.06.29 (Christian Borgelt)
      See Also:
    • getEdgeMgr

      public TypeMgr getEdgeMgr()
      Get the edge type manager.
      Returns:
      the edge type manager
      Since:
      2007.06.21 (Christian Borgelt)
    • setEdgeMgr

      public void setEdgeMgr(TypeMgr edgemgr)
      Set the edge type manager.

      This function should only have an effect if the function hasFixedTyes() returns false.

      Parameters:
      edgemgr - the new edge type manager
      Since:
      2007.06.29 (Christian Borgelt)
      See Also:
    • setTypeMgrs

      public void setTypeMgrs(Notation ntn)
      Set the type managers from another notation.
      Parameters:
      ntn - the notation of which to copy the type managers
      Since:
      2007.07.01 (Christian Borgelt)
    • setReader

      protected void setReader(Reader reader)
      Set the reader to read from.

      Also create a small stack to handle pushed back characters.

      Parameters:
      reader - the reader to read from
      Since:
      2007.06.23 (Christian Borgelt)
    • read

      protected int read() throws IOException
      Read the next character.
      Returns:
      the character read
      Throws:
      IOException - if reading the next character failed
      Since:
      2007.06.23 (Christian Borgelt)
    • unread

      protected void unread(int c)
      Unread/push back a character.
      Parameters:
      c - the character to push back
      Since:
      2007.06.23 (Christian Borgelt)
    • parse

      public abstract Graph parse(Reader reader) throws IOException
      Parse a description of an attributed graph.
      Parameters:
      reader - the reader from which to read the description
      Returns:
      the parsed graph
      Throws:
      IOException - if a parse error or an i/o error occurs
      Since:
      2006.08.12 (Christian Borgelt)
    • getDelim

      public int getDelim()
      Get the delimiter character.

      The delimiter character is the character at which parsing stopped, but which was not processed by the parser anymore.

      Returns:
      the delimiter character or -1 if no delimiter character was read
      Since:
      2007.06.26 (Christian Borgelt)
    • describe

      public abstract String describe(Graph graph)
      Create a string description of a graph.
      Parameters:
      graph - the graph to describe
      Returns:
      the created string description
      Since:
      2006.08.12 (Christian Borgelt)
    • write

      public abstract void write(Graph graph, Writer writer) throws IOException
      Write a description of an attributed graph.
      Parameters:
      graph - the graph to write
      writer - the writer to write to
      Throws:
      IOException - if a read error occurred
      Since:
      2007.06.22 (Christian Borgelt)
    • mark

      protected static void mark(Node node)
      Mark the visits of each node.

      In this function the marker of a node is used to determine the number of labels needed for a node: 1 means that the node has not been visited yet, 0 means that it has been visited only once (and thus needs no label) -n, n > 0, means that it has been visited n+1 times and therefore needs n labels (for n "backward connections"). The procedure is a depth-first search and assumes that all nodes have been marked with the value 1 before.

      Parameters:
      node - the current node in the depth-first search
      Since:
      2006.08.12 (Christian Borgelt)
    • unmark

      protected static void unmark(Node node)
      Unmark a connected component.

      With this function a connected component is unmarked after it has been described. The procedure is a simple depth-first search.

      Parameters:
      node - the current node in the depth-first search
      Since:
      2006.08.12 (Christian Borgelt)
    • createNotation

      public static Notation createNotation(String name)
      Create a graph notation corresponding to a given name.
      Parameters:
      name - the name of the notation
      Returns:
      the created notation
      Since:
      2007.03.02 (Christian Borgelt)