public class GraphUtilities
extends java.lang.Object
Constructor and Description |
---|
GraphUtilities() |
Modifier and Type | Method and Description |
---|---|
static java.util.List<Node> |
flatten(java.util.List<Node> roots)
Out of a list of lineage graph roots, creates another set of graphs where
nested nodes are exploded.
|
static Node |
flatten(Node root)
Out of a single-rooted lineage graph, creates another graph where nested
nodes are exploded.
|
static boolean |
isLeaf(Node n)
Determines if a node is a leaf.
|
static java.util.List<Node> |
simplify(java.util.List<Node> roots)
Simplifies a list of lineage graphs.
|
static Node |
simplify(Node root)
Simplifies a single-rooted lineage graph.
|
static java.util.List<Node> |
squash(java.util.List<Node> roots)
Out of a list of lineage graphs, creates another graph where only
Boolean nodes and leaves are kept.
|
static Node |
squash(Node root)
Out of a single-rooted lineage graph, creates another graph where only
Boolean nodes and leaves are kept.
|
protected static void |
squash(Node parent,
int pin_index,
Pin<? extends Node> pin,
java.util.Set<Node> visited,
java.util.Map<Node,Node> duplicates) |
protected static Node |
squash(Node root,
java.util.Set<Node> visited,
java.util.Map<Node,Node> duplicates)
Out of a single-rooted lineage graph, creates another graph where only
Boolean nodes and leaves are kept.
|
public static Node simplify(Node root)
squash()
and
flatten()
.root
- The root of the original graphpublic static java.util.List<Node> simplify(java.util.List<Node> roots)
squash(List)
and
flatten()
.roots
- The roots of the original graphspublic static Node flatten(Node root)
root
- The root of the original graphpublic static java.util.List<Node> flatten(java.util.List<Node> roots)
The operation is less trivial than it seems, as one cannot simply flatten the graph starting from each root separately. Any node shared between two sub-graphs will result in two copies. One must therefore pass the set of copies already produced in a previous flattening operation to the next one.
roots
- The root of the original graphpublic static java.util.List<Node> squash(java.util.List<Node> roots)
roots
- The roots of the original graphprotected static Node squash(Node root, java.util.Set<Node> visited, java.util.Map<Node,Node> duplicates)
root
- The root of the original graphvisited
- A set of already visited nodesduplicates
- A map keeping track of original nodes and their copies
in the resulting graphpublic static Node squash(Node root)
root
- The root of the original graphprotected static void squash(Node parent, int pin_index, Pin<? extends Node> pin, java.util.Set<Node> visited, java.util.Map<Node,Node> duplicates)
public static boolean isLeaf(Node n)
n
- The nodetrue
if the node is a leaf, false
otherwise.Copyright © Sylvain HallĂ©. All Rights Reserved.