Package moss

Class Edge

java.lang.Object
moss.Edge
All Implemented Interfaces:
Serializable, Comparable<Edge>

public class Edge extends Object implements Comparable<Edge>, Serializable
Class for edges of an attributed (labeled/typed) graph.

An edge carries information about the nodes it connects, its type, whether it is part of a ring (for example, an aromatic ring in a molecule), and whether it is a bridge in graph it is part of. In addition, for ring edges a bit flag array makes it possible to easily follow a ring in a molecule.

Note that only 30 bits are actually available for the type of the edge. The two most significant bits are reserved as flags, for example, for marking ring bonds.

Since:
2002.03.11
See Also:
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final long
    the mask to extract the bridge flag
    protected Node
    the destination node of the edge
    static final int
    the mask for the edge flags (wildcard and ring)
    protected long
    the flags for rings and bridges
    protected int
    a marker for internal use (e.g.
    static final int
    the flag for the edge type to distinguish ring edges
    static final long
    the mask to extract the ring flags
    protected Node
    the source node of the edge
    protected int
    the type of the edge, e.g.
    static final int
    the mask for the base type
    static final int
    the flag for a wildcard type
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
    Edge(Node src, Node dst, int type)
    Create an edge of a given type between two nodes.
    protected
    Edge(Node src, Node dst, int type, long flags)
    Create an edge of a given type between two nodes.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Clear the ring flags of the edge.
    int
    Compare two edges (w.r.t.
    boolean
    equals(Object edge)
    Check whether two edges are equal.
    int
    Get the base type (attribute/label) of an edge.
    Get the destination node of the edge.
    long
    Get the ring flags of the edge.
    Get the source node of the edge.
    int
    Get the full type (attribute/label) of an edge.
    int
    Compute the Hash code of an edge.
    boolean
    Check whether the edge is a bridge.
    boolean
    Check whether the edge is part of a ring.
    boolean
    Check whether this is a special edge (wildcard or ring).
    boolean
    Check whether this is a wildcard edge.
    void
    markBridge(boolean bridge)
    Set or clear the bridge flag of the edge.
    void
    markRing(boolean ring)
    Set or clear the ring type flag of the edge.
    void
    maskType(int mask)
    Mask the edge type with the given mask.

    Methods inherited from class java.lang.Object

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

    • TYPEMASK

      public static final int TYPEMASK
      the mask for the base type
      See Also:
    • FLAGMASK

      public static final int FLAGMASK
      the mask for the edge flags (wildcard and ring)
      See Also:
    • WILDCARD

      public static final int WILDCARD
      the flag for a wildcard type
      See Also:
    • RING

      public static final int RING
      the flag for the edge type to distinguish ring edges
      See Also:
    • BRIDGE

      public static final long BRIDGE
      the mask to extract the bridge flag
      See Also:
    • RINGMASK

      public static final long RINGMASK
      the mask to extract the ring flags
      See Also:
    • type

      protected int type
      the type of the edge, e.g. SINGLE
    • mark

      protected int mark
      a marker for internal use (e.g. for a substructure)
    • src

      protected Node src
      the source node of the edge
    • dst

      protected Node dst
      the destination node of the edge
    • flags

      protected long flags
      the flags for rings and bridges
  • Constructor Details

    • Edge

      protected Edge(Node src, Node dst, int type, long flags)
      Create an edge of a given type between two nodes.

      The created edge is automatically added to the two nodes it connects.

      Parameters:
      src - the source node of the edge
      dst - the destination node of the edge
      type - the type of the edge
      flags - the ring and bridge flags of the edge
      Since:
      2009.05.04 (Christian Borgelt)
    • Edge

      protected Edge(Node src, Node dst, int type)
      Create an edge of a given type between two nodes.

      The created edge is automatically added to the two nodes it connects.

      Parameters:
      src - the source node of the edge
      dst - the destination node of the edge
      type - the type of the edge
      Since:
      2002.03.11 (Christian Borgelt)
  • Method Details

    • getType

      public int getType()
      Get the full type (attribute/label) of an edge.
      Returns:
      the type of the edge
      Since:
      2002.03.11 (Christian Borgelt)
    • getBaseType

      public int getBaseType()
      Get the base type (attribute/label) of an edge.
      Returns:
      the type of the edge
      Since:
      2009.08.13 (Christian Borgelt)
    • maskType

      public void maskType(int mask)
      Mask the edge type with the given mask.
      Parameters:
      mask - the mask for the edge typ
      Since:
      2002.03.11 (Christian Borgelt)
    • isSpecial

      public boolean isSpecial()
      Check whether this is a special edge (wildcard or ring).
      Returns:
      whether this is a special edge
      Since:
      2008.08.13 (Christian Borgelt)
    • isWildcard

      public boolean isWildcard()
      Check whether this is a wildcard edge.
      Returns:
      whether this is a wildcard edge
      Since:
      2008.08.13 (Christian Borgelt)
    • isInRing

      public boolean isInRing()
      Check whether the edge is part of a ring.

      This function only extracts the ring flag from the edge type. It does not analyze the graph containing the edge.

      Returns:
      whether the edge is part of a ring
      Since:
      2002.03.11 (Christian Borgelt)
    • markRing

      public void markRing(boolean ring)
      Set or clear the ring type flag of the edge.
      Parameters:
      ring - whether the edge is in a ring
      Since:
      2007.06.30 (Christian Borgelt)
    • getSource

      public Node getSource()
      Get the source node of the edge.
      Returns:
      the source node of the edge
      Since:
      2002.03.11 (Christian Borgelt)
    • getDest

      public Node getDest()
      Get the destination node of the edge.
      Returns:
      the destination node of the edge
      Since:
      2002.03.11 (Christian Borgelt)
    • getRings

      public long getRings()
      Get the ring flags of the edge.

      This function only extracts the ring flags from the flags field. It does not analyze the graph containing the edge.

      Returns:
      the ring flags of the edge
      Since:
      2002.03.11 (Christian Borgelt)
    • clearRings

      public void clearRings()
      Clear the ring flags of the edge.
      Since:
      2007.06.30 (Christian Borgelt)
    • isBridge

      public boolean isBridge()
      Check whether the edge is a bridge.

      This function only extracts the bridge flag from the flags field. It does not analyze the graph containing the edge.

      Returns:
      whether the edge is a bridge
      Since:
      2002.03.11 (Christian Borgelt)
    • markBridge

      public void markBridge(boolean bridge)
      Set or clear the bridge flag of the edge.
      Parameters:
      bridge - whether the edge is a bridge
      Since:
      2002.03.11 (Christian Borgelt)
    • compareTo

      public int compareTo(Edge obj)
      Compare two edges (w.r.t. their marker values).

      This function is needed in NamedGraph.split() (indirectly through Arrays.sort()).

      Specified by:
      compareTo in interface Comparable<Edge>
      Parameters:
      obj - the edge to compare to
      Returns:
      the sign of the difference of the edge markers, that is, -1, 0, or +1 as the marker of this edge is less than, equal to, or greater than the marker of the edge given as an argument
      Since:
      2007.06.14 (Christian Borgelt)
    • hashCode

      public int hashCode()
      Compute the Hash code of an edge.
      Overrides:
      hashCode in class Object
      Returns:
      the Hash code of the edge
      Since:
      2015.05.02 (Christian Borgelt)
    • equals

      public boolean equals(Object edge)
      Check whether two edges are equal.

      This method checks whether the two edges connect nodes of the same type with an edge of the same type. If this is the case, the function returns true, otherwise it returns false.

      Overrides:
      equals in class Object
      Parameters:
      edge - the edge to compare to
      Returns:
      whether the two edges are equal
      Since:
      2009.04.30 (Christian Borgelt)