public class TreeUtils
extends java.lang.Object
Constructor and Description |
---|
TreeUtils() |
Modifier and Type | Method and Description |
---|---|
static NAryTree |
flatten(NAryTree tree)
Flattens a tree by allowing non-LOOP nodes to absorp children that are of
the same operator type as they and remove operators that have only 1
child
|
static NAryTree |
fromString(java.lang.String s) |
static NAryTree |
fromString(java.lang.String s,
gnu.trove.map.TObjectShortMap<java.lang.String> map) |
static NAryTree |
fromString(java.lang.String s,
org.deckfour.xes.classification.XEventClasses classes) |
static int |
getNumberOfNodesConfigured(NAryTree tree)
Returns the number of nodes that have a configuration option set any of
the configurations
|
static int |
getNumberOfNodesConfiguredForConfiguration(NAryTree tree,
int configuration)
Returns the number of nodes that have a configuration option set for the
provided configuration
|
static short |
getRandomOperatorType(java.util.Random rng) |
static short |
getRandomOperatorType(java.util.Random rng,
int maxType)
Returns a random operator type, less than or equal to the provided
maxType (RevSeq = 5, Loop = 4, OR = 3, AND = 2, XOR = 1 and SEQ = 0).
|
static org.deckfour.xes.classification.XEventClasses |
getXEventClassesFromConnection(org.processmining.framework.plugin.PluginContext context,
NAryTree tree)
Convenience method to ask the context for a connection between the given
tree and the list of XEventClasses required to correctly interpret the
leafs.
|
static void |
main(java.lang.String[] args) |
static java.lang.String |
nodeToString(NAryTree tree,
int node)
Returns the string representation of THIS NODE ONLY
|
static java.lang.String |
nodeToString(NAryTree tree,
int node,
java.lang.String[] leafLabels)
Returns the string representation of THIS NODE ONLY, if a leaf then
returns the corresponding XEventClass string representation or TAU if
necessary
|
static java.lang.String |
nodeToString(NAryTree tree,
int node,
org.deckfour.xes.classification.XEventClasses classes)
Returns the string representation of THIS NODE ONLY, if a leaf then
returns the corresponding XEventClass string representation or TAU if
necessary
|
static NAryTree |
normalize(NAryTree tree)
Normalizes a tree by first flattening it and then sorting it
|
static void |
printTree(NAryTree tree) |
static NAryTreeImpl |
randomTree(int evtClasses,
double leafProb,
int minNodes,
int maxNodes) |
static NAryTreeImpl |
randomTree(int evtClasses,
double leafProb,
int minNodes,
int maxNodes,
java.util.Random r) |
static java.lang.String |
readableSize(long size) |
static NAryTree |
rewriteRevSeq(NAryTree tree)
Rewrites all REVSEQ operators nodes to regular SEQ nodes (also updates
configurations).
|
static NAryTree |
sort(NAryTree tree)
Sorts the provided tree.
|
static java.lang.String |
toString(NAryTree tree)
Returns a human-readable string representation of an NAryTree
|
static java.lang.String |
toString(NAryTree tree,
int node)
Returns a human-readable string representation of the provided node in an
NAryTree
|
static java.lang.String |
toString(NAryTree tree,
int node,
org.deckfour.xes.classification.XEventClasses classes)
Returns a human-readable string representation of the provided node in an
NAryTree using the XEventClasses for the leafs
|
static java.lang.String |
toString(NAryTree tree,
org.deckfour.xes.classification.XEventClasses classes)
Returns a human-readable string representation of an NAryTree using the
provided XEventClasses for leafs
|
static void |
writeBehaviorToDot(NAryTree tree,
int configurationNumber,
java.io.OutputStreamWriter out,
boolean doPushDown) |
static void |
writeBehaviorToDot(java.io.OutputStreamWriter out,
boolean doPushDown,
StateBuilder builder) |
static void |
writeBehaviorToDot(java.io.OutputStreamWriter out,
StateSpace statespace,
StateBuilder builder) |
static void |
writeTreeToDot(NAryTree tree,
int configurationNumber,
java.io.OutputStreamWriter out) |
static void |
writeTreeToDot(NAryTree tree,
int configurationNumber,
java.io.OutputStreamWriter out,
java.lang.String[] leafLabels) |
static gnu.trove.map.TObjectShortMap<java.lang.String> |
xEventClassesToShortmap(org.deckfour.xes.classification.XEventClasses classes)
Convenience method to produce a shortmap required for the fromString
method
|
public static NAryTree fromString(java.lang.String s)
public static NAryTree fromString(java.lang.String s, org.deckfour.xes.classification.XEventClasses classes)
public static NAryTree fromString(java.lang.String s, gnu.trove.map.TObjectShortMap<java.lang.String> map)
public static void writeTreeToDot(NAryTree tree, int configurationNumber, java.io.OutputStreamWriter out) throws java.io.IOException
java.io.IOException
public static void writeTreeToDot(NAryTree tree, int configurationNumber, java.io.OutputStreamWriter out, java.lang.String[] leafLabels) throws java.io.IOException
java.io.IOException
public static java.lang.String readableSize(long size)
public static void writeBehaviorToDot(NAryTree tree, int configurationNumber, java.io.OutputStreamWriter out, boolean doPushDown) throws java.io.IOException
java.io.IOException
public static void writeBehaviorToDot(java.io.OutputStreamWriter out, boolean doPushDown, StateBuilder builder) throws java.io.IOException
java.io.IOException
public static void writeBehaviorToDot(java.io.OutputStreamWriter out, StateSpace statespace, StateBuilder builder) throws java.io.IOException
java.io.IOException
public static java.lang.String toString(NAryTree tree)
tree
- public static java.lang.String toString(NAryTree tree, org.deckfour.xes.classification.XEventClasses classes)
tree
- classes
- public static java.lang.String toString(NAryTree tree, int node)
tree
- node
- node to printpublic static java.lang.String toString(NAryTree tree, int node, org.deckfour.xes.classification.XEventClasses classes)
tree
- node
- classes
- public static java.lang.String nodeToString(NAryTree tree, int node)
tree
- node
- public static java.lang.String nodeToString(NAryTree tree, int node, org.deckfour.xes.classification.XEventClasses classes)
tree
- node
- classes
- public static java.lang.String nodeToString(NAryTree tree, int node, java.lang.String[] leafLabels)
tree
- node
- classes
- public static void printTree(NAryTree tree)
public static NAryTreeImpl randomTree(int evtClasses, double leafProb, int minNodes, int maxNodes)
public static NAryTreeImpl randomTree(int evtClasses, double leafProb, int minNodes, int maxNodes, java.util.Random r)
public static void main(java.lang.String[] args)
public static NAryTree normalize(NAryTree tree)
tree
- NAryTree to normalizepublic static NAryTree flatten(NAryTree tree)
tree
- NAryTree to flattenpublic static NAryTree sort(NAryTree tree)
tree
- NAryTree that should be sortedpublic static short getRandomOperatorType(java.util.Random rng)
public static short getRandomOperatorType(java.util.Random rng, int maxType)
rng
- maxType
- The 'maximum' (inclusive) type allowed to return. If this
value is less than 0 or bigger than 5, 5 is assumed, e.g. all
types are allowed.public static org.deckfour.xes.classification.XEventClasses getXEventClassesFromConnection(org.processmining.framework.plugin.PluginContext context, NAryTree tree)
context
- PluginContext to search withintree
- NAryTree that should participate in the connectionpublic static gnu.trove.map.TObjectShortMap<java.lang.String> xEventClassesToShortmap(org.deckfour.xes.classification.XEventClasses classes)
classes
- public static NAryTree rewriteRevSeq(NAryTree tree)
tree
- The tree with REVSEQs that should be rewrittenpublic static int getNumberOfNodesConfiguredForConfiguration(NAryTree tree, int configuration)
tree
- configuration
- public static int getNumberOfNodesConfigured(NAryTree tree)
tree
-