Package moss

Class Embedding

java.lang.Object
moss.Embedding
All Implemented Interfaces:
Serializable

public class Embedding extends Object implements Serializable
Class for embeddings of substructures into graphs.

An embedding of a substructure is represented by referring to the nodes and edges of a graph, namely by simply listing the nodes and edges (from the graph) that form the substructure. An embedding must contain at least one node, i.e., it cannot be empty. It need not contain any edges, though.

If the edges array has a positive length, then usually edges[edges.length-1] contains the edge added last (perfect extensions and ring extensions may lead to exceptions from this rule, especially after adaptation).

The nodes in the nodes array are usually sorted in the order in which they have been added in the extension process (perfect extensions and ring extensions may lead to exceptions from this rule, especially after adaptation).

Since:
2002.03.11
See Also:
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected Edge[]
    the array of edges (only references to the underlying graph)
    protected Graph
    the graph referred to
    protected Node[]
    the array of nodes (only references to the underlying graph)
    protected Embedding
    the next embedding in a list of embeddings
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
    Dummy constructor.
    protected
    Create an embedding from a canonical form.
    protected
    Embedding(Embedding emb, Edge edge)
    Extend a given embedding with a given edge.
    protected
    Embedding(Graph graph, int index)
    Create a single node embedding.
    protected
    Embedding(Graph graph, Node[] nodes, Edge[] edges)
    Create an embedding from node and edge references.
  • Method Summary

    Modifier and Type
    Method
    Description
    protected int
    Find the (maximum) length of a common edge array prefix.
    boolean
    Check whether two embeddings are equal.
    protected Embedding
    extend(int src, int dst, int edge, int node)
    Create all extensions of a given type of this embedding.
    protected int
    Get the group of the underlying graph.
    int
    Compute the hash code of the subgraph described by the embedding.
    protected void
    Mark all nodes and edges with their index.
    static void
    main(String[] args)
    Main function for testing the overlap functions.
    protected void
    mark(int mark)
    Mark all nodes and edges with a given value.
    protected boolean
    Check whether this embedding overlaps another.
    protected boolean
    overlaps(Embedding emb, boolean harmful)
    Check whether this embedding overlaps another.
    protected boolean
    Check whether this embedding overlaps another harmfully.

    Methods inherited from class java.lang.Object

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

    • succ

      protected Embedding succ
      the next embedding in a list of embeddings
    • graph

      protected Graph graph
      the graph referred to
    • nodes

      protected Node[] nodes
      the array of nodes (only references to the underlying graph)
    • edges

      protected Edge[] edges
      the array of edges (only references to the underlying graph)
  • Constructor Details

    • Embedding

      protected Embedding()
      Dummy constructor.

      This constructor is only needed to create the dummy object CONTAINED in the class Graph, which is used as a special parameter and as a special return value for the function Graph.embed() in order to save a recursion parameter.

      Since:
      2006.08.28 (Christian Borgelt)
    • Embedding

      protected Embedding(Graph graph, int index)
      Create a single node embedding.

      The node referred to is given by its index in the graph. The edges array is initialized to an array of zero size (not null).

      Parameters:
      graph - the graph into which to embed
      index - the index of the node in the graph
      Since:
      2002.03.11 (Christian Borgelt)
    • Embedding

      protected Embedding(Graph graph, Node[] nodes, Edge[] edges)
      Create an embedding from node and edge references.

      This function is used when embedding a seed structure. The given node and edge arrays are copied.

      Parameters:
      graph - the graph referred to
      nodes - the nodes of the substructure
      edges - the edges of the substructure
      Since:
      2002.03.11 (Christian Borgelt)
    • Embedding

      protected Embedding(CanonicalForm cnf)
      Create an embedding from a canonical form.

      This function is called if a created extension is only needed as an embedding (in contrast to a fragment).

      Parameters:
      cnf - the canonical form holding the extension
      Since:
      2002.03.11 (Christian Borgelt)
    • Embedding

      protected Embedding(Embedding emb, Edge edge)
      Extend a given embedding with a given edge.

      This function assumes that the nodes of the embedding to extend are marked (with non-negative values) in the underlying graph. It is only needed for Embedding.extend().

      Parameters:
      emb - the embedding to extend
      edge - the edge by which to extend the embedding
      Since:
      2002.03.11 (Christian Borgelt)
      See Also:
  • Method Details

    • equals

      public boolean equals(Object emb)
      Check whether two embeddings are equal.

      This method is overridden only to avoid certain warnings.

      Overrides:
      equals in class Object
      Parameters:
      emb - the embedding to compare to
      Since:
      2007.11.06 (Christian Borgelt)
    • hashCode

      public int hashCode()
      Compute the hash code of the subgraph described by the embedding.

      This function should yield the same value as the corresponding function Graph.hashCode().

      Overrides:
      hashCode in class Object
      Returns:
      the hash code of the subgraph described by the embedding
      Since:
      2006.11.11 (Christian Borgelt)
    • getGroup

      protected int getGroup()
      Get the group of the underlying graph.
      Returns:
      the group of the underlying graph
      Since:
      2007.08.10 (Christian Borgelt)
    • mark

      protected void mark(int mark)
      Mark all nodes and edges with a given value.
      Parameters:
      mark - the value with which to mark nodes and edges
      Since:
      2002.04.14 (Christian Borgelt)
    • index

      protected void index()
      Mark all nodes and edges with their index.
      Since:
      2002.04.14 (Christian Borgelt)
    • common

      protected int common(Embedding emb)
      Find the (maximum) length of a common edge array prefix.
      Parameters:
      emb - the embedding to compare to
      Returns:
      the number of edges that are common to the embeddings, or -1 if not even the root node coincides
      Since:
      2007.10.23 (Christian Borgelt)
    • extend

      protected Embedding extend(int src, int dst, int edge, int node)
      Create all extensions of a given type of this embedding.

      The type of the extension is described by the index of the source node (index in the embedding), the index of the destination node (which may be negative in order to indicate that the node is not yet part of the embedding), the type of the edge and the type of the destination node of the edge to add.

      Parameters:
      src - the index of the source node
      dst - the index of the destination node (or -1 if it is not yet part of the embedding)
      edge - the type of the extension edge
      node - the type of the destination node
      Returns:
      a list of created embeddings
      Since:
      2002.03.11 (Christian Borgelt)
    • overlaps

      protected boolean overlaps(Embedding emb, boolean harmful)
      Check whether this embedding overlaps another.
      Parameters:
      emb - the embedding to check for an overlap
      harmful - whether to check for a harmful overlap
      Returns:
      whether the embeddings overlap each other
      Since:
      2007.06.14 (Christian Borgelt)
    • overlaps

      protected boolean overlaps(Embedding emb)
      Check whether this embedding overlaps another.
      Parameters:
      emb - the embedding to check for an overlap
      Returns:
      whether the embeddings overlap each other
      Since:
      2007.06.12 (Christian Borgelt)
    • overlapsHarmfully

      protected boolean overlapsHarmfully(Embedding emb)
      Check whether this embedding overlaps another harmfully.

      It is assumed that the two embeddings refer to the same fragment and thus have the same number of nodes and edges.

      Parameters:
      emb - the embedding to check for an overlap
      Returns:
      whether the embeddings overlap each other harmfully
      Since:
      2007.06.13 (Christian Borgelt)
    • main

      public static void main(String[] args)
      Main function for testing the overlap functions.
      Parameters:
      args - the command line arguments
      Since:
      2007.06.12 (Christian Borgelt)