java.lang.Object
de.ipk_gatersleben.ag_nw.graffiti.plugins.algorithms.naive_pattern_finder.PatternAttributeUtils

public class PatternAttributeUtils
extends Object
Utilities for the handling the attributes on graphs, nodes, and edges and the corresponding definition of the strings. Pattern occurences are represented as attributes of nodes fand edges. Every occurence of a pattern is marked as a set of four attributes: the pattern name, the index of the pattern, the index of the node (or edge) within this special occurence of the pattern, and the internal number of the node (or edge) within the pattern graph. These four attributes are group into a number container. This container is called the position container. Every node or edge may have one or more containers, which are encapsulated by another attribute named "PATTERN". The list of patterns is itself encapsulated by the attribute "AGNW" which is the container for the group in Gatersleben. A simple example:
 AGNW [
   PATTERN [
     PATTERN_1 [
       PATTERN_NAME "X1"
       PATTERN_INDEX 1
       NODE_INDEX 1
       INTERNAL_NODE_INDEX 111
     ]
     PATTERN_2 [
       PATTERN_NAME "X1"
       PATTERN_INDEX 2
       NODE_INDEX 2
       INTERNAL_NODE_INDEX 121
     ]
     PATTERN_3 [
       PATTERN_NAME "X2"
       PATTERN_INDEX 1
       NODE_INDEX 1
       INTERNAL_NODE_INDEX 113
     ]
   ]
 ]
 
Author:
Dirk Koschützki
  • Field Details

    • PATTERN_PATH

      public static final String PATTERN_PATH
      The container for all pattern attributes.
      See Also:
      Constant Field Values
    • MIN_ADD_INC_EDGES_PATH

      public static final String MIN_ADD_INC_EDGES_PATH
      Path to the attribute for the minimal value of additional incoming edges.
      See Also:
      Constant Field Values
    • MAX_ADD_INC_EDGES_PATH

      public static final String MAX_ADD_INC_EDGES_PATH
      Path to the attribute for the maximal value of additional incoming edges.
      See Also:
      Constant Field Values
    • MIN_ADD_OUT_EDGES_PATH

      public static final String MIN_ADD_OUT_EDGES_PATH
      Path to the attribute for the minimal value of additional outgoing edges.
      See Also:
      Constant Field Values
    • MAX_ADD_OUT_EDGES_PATH

      public static final String MAX_ADD_OUT_EDGES_PATH
      Path to the attribute for the maximal value of additional outgoing edges.
      See Also:
      Constant Field Values
    • PATTERN_RECORD_PREFIX

      public static final String PATTERN_RECORD_PREFIX
      The prefix of the attribute name for the pattern record. Every attribute needs a unique name which has to start with a string. Therefore we generate a new unique name based on this prefix for every occurence of a pattern at a node.
      See Also:
      Constant Field Values
    • PATTERN_NAME

      public static final String PATTERN_NAME
      The attribute name for the pattern name. The pattern name is of type String and stores the name of the pattern.
      See Also:
      Constant Field Values
    • PATTERN_INDEX

      public static final String PATTERN_INDEX
      The attribute name for the pattern index. Each pattern can be found several times in a graph. If a pattern of one type is found two times in a graph, all nodes which belong to the first accourence will get the index 1, the second found pattern will get the number 2. This number will be the same for differnt patterns. So the first found pattern of a second type will get also the number 1 for the pattern_index.
      See Also:
      Constant Field Values
    • NODE_INDEX

      public static final String NODE_INDEX
      The attribute name for the node index. Every node within the occurence of a pattern will be enumerated within this attribute.
      See Also:
      Constant Field Values
    • EDGE_INDEX

      public static final String EDGE_INDEX
      The attribute name for the edge index. Every edge within the occurence of a pattern will be enumerated within this attribute.
      See Also:
      Constant Field Values
    • INTERNAL_NODE_INDEX

      public static final String INTERNAL_NODE_INDEX
      The attribute name for the internal node index. Additionally to the node index the internal id of the node within the pattern graph is saved in the target graph. Beware: The internal id may be different from the node index, as the id is automatically generated during constrution of the pattern graph!
      See Also:
      Constant Field Values
    • INTERNAL_EDGE_INDEX

      public static final String INTERNAL_EDGE_INDEX
      The attribute name for the internal edge index. Additionally to the edge index the internal id of the edge within the pattern graph is saved in the target graph. Beware: The internal id may be different from the edge index, as the id is automatically generated during constrution of the pattern graph!
      See Also:
      Constant Field Values
  • Constructor Details

    • PatternAttributeUtils

      public PatternAttributeUtils()
  • Method Details

    • checkExistenceAGNWContainer

      public static boolean checkExistenceAGNWContainer​(Graph g)
      Checks, if the top level container attribute "AGNW" exists at the given graph.
      Parameters:
      g - a graph
      Returns:
      true, if the attribute exists
    • checkExistenceAGNWContainer

      public static boolean checkExistenceAGNWContainer​(Node n)
      Checks, if the top level container attribute "AGNW" exists at the given node.
      Parameters:
      n - a node
      Returns:
      true, if the attribute exists
    • checkExistenceAGNWContainer

      public static boolean checkExistenceAGNWContainer​(Edge e)
      Checks, if the top level container attribute "AGNW" exists at the given edge.
      Parameters:
      e - an edge
      Returns:
      true, if the attribute exists
    • checkExistencePatternContainer

      public static boolean checkExistencePatternContainer​(Graph g)
      Checks, if the pattern container attribute "AGNW.PATTERN" exists at the given graph.
      Parameters:
      g - a graph
      Returns:
      true, if the attribute exists
    • checkExistencePatternContainer

      public static boolean checkExistencePatternContainer​(Node n)
      Checks, if the pattern container attribute "AGNW.PATTERN" exists at the given node.
      Parameters:
      n - a node
      Returns:
      true, if the attribute exists
    • checkExistencePatternContainer

      public static boolean checkExistencePatternContainer​(Edge e)
      Checks, if the pattern container attribute "AGNW.PATTERN" exists at the given edge.
      Parameters:
      e - an edge
      Returns:
      true, if the attribute exists
    • checkExistencePattern

      public static boolean checkExistencePattern​(Node n, int position)
      Checks, if the pattern container for the pattern position exists at the given node.
      Parameters:
      n - a node
      position - the position
      Returns:
      true, if the attribute exists.
    • checkExistencePattern

      public static boolean checkExistencePattern​(Edge e, int position)
      Checks, if the pattern container for the pattern position exists at the given edge.
      Parameters:
      e - an edge
      position - the position
      Returns:
      true, if the attribute exists.
    • addAGNWContainer

      public static void addAGNWContainer​(Graph g)
      Adds the top level container attribute "AGNW" to the given graph.
      Parameters:
      g - a graph
    • addAGNWContainer

      public static void addAGNWContainer​(Node n)
      Adds the top level container attribute "AGNW" to the given node.
      Parameters:
      n - a node
    • addAGNWContainer

      public static void addAGNWContainer​(Edge e)
      Adds the top level container attribute "AGNW" to the given edge.
      Parameters:
      e - an edge
    • addPatternContainer

      public static void addPatternContainer​(Graph g)
      Adds the pattern container attribute "AGNW.PATTERN" to the given graph.
      Parameters:
      g - a graph
    • addPatternContainer

      public static void addPatternContainer​(Node n)
      Adds the pattern container attribute "AGNW.PATTERN" to the given node.
      Parameters:
      n - a node
    • addPatternContainer

      public static void addPatternContainer​(Edge e)
      Adds the pattern container attribute "AGNW.PATTERN" to the given edge.
      Parameters:
      e - an edge
    • addPattern

      public static void addPattern​(Node n, int position)
      Adds the pattern container for the given pattern position at the given node.
      Parameters:
      n - a node
      position - the position
    • addPattern

      public static void addPattern​(Edge e, int position)
      Adds the pattern container for the given pattern position at the given edge.
      Parameters:
      e - an edge
      position - the position
    • checkAndAddAGNWContainer

      public static void checkAndAddAGNWContainer​(Graph g)
      Adds the top level container attribute "AGNW" to the given graph, if it is not already there.
      Parameters:
      g - a graph
    • checkAndAddAGNWContainer

      public static void checkAndAddAGNWContainer​(Node n)
      Adds the top level container attribute "AGNW" to the given node, if it is not already there.
      Parameters:
      n - a node
    • checkAndAddAGNWContainer

      public static void checkAndAddAGNWContainer​(Edge e)
      Adds the top level container attribute "AGNW" to the given edge, if it is not already there.
      Parameters:
      e - an edge
    • checkAndAddPatternContainer

      public static void checkAndAddPatternContainer​(Graph g)
      Adds the pattern container attribute "AGNW.PATTERN" to the given graph, if it is not already there.
      Parameters:
      g - a graph
    • checkAndAddPatternContainer

      public static void checkAndAddPatternContainer​(Node n)
      Adds the pattern container attribute "AGNW.PATTERN" to the given node, if it is not already there.
      Parameters:
      n - a node
    • checkAndAddPatternContainer

      public static void checkAndAddPatternContainer​(Edge e)
      Adds the pattern container attribute "AGNW.PATTERN" to the given edge, if it is not already there.
      Parameters:
      e - an edge
    • checkAndAddPattern

      public static void checkAndAddPattern​(Node n, int position)
      Adds the pattern container for the pattern position to the given node, if it is not already there.
      Parameters:
      n - a node
      position - the position
    • checkAndAddPattern

      public static void checkAndAddPattern​(Edge e, int position)
      Adds the pattern container for the pattern position to the given edge, if it is not already there.
      Parameters:
      e - an edge
      position - the position
    • getPatternName

      public static String getPatternName​(Node n, int position)
      Returns the pattern name for the given node and position.
      Parameters:
      n - a node
      position - the position
      Returns:
      the pattern name
    • getPatternName

      public static String getPatternName​(Edge e, int position)
      Returns the pattern name for the given edge and position.
      Parameters:
      e - an edge
      position - the position
      Returns:
      the pattern name
    • getPatternIndex

      public static Integer getPatternIndex​(Node n, int position)
      Returns the pattern index for the given node and position.
      Parameters:
      n - a node
      position - the position
      Returns:
      the pattern index
    • getPatternIndex

      public static Integer getPatternIndex​(Edge e, int position)
      Returns the pattern index for the given edge and position.
      Parameters:
      e - an edge
      position - the position
      Returns:
      the pattern index
    • getNodeIndex

      public static Integer getNodeIndex​(Node n, int position)
      Returns the node index for the given node and position.
      Parameters:
      n - a node
      position - the position
      Returns:
      the node index
    • getEdgeIndex

      public static Integer getEdgeIndex​(Edge e, int position)
      Returns the edge index for the given edge and position.
      Parameters:
      e - an edge
      position - the position
      Returns:
      the edge index
    • getInternalNodeIndex

      public static Integer getInternalNodeIndex​(Node n, int position)
      Returns the internal node index for the given node and position.
      Parameters:
      n - a node
      position - the position
      Returns:
      the node index
    • getInternalEdgeIndex

      public static Integer getInternalEdgeIndex​(Edge e, int position)
      Returns the internal edge index for the given edge and position.
      Parameters:
      e - an edge
      position - the position
      Returns:
      the edge index
    • addPatternInformation

      public static void addPatternInformation​(Node n, int position, String patternName, Integer patternIndex, Integer nodeIndex, Node patternNode)
      Adds a set of pattern information to the given node.
      Parameters:
      n - a node
      position - the position
      patternName - the name of pattern
      patternIndex - the occurance of this pattern in the graph
      nodeIndex - the number of node of this pattern occurance
      patternNode - the matched node from the pattern graph
    • addPatternInformation

      public static void addPatternInformation​(Edge e, int position, String patternName, Integer patternIndex, Integer edgeIndex)
      Adds a set of pattern information to the given edge.
      Parameters:
      e - an edge
      position - the position
      patternName - the name of pattern
      patternIndex - the occurance of this pattern in the graph
      edgeIndex - the number of the edge of this pattern occurance
    • getMaximumPatternPosition

      public static int getMaximumPatternPosition​(Node n)
      Returns the maximal position value of the pattern container.
      Parameters:
      n - a node
      Returns:
      returns the maximal value or zero, if no pattern exists.
    • getMaximumPatternPosition

      public static int getMaximumPatternPosition​(Edge e)
      Returns the maximal position value of the pattern container.
      Parameters:
      e - an edge
      Returns:
      returns the maximal value or zero, if no pattern exists.
    • checkExistenceOfAnyPattern

      public static boolean checkExistenceOfAnyPattern​(Node n)
      Checks if a pattern exists at the given node.
      Parameters:
      n - a node
      Returns:
      true, if at least one pattern exists, false otherwise
    • checkExistenceOfAnyPattern

      public static boolean checkExistenceOfAnyPattern​(Edge e)
      Checks if a pattern exists at the given edge.
      Parameters:
      e - an edge
      Returns:
      true, if at least one pattern exists, false otherwise
    • findPatternPosition

      public static int findPatternPosition​(Node n, String patternName, Integer patternIndex)
      Returns the position of the given pattern name and pattern index for the given node.
      Parameters:
      n - a node
      patternName - the pattern name
      patternIndex - the pattern index
      Returns:
      the position or zero, if the pattern name and index combination does not exists
    • findPatternPosition

      public static int findPatternPosition​(Edge e, String patternName, Integer patternIndex)
      Returns the position of the given pattern name and pattern index for the given edge.
      Parameters:
      e - an edge
      patternName - the pattern name
      patternIndex - the pattern index
      Returns:
      the position or zero, if the pattern name and index combination does not exists
    • getMinAddIncEdges

      public static int getMinAddIncEdges​(Node n)
      Returns the minimal value for the additional incoming edges.
      Parameters:
      n - a node
      Returns:
      the minimal value for additional incoming edges
    • getMaxAddIncEdges

      public static int getMaxAddIncEdges​(Node n)
      Returns the maximal value for the additional incoming edges.
      Parameters:
      n - a node
      Returns:
      the maximal value for additional incoming edges
    • getMinAddOutEdges

      public static int getMinAddOutEdges​(Node n)
      Returns the minimal value for the additional outgoing edges.
      Parameters:
      n - a node
      Returns:
      the minimal value for additional outgoing edges
    • getMaxAddOutEdges

      public static int getMaxAddOutEdges​(Node n)
      Returns the maximal value for the additional outgoing edges.
      Parameters:
      n - a node
      Returns:
      the maximal value for additional outgoing edges