Class PatternAttributeUtils
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 Summary
Fields Modifier and Type Field Description static String
EDGE_INDEX
The attribute name for the edge index.static String
INTERNAL_EDGE_INDEX
The attribute name for the internal edge index.static String
INTERNAL_NODE_INDEX
The attribute name for the internal node index.static String
MAX_ADD_INC_EDGES_PATH
Path to the attribute for the maximal value of additional incoming edges.static String
MAX_ADD_OUT_EDGES_PATH
Path to the attribute for the maximal value of additional outgoing edges.static String
MIN_ADD_INC_EDGES_PATH
Path to the attribute for the minimal value of additional incoming edges.static String
MIN_ADD_OUT_EDGES_PATH
Path to the attribute for the minimal value of additional outgoing edges.static String
NODE_INDEX
The attribute name for the node index.static String
PATTERN_INDEX
The attribute name for the pattern index.static String
PATTERN_NAME
The attribute name for the pattern name.static String
PATTERN_PATH
The container for all pattern attributes.static String
PATTERN_RECORD_PREFIX
The prefix of the attribute name for the pattern record. -
Constructor Summary
Constructors Constructor Description PatternAttributeUtils()
-
Method Summary
Modifier and Type Method Description static void
addAGNWContainer(Edge e)
Adds the top level container attribute "AGNW" to the given edge.static void
addAGNWContainer(Graph g)
Adds the top level container attribute "AGNW" to the given graph.static void
addAGNWContainer(Node n)
Adds the top level container attribute "AGNW" to the given node.static void
addPattern(Edge e, int position)
Adds the pattern container for the given pattern position at the given edge.static void
addPattern(Node n, int position)
Adds the pattern container for the given pattern position at the given node.static void
addPatternContainer(Edge e)
Adds the pattern container attribute "AGNW.PATTERN" to the given edge.static void
addPatternContainer(Graph g)
Adds the pattern container attribute "AGNW.PATTERN" to the given graph.static void
addPatternContainer(Node n)
Adds the pattern container attribute "AGNW.PATTERN" to the given node.static void
addPatternInformation(Edge e, int position, String patternName, Integer patternIndex, Integer edgeIndex)
Adds a set of pattern information to the given edge.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.static void
checkAndAddAGNWContainer(Edge e)
Adds the top level container attribute "AGNW" to the given edge, if it is not already there.static void
checkAndAddAGNWContainer(Graph g)
Adds the top level container attribute "AGNW" to the given graph, if it is not already there.static void
checkAndAddAGNWContainer(Node n)
Adds the top level container attribute "AGNW" to the given node, if it is not already there.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.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.static void
checkAndAddPatternContainer(Edge e)
Adds the pattern container attribute "AGNW.PATTERN" to the given edge, if it is not already there.static void
checkAndAddPatternContainer(Graph g)
Adds the pattern container attribute "AGNW.PATTERN" to the given graph, if it is not already there.static void
checkAndAddPatternContainer(Node n)
Adds the pattern container attribute "AGNW.PATTERN" to the given node, if it is not already there.static boolean
checkExistenceAGNWContainer(Edge e)
Checks, if the top level container attribute "AGNW" exists at the given edge.static boolean
checkExistenceAGNWContainer(Graph g)
Checks, if the top level container attribute "AGNW" exists at the given graph.static boolean
checkExistenceAGNWContainer(Node n)
Checks, if the top level container attribute "AGNW" exists at the given node.static boolean
checkExistenceOfAnyPattern(Edge e)
Checks if a pattern exists at the given edge.static boolean
checkExistenceOfAnyPattern(Node n)
Checks if a pattern exists at the given node.static boolean
checkExistencePattern(Edge e, int position)
Checks, if the pattern container for the pattern position exists at the given edge.static boolean
checkExistencePattern(Node n, int position)
Checks, if the pattern container for the pattern position exists at the given node.static boolean
checkExistencePatternContainer(Edge e)
Checks, if the pattern container attribute "AGNW.PATTERN" exists at the given edge.static boolean
checkExistencePatternContainer(Graph g)
Checks, if the pattern container attribute "AGNW.PATTERN" exists at the given graph.static boolean
checkExistencePatternContainer(Node n)
Checks, if the pattern container attribute "AGNW.PATTERN" exists at the given node.static int
findPatternPosition(Edge e, String patternName, Integer patternIndex)
Returns the position of the given pattern name and pattern index for the given edge.static int
findPatternPosition(Node n, String patternName, Integer patternIndex)
Returns the position of the given pattern name and pattern index for the given node.static Integer
getEdgeIndex(Edge e, int position)
Returns the edge index for the given edge and position.static Integer
getInternalEdgeIndex(Edge e, int position)
Returns the internal edge index for the given edge and position.static Integer
getInternalNodeIndex(Node n, int position)
Returns the internal node index for the given node and position.static int
getMaxAddIncEdges(Node n)
Returns the maximal value for the additional incoming edges.static int
getMaxAddOutEdges(Node n)
Returns the maximal value for the additional outgoing edges.static int
getMaximumPatternPosition(Edge e)
Returns the maximal position value of the pattern container.static int
getMaximumPatternPosition(Node n)
Returns the maximal position value of the pattern container.static int
getMinAddIncEdges(Node n)
Returns the minimal value for the additional incoming edges.static int
getMinAddOutEdges(Node n)
Returns the minimal value for the additional outgoing edges.static Integer
getNodeIndex(Node n, int position)
Returns the node index for the given node and position.static Integer
getPatternIndex(Edge e, int position)
Returns the pattern index for the given edge and position.static Integer
getPatternIndex(Node n, int position)
Returns the pattern index for the given node and position.static String
getPatternName(Edge e, int position)
Returns the pattern name for the given edge and position.static String
getPatternName(Node n, int position)
Returns the pattern name for the given node and position.
-
Field Details
-
PATTERN_PATH
The container for all pattern attributes.- See Also:
- Constant Field Values
-
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
Path to the attribute for the maximal value of additional incoming edges.- See Also:
- Constant Field Values
-
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
Path to the attribute for the maximal value of additional outgoing edges.- See Also:
- Constant Field Values
-
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
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
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
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
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
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
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
Checks, if the top level container attribute "AGNW" exists at the given graph.- Parameters:
g
- a graph- Returns:
- true, if the attribute exists
-
checkExistenceAGNWContainer
Checks, if the top level container attribute "AGNW" exists at the given node.- Parameters:
n
- a node- Returns:
- true, if the attribute exists
-
checkExistenceAGNWContainer
Checks, if the top level container attribute "AGNW" exists at the given edge.- Parameters:
e
- an edge- Returns:
- true, if the attribute exists
-
checkExistencePatternContainer
Checks, if the pattern container attribute "AGNW.PATTERN" exists at the given graph.- Parameters:
g
- a graph- Returns:
- true, if the attribute exists
-
checkExistencePatternContainer
Checks, if the pattern container attribute "AGNW.PATTERN" exists at the given node.- Parameters:
n
- a node- Returns:
- true, if the attribute exists
-
checkExistencePatternContainer
Checks, if the pattern container attribute "AGNW.PATTERN" exists at the given edge.- Parameters:
e
- an edge- Returns:
- true, if the attribute exists
-
checkExistencePattern
Checks, if the pattern container for the pattern position exists at the given node.- Parameters:
n
- a nodeposition
- the position- Returns:
- true, if the attribute exists.
-
checkExistencePattern
Checks, if the pattern container for the pattern position exists at the given edge.- Parameters:
e
- an edgeposition
- the position- Returns:
- true, if the attribute exists.
-
addAGNWContainer
Adds the top level container attribute "AGNW" to the given graph.- Parameters:
g
- a graph
-
addAGNWContainer
Adds the top level container attribute "AGNW" to the given node.- Parameters:
n
- a node
-
addAGNWContainer
Adds the top level container attribute "AGNW" to the given edge.- Parameters:
e
- an edge
-
addPatternContainer
Adds the pattern container attribute "AGNW.PATTERN" to the given graph.- Parameters:
g
- a graph
-
addPatternContainer
Adds the pattern container attribute "AGNW.PATTERN" to the given node.- Parameters:
n
- a node
-
addPatternContainer
Adds the pattern container attribute "AGNW.PATTERN" to the given edge.- Parameters:
e
- an edge
-
addPattern
Adds the pattern container for the given pattern position at the given node.- Parameters:
n
- a nodeposition
- the position
-
addPattern
Adds the pattern container for the given pattern position at the given edge.- Parameters:
e
- an edgeposition
- the position
-
checkAndAddAGNWContainer
Adds the top level container attribute "AGNW" to the given graph, if it is not already there.- Parameters:
g
- a graph
-
checkAndAddAGNWContainer
Adds the top level container attribute "AGNW" to the given node, if it is not already there.- Parameters:
n
- a node
-
checkAndAddAGNWContainer
Adds the top level container attribute "AGNW" to the given edge, if it is not already there.- Parameters:
e
- an edge
-
checkAndAddPatternContainer
Adds the pattern container attribute "AGNW.PATTERN" to the given graph, if it is not already there.- Parameters:
g
- a graph
-
checkAndAddPatternContainer
Adds the pattern container attribute "AGNW.PATTERN" to the given node, if it is not already there.- Parameters:
n
- a node
-
checkAndAddPatternContainer
Adds the pattern container attribute "AGNW.PATTERN" to the given edge, if it is not already there.- Parameters:
e
- an edge
-
checkAndAddPattern
Adds the pattern container for the pattern position to the given node, if it is not already there.- Parameters:
n
- a nodeposition
- the position
-
checkAndAddPattern
Adds the pattern container for the pattern position to the given edge, if it is not already there.- Parameters:
e
- an edgeposition
- the position
-
getPatternName
Returns the pattern name for the given node and position.- Parameters:
n
- a nodeposition
- the position- Returns:
- the pattern name
-
getPatternName
Returns the pattern name for the given edge and position.- Parameters:
e
- an edgeposition
- the position- Returns:
- the pattern name
-
getPatternIndex
Returns the pattern index for the given node and position.- Parameters:
n
- a nodeposition
- the position- Returns:
- the pattern index
-
getPatternIndex
Returns the pattern index for the given edge and position.- Parameters:
e
- an edgeposition
- the position- Returns:
- the pattern index
-
getNodeIndex
Returns the node index for the given node and position.- Parameters:
n
- a nodeposition
- the position- Returns:
- the node index
-
getEdgeIndex
Returns the edge index for the given edge and position.- Parameters:
e
- an edgeposition
- the position- Returns:
- the edge index
-
getInternalNodeIndex
Returns the internal node index for the given node and position.- Parameters:
n
- a nodeposition
- the position- Returns:
- the node index
-
getInternalEdgeIndex
Returns the internal edge index for the given edge and position.- Parameters:
e
- an edgeposition
- 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 nodeposition
- the positionpatternName
- the name of patternpatternIndex
- the occurance of this pattern in the graphnodeIndex
- the number of node of this pattern occurancepatternNode
- 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 edgeposition
- the positionpatternName
- the name of patternpatternIndex
- the occurance of this pattern in the graphedgeIndex
- the number of the edge of this pattern occurance
-
getMaximumPatternPosition
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
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
Checks if a pattern exists at the given node.- Parameters:
n
- a node- Returns:
- true, if at least one pattern exists, false otherwise
-
checkExistenceOfAnyPattern
Checks if a pattern exists at the given edge.- Parameters:
e
- an edge- Returns:
- true, if at least one pattern exists, false otherwise
-
findPatternPosition
Returns the position of the given pattern name and pattern index for the given node.- Parameters:
n
- a nodepatternName
- the pattern namepatternIndex
- the pattern index- Returns:
- the position or zero, if the pattern name and index combination does not exists
-
findPatternPosition
Returns the position of the given pattern name and pattern index for the given edge.- Parameters:
e
- an edgepatternName
- the pattern namepatternIndex
- the pattern index- Returns:
- the position or zero, if the pattern name and index combination does not exists
-
getMinAddIncEdges
Returns the minimal value for the additional incoming edges.- Parameters:
n
- a node- Returns:
- the minimal value for additional incoming edges
-
getMaxAddIncEdges
Returns the maximal value for the additional incoming edges.- Parameters:
n
- a node- Returns:
- the maximal value for additional incoming edges
-
getMinAddOutEdges
Returns the minimal value for the additional outgoing edges.- Parameters:
n
- a node- Returns:
- the minimal value for additional outgoing edges
-
getMaxAddOutEdges
Returns the maximal value for the additional outgoing edges.- Parameters:
n
- a node- Returns:
- the maximal value for additional outgoing edges
-