Class EfficientTreeImpl
- java.lang.Object
-
- org.processmining.plugins.InductiveMiner.efficienttree.EfficientTreeImpl
-
- All Implemented Interfaces:
java.lang.Cloneable,EfficientTree
public class EfficientTreeImpl extends java.lang.Object implements EfficientTree
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.processmining.plugins.InductiveMiner.efficienttree.EfficientTree
EfficientTree.NodeType
-
-
Field Summary
Fields Modifier and Type Field Description static intchildrenFactor
-
Constructor Summary
Constructors Constructor Description EfficientTreeImpl(int[] tree, gnu.trove.map.TObjectIntMap<java.lang.String> activity2int, java.lang.String[] int2activity)Construct a new efficient tree using the given inputs.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voidaddChild(int parent, int asChildNr, int operatorOrActivity)Add a child to the tree, as a child of parent, at the given position.EfficientTreeclone()voidcopy(int srcPos, int destPos, int length)Please refer to EfficientTreeUtils for higher-level editing functions.booleanequals(java.lang.Object obj)intgetActivity(int node)gnu.trove.map.TObjectIntMap<java.lang.String>getActivity2int()java.lang.StringgetActivityName(int node)intgetChild(int parent, int numberOfChild)java.lang.Iterable<java.lang.Integer>getChildren(int node)int[]getChildTree(int node)Deprecated.static gnu.trove.map.TObjectIntMap<java.lang.String>getEmptyActivity2int()java.lang.String[]getInt2activity()intgetMaxNumberOfNodes()EfficientTree.NodeTypegetNodeType(int node)intgetNumberOfChildren(int node)intgetRoot()int[]getTree()inthashCode()booleanisActivity(int node)booleanisConcurrent(int node)booleanisInterleaved(int node)booleanisLoop(int node)booleanisOperator(int node)booleanisOr(int node)booleanisSequence(int node)booleanisSkip(int node)booleanisTau(int node)booleanisXor(int node)voidreorderNodes(java.lang.Integer[] nodes, int end)Please refer to EfficientTreeUtils for higher-level editing functions.voidreplaceTree(int[] tree)Replace the tree structure.voidsetNodeActivity(int node, int activity)Please refer to EfficientTreeUtils for higher-level editing functions.voidsetNodeType(int node, EfficientTree.NodeType operator)Please refer to EfficientTreeUtils for higher-level editing functions.voidsetNumberOfChildren(int node, int numberOfChildren)Please refer to EfficientTreeUtils for higher-level editing functions.voidsetSize(int size)Please refer to EfficientTreeUtils for higher-level editing functions.EfficientTreeImplshortenTree()Copy the tree into a tight arrayvoidswap(int startA, int startB, int lengthB)Please refer to EfficientTreeUtils for higher-level editing functions.java.lang.StringtoString()Return a string representation of this tree.voidtoString(int node, java.lang.StringBuilder result)inttraverse(int node)
-
-
-
Field Detail
-
childrenFactor
public static final int childrenFactor
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
EfficientTreeImpl
public EfficientTreeImpl(int[] tree, gnu.trove.map.TObjectIntMap<java.lang.String> activity2int, java.lang.String[] int2activity)Construct a new efficient tree using the given inputs. These inputs will not be copied and should not be altered outside the EfficientTree context after creating the tree.- Parameters:
tree-activity2int- The mapping from activities (strings) to integers. The map should be created such that the emptiness value is not 0 (as that is a valid activity). Preferably, use getEmptyActivity2int() to obtain such a map.int2activity- The mapping from integers to the activities (strings). Should be consistent with activity2int.
-
-
Method Detail
-
getTree
public int[] getTree()
- Specified by:
getTreein interfaceEfficientTree- Returns:
- the internal representation of the process tree. Do not edit the returned object.
-
getActivity2int
public gnu.trove.map.TObjectIntMap<java.lang.String> getActivity2int()
- Specified by:
getActivity2intin interfaceEfficientTree- Returns:
- A map from activity to index
-
getInt2activity
public java.lang.String[] getInt2activity()
- Specified by:
getInt2activityin interfaceEfficientTree- Returns:
- A map from index (not node!) to activity.
-
addChild
public void addChild(int parent, int asChildNr, int operatorOrActivity)Add a child to the tree, as a child of parent, at the given position. The caller has to ensure there's enough space in the array of the tree.- Parameters:
parent-asChildNr-
-
traverse
public int traverse(int node)
- Specified by:
traversein interfaceEfficientTree- Returns:
- the first node after node i.
-
getActivity
public int getActivity(int node)
- Specified by:
getActivityin interfaceEfficientTree- Returns:
- the activity number denoted at position node. Only call if the node is an activity.
-
getActivityName
public java.lang.String getActivityName(int node)
- Specified by:
getActivityNamein interfaceEfficientTree- Returns:
- the activity name denoted at position node. Only call if the node is an activity.
-
isOperator
public boolean isOperator(int node)
- Specified by:
isOperatorin interfaceEfficientTree- Returns:
- whether the node at position i is an operator
-
getNumberOfChildren
public int getNumberOfChildren(int node)
- Specified by:
getNumberOfChildrenin interfaceEfficientTree- Returns:
- the number of children of the current node. Only call when the node is an operator.
-
getChild
public int getChild(int parent, int numberOfChild)- Specified by:
getChildin interfaceEfficientTreenumberOfChild- (the first child has number 0)- Returns:
- the position of the #nrOfChild child of parent.
-
isTau
public boolean isTau(int node)
- Specified by:
isTauin interfaceEfficientTree- Returns:
- whether the given node is a tau
-
isActivity
public boolean isActivity(int node)
- Specified by:
isActivityin interfaceEfficientTree- Returns:
- whether the given node is an activity
-
isSequence
public boolean isSequence(int node)
- Specified by:
isSequencein interfaceEfficientTree- Returns:
- whether the given node is a sequence
-
isXor
public boolean isXor(int node)
- Specified by:
isXorin interfaceEfficientTree- Returns:
- whether the given node is a xor
-
isConcurrent
public boolean isConcurrent(int node)
- Specified by:
isConcurrentin interfaceEfficientTree- Returns:
- whether the given node is an and
-
isInterleaved
public boolean isInterleaved(int node)
- Specified by:
isInterleavedin interfaceEfficientTree- Returns:
- whether the given node is an interleaved node
-
isLoop
public boolean isLoop(int node)
- Specified by:
isLoopin interfaceEfficientTree- Returns:
- whether the given node is a loop
-
isOr
public boolean isOr(int node)
- Specified by:
isOrin interfaceEfficientTree- Returns:
- whether the given node is an or
-
getRoot
public int getRoot()
- Specified by:
getRootin interfaceEfficientTree- Returns:
- The index of the root of the tree.
-
getChildren
public java.lang.Iterable<java.lang.Integer> getChildren(int node)
- Specified by:
getChildrenin interfaceEfficientTree- Returns:
- an iterable over all children of the given node.
-
shortenTree
public EfficientTreeImpl shortenTree()
Copy the tree into a tight array
-
isSkip
public boolean isSkip(int node)
- Specified by:
isSkipin interfaceEfficientTree- Returns:
- whether the given node is not a semantic node (doesn't exist)
-
getChildTree
@Deprecated public int[] getChildTree(int node)
Deprecated.
-
getEmptyActivity2int
public static gnu.trove.map.TObjectIntMap<java.lang.String> getEmptyActivity2int()
-
replaceTree
public void replaceTree(int[] tree)
Replace the tree structure.- Parameters:
tree-
-
toString
public java.lang.String toString()
Return a string representation of this tree. This string representation is not unique for equivalent trees, e.g. the trees xor(a, b) and xor(b, a) are equivalent, but do not have the same string representation.- Overrides:
toStringin classjava.lang.Object
-
toString
public void toString(int node, java.lang.StringBuilder result) throws UnknownTreeNodeException- Throws:
UnknownTreeNodeException
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equalsin classjava.lang.Object
-
clone
public EfficientTree clone()
- Specified by:
clonein interfaceEfficientTree- Overrides:
clonein classjava.lang.Object
-
getNodeType
public EfficientTree.NodeType getNodeType(int node)
- Specified by:
getNodeTypein interfaceEfficientTree- Returns:
- the type of operator. Only call if the node is an operator.
-
getMaxNumberOfNodes
public int getMaxNumberOfNodes()
- Specified by:
getMaxNumberOfNodesin interfaceEfficientTree- Returns:
- a number that is larger or equal to the number of nodes in the tree.
-
copy
public void copy(int srcPos, int destPos, int length)Description copied from interface:EfficientTreePlease refer to EfficientTreeUtils for higher-level editing functions. The usage of this method is not encouraged. Copies nodes in the tree, overwriting the nodes at the destination. It is the responsibility of the caller to ensure there is enough space in the tree, and to ensure the tree remains consistent.- Specified by:
copyin interfaceEfficientTree- Parameters:
srcPos- start of the block - sourcedestPos- start of the block - destinationlength- number of nodes to be moved
-
setNodeType
public void setNodeType(int node, EfficientTree.NodeType operator)Description copied from interface:EfficientTreePlease refer to EfficientTreeUtils for higher-level editing functions. The usage of this method is not encouraged. Sets the type of a node. It is the responsibility of the caller to ensure that no non-operator is changed into/from an operator, as this might have unexpected consequences.- Specified by:
setNodeTypein interfaceEfficientTree
-
setNodeActivity
public void setNodeActivity(int node, int activity)Description copied from interface:EfficientTreePlease refer to EfficientTreeUtils for higher-level editing functions. The usage of this method is not encouraged.- Specified by:
setNodeActivityin interfaceEfficientTree
-
setNumberOfChildren
public void setNumberOfChildren(int node, int numberOfChildren)Description copied from interface:EfficientTreePlease refer to EfficientTreeUtils for higher-level editing functions. The usage of this method is not encouraged. Sets the number of children of a node. It is the responsibility of the caller to ensure the tree remains consistent.- Specified by:
setNumberOfChildrenin interfaceEfficientTree
-
setSize
public void setSize(int size)
Description copied from interface:EfficientTreePlease refer to EfficientTreeUtils for higher-level editing functions. The usage of this method is not encouraged. Set the size as given. Adds skip nodes if necessary.- Specified by:
setSizein interfaceEfficientTree
-
swap
public void swap(int startA, int startB, int lengthB)Description copied from interface:EfficientTreePlease refer to EfficientTreeUtils for higher-level editing functions. The usage of this method is not encouraged. Swap two consecutive children in a tree.- Specified by:
swapin interfaceEfficientTree
-
reorderNodes
public void reorderNodes(java.lang.Integer[] nodes, int end)Description copied from interface:EfficientTreePlease refer to EfficientTreeUtils for higher-level editing functions. The usage of this method is not encouraged. Reorders nodes- Specified by:
reorderNodesin interfaceEfficientTree- Parameters:
nodes- A consecutive but possibly shuffled list of indices, in which to reorder nodes.end- The index after the end of the last node.
-
-