public class InternalHeapConfiguration extends Object implements HeapConfiguration, Graph
An implementation of HeapConfiguration based on bipartite graphs, which are implemented in
LabeledDigraph.
In addition to HeapConfiguration, this class also implements Graph, such that graph morphisms between
InternalHeapConfigurations can be computed. See also de.rwth.i2.attestor.graph.morphism.
In an InternalHeapConfiguration, nodes, nonterminal edges and variable edges are represented by nodes in a
LabeledDigraph that are distinguished by their node label. Furthermore, selector edges
and tentacles between (nonterminal or variable) hyperedges are represented by
edges in a LabeledDigraph. Consequently, each selector edge is labeled with a SelectorLabel and
each tentacle is labeled with an int value that represents the tentacles position in the sequence of nodes
attached to a hyperedge.
To be more precise:
Type. All incoming and outgoing edges in the underlying LabeledDigraph correspond
to selector edges. For each SelectorLabel there is at most one outgoing selector edge for each node.
In contrast, a node may have an arbitrary number of incoming selector edges.
Nonterminal.
In the underlying LabeledDigraph a nonterminal edge containsSubsumingState no incoming edges.
Moreover, a nonterminal edge with Nonterminal.getRank() equals to k containsSubsumingState exactly k
outgoing edges in the underlying LabeledDigraph that correspond to its tentacles.
Thus, these outgoing edges are labeled with integers 0,1,...,k-1, respectively.
The target of an outgoing edge labeled with i then corresponds to the i-th node attached to the
nonterminal edge.
that are labeled with integer values 0,1,...,k-1, respectively.
In this setting an edge labeled with i denotes the i-th tentacle of a nonterminal edge.
Variable.
In the underlying LabeledDigraph a variable edge containsSubsumingState no incoming edges.
Moreover, each variable edge has exactly one outgoing edge in the underlying LabeledDigraph
whose target is the unique node corresponding to the value of the variable.
This unique outgoing edge is always labeled with the integer value 0.
The LabeledDigraph underlying an immutable InternalHeapConfiguration is kept compact.
This means that LabeledDigraph.size() equals the number of nodes, nonterminal edges and variable edges.
To this end any call to InternalHeapConfigurationBuilder.build() may swap around elements to remove gaps
caused by deleting elements of a HeapConfiguration.
Since swapping elements changes their identifiers, InternalHeapConfiguration distinguishes between public
and private identifiers:
HeapConfiguration.
In contrast, all methodExecution provided by Graph directly use private identifiers to avoid translating
between public and private identifiers
when computing graph morphisms.
HeapConfiguration always take public identifiers as parameters and return
public identifiers.
Hence, as long as a client uses only methodExecution provided by HeapConfiguration, all identifiers are public.
InternalHeapConfiguration provides the methodExecution getPrivateId(int)
and getPublicId(int)
to translate a public identifier into a private identifier and a private identifier into a public identifier,
respectively.
INVALID_ELEMENT| Constructor and Description |
|---|
InternalHeapConfiguration()
Sets up an empty InternalHeapConfiguration.
|
| Modifier and Type | Method and Description |
|---|---|
gnu.trove.list.array.TIntArrayList |
attachedNodesOf(int ntEdge) |
gnu.trove.list.array.TIntArrayList |
attachedNonterminalEdgesOf(int node) |
gnu.trove.map.TIntIntMap |
attachedNonterminalEdgesWithNonReductionTentacle(int node) |
gnu.trove.list.array.TIntArrayList |
attachedVariablesOf(int node) |
HeapConfigurationBuilder |
builder()
Mark a HeapConfiguration as temporarily mutable by a
HeapConfigurationBuilder. |
HeapConfiguration |
clone() |
int |
countExternalNodes() |
int |
countNodes() |
int |
countNonterminalEdges() |
int |
countVariableEdges() |
boolean |
equals(Object otherObject) |
int |
externalIndexOf(int node) |
int |
externalNodeAt(int pos) |
gnu.trove.list.array.TIntArrayList |
externalNodes() |
List<Object> |
getEdgeLabel(int privateIdFrom,
int privateIdTo)
This method directly access the
LabeledDigraph
underlying an InternalHeapConfiguration through private IDs. |
AbstractMatchingChecker |
getEmbeddingsOf(HeapConfiguration pattern,
MorphismOptions morphismOptions)
Returns an AbstractMatchingChecker to search for all occurrences of the given pattern HeapConfiguration
in this HeapConfiguration (the target).
|
HeapConfiguration |
getEmpty() |
int |
getExternalIndex(int privateNodeId)
This method directly access the
LabeledDigraph
underlying an InternalHeapConfiguration through private IDs. |
NodeLabel |
getNodeLabel(int privateNodeId)
This method directly access the
LabeledDigraph
underlying an InternalHeapConfiguration through private IDs. |
gnu.trove.list.array.TIntArrayList |
getPredecessorsOf(int privateNodeId)
This method directly access the
LabeledDigraph
underlying an InternalHeapConfiguration through private IDs. |
gnu.trove.list.array.TIntArrayList |
getSuccessorsOf(int privateNodeId)
This method directly access the
LabeledDigraph
underlying an InternalHeapConfiguration through private IDs. |
boolean |
hasEdge(int privateIdFrom,
int privateIdTo)
This method directly access the
LabeledDigraph
underlying an InternalHeapConfiguration through private IDs. |
int |
hashCode() |
boolean |
isEdgeBetweenMarkedNodes(int from,
int to) |
boolean |
isExternal(int privateNodeId)
This method directly access the
LabeledDigraph
underlying an InternalHeapConfiguration through private IDs. |
boolean |
isExternalNode(int node) |
Nonterminal |
labelOf(int ntEdge) |
String |
nameOf(int varEdge) |
gnu.trove.list.array.TIntArrayList |
nodes() |
Type |
nodeTypeOf(int node) |
gnu.trove.list.array.TIntArrayList |
nonterminalEdges() |
gnu.trove.list.array.TIntArrayList |
predecessorNodesOf(int node) |
int |
rankOf(int ntEdge) |
List<SelectorLabel> |
selectorLabelsOf(int node) |
int |
selectorTargetOf(int node,
SelectorLabel sel) |
int |
size() |
gnu.trove.list.array.TIntArrayList |
successorNodesOf(int node) |
int |
targetOf(int varEdge) |
String |
toString() |
gnu.trove.list.array.TIntArrayList |
variableEdges() |
int |
variableTargetOf(String variableName) |
int |
variableWith(String name) |
public InternalHeapConfiguration()
public HeapConfiguration clone()
clone in interface HeapConfigurationclone in class Objectpublic HeapConfiguration getEmpty()
getEmpty in interface HeapConfigurationpublic HeapConfigurationBuilder builder()
HeapConfigurationHeapConfigurationBuilder.
The HeapConfiguration stays mutable until HeapConfigurationBuilder.build() is called.
For each HeapConfiguration, there is either no builder (immutable) or exactly one builder (mutable).builder in interface HeapConfigurationpublic int countNodes()
countNodes in interface HeapConfigurationpublic gnu.trove.list.array.TIntArrayList nodes()
nodes in interface HeapConfigurationpublic Type nodeTypeOf(int node)
nodeTypeOf in interface HeapConfigurationnode - A node contained in the HeapConfiguration.public gnu.trove.list.array.TIntArrayList attachedVariablesOf(int node)
attachedVariablesOf in interface HeapConfigurationnode - A node contained in the HeapConfiguration.public gnu.trove.list.array.TIntArrayList attachedNonterminalEdgesOf(int node)
attachedNonterminalEdgesOf in interface HeapConfigurationnode - A node contained in the HeapConfiguration.public gnu.trove.list.array.TIntArrayList successorNodesOf(int node)
successorNodesOf in interface HeapConfigurationnode - A node contained in the HeapConfiguration.public gnu.trove.list.array.TIntArrayList predecessorNodesOf(int node)
predecessorNodesOf in interface HeapConfigurationnode - A node contained in the HeapConfiguration.public List<SelectorLabel> selectorLabelsOf(int node)
selectorLabelsOf in interface HeapConfigurationnode - A node contained in the HeapConfiguration.public int selectorTargetOf(int node,
SelectorLabel sel)
selectorTargetOf in interface HeapConfigurationnode - A node contained in the HeapConfiguration.sel - A SelectorLabel that occurs as an edge label for the given node.public int countExternalNodes()
countExternalNodes in interface HeapConfigurationpublic gnu.trove.list.array.TIntArrayList externalNodes()
externalNodes in interface HeapConfigurationpublic int externalNodeAt(int pos)
externalNodeAt in interface HeapConfigurationpos - An index of an external node satisfying 0 <= pos && pos <= countExternalNodes().public boolean isExternalNode(int node)
isExternalNode in interface HeapConfigurationnode - A node in the HeapConfiguration.public int externalIndexOf(int node)
externalIndexOf in interface HeapConfigurationnode - A node in the HeapConfiguration.public int countNonterminalEdges()
countNonterminalEdges in interface HeapConfigurationpublic gnu.trove.list.array.TIntArrayList nonterminalEdges()
nonterminalEdges in interface HeapConfigurationpublic int rankOf(int ntEdge)
rankOf in interface HeapConfigurationntEdge - A nonterminal edge in this HeapConfiguration.public Nonterminal labelOf(int ntEdge)
labelOf in interface HeapConfigurationntEdge - A nonterminal edge in this HeapConfiguration.public gnu.trove.list.array.TIntArrayList attachedNodesOf(int ntEdge)
attachedNodesOf in interface HeapConfigurationntEdge - A nonterminal edge in this HeapConfiguration.public int countVariableEdges()
countVariableEdges in interface HeapConfigurationpublic gnu.trove.list.array.TIntArrayList variableEdges()
variableEdges in interface HeapConfigurationpublic int variableWith(String name)
variableWith in interface HeapConfigurationname - The name of the requested variableHeapConfiguration.INVALID_ELEMENT.public String nameOf(int varEdge)
nameOf in interface HeapConfigurationvarEdge - A variable edge in this HeapConfiguration.public int targetOf(int varEdge)
targetOf in interface HeapConfigurationvarEdge - A variable edge in this HeapConfiguration.public AbstractMatchingChecker getEmbeddingsOf(HeapConfiguration pattern, MorphismOptions morphismOptions)
HeapConfigurationgetEmbeddingsOf in interface HeapConfigurationpattern - The HeapConfiguration to search for.morphismOptions - Options guiding how embeddings are computed.public int variableTargetOf(String variableName)
variableTargetOf in interface HeapConfigurationvariableName - The name of the requested variable.public gnu.trove.map.TIntIntMap attachedNonterminalEdgesWithNonReductionTentacle(int node)
attachedNonterminalEdgesWithNonReductionTentacle in interface HeapConfigurationnode - A node in the graph.public int size()
public boolean hasEdge(int privateIdFrom,
int privateIdTo)
LabeledDigraph
underlying an InternalHeapConfiguration through private IDs.
It should thus only be used if it can be guaranteed that a HeapConfiguration is immutable.
That is, HeapConfiguration.builder() is null.public gnu.trove.list.array.TIntArrayList getSuccessorsOf(int privateNodeId)
LabeledDigraph
underlying an InternalHeapConfiguration through private IDs.
It should thus only be used if it can be guaranteed that a HeapConfiguration is immutable.
That is, HeapConfiguration.builder() is null.getSuccessorsOf in interface GraphprivateNodeId - The source node whose successor nodes are requested.public gnu.trove.list.array.TIntArrayList getPredecessorsOf(int privateNodeId)
LabeledDigraph
underlying an InternalHeapConfiguration through private IDs.
It should thus only be used if it can be guaranteed that a HeapConfiguration is immutable.
That is, HeapConfiguration.builder() is null.getPredecessorsOf in interface GraphprivateNodeId - The target node whose predecessor nodes are requested.public NodeLabel getNodeLabel(int privateNodeId)
LabeledDigraph
underlying an InternalHeapConfiguration through private IDs.
It should thus only be used if it can be guaranteed that a HeapConfiguration is immutable.
That is, HeapConfiguration.builder() is null.getNodeLabel in interface GraphprivateNodeId - The node whose label is requested.public List<Object> getEdgeLabel(int privateIdFrom, int privateIdTo)
LabeledDigraph
underlying an InternalHeapConfiguration through private IDs.
It should thus only be used if it can be guaranteed that a HeapConfiguration is immutable.
That is, HeapConfiguration.builder() is null.getEdgeLabel in interface GraphprivateIdFrom - The source node.privateIdTo - The target node.public int getExternalIndex(int privateNodeId)
LabeledDigraph
underlying an InternalHeapConfiguration through private IDs.
It should thus only be used if it can be guaranteed that a HeapConfiguration is immutable.
That is, HeapConfiguration.builder() is null.getExternalIndex in interface GraphprivateNodeId - An external node.public boolean isEdgeBetweenMarkedNodes(int from,
int to)
isEdgeBetweenMarkedNodes in interface Graphpublic boolean isExternal(int privateNodeId)
LabeledDigraph
underlying an InternalHeapConfiguration through private IDs.
It should thus only be used if it can be guaranteed that a HeapConfiguration is immutable.
That is, HeapConfiguration.builder() is null.isExternal in interface GraphprivateNodeId - The node that should be checked.Copyright © 2019. All rights reserved.