|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectunbbayes.util.dseparation.impl.MSeparationUtility
public class MSeparationUtility
Nested Class Summary | |
---|---|
class |
MSeparationUtility.MSeparationUtilityNodeVisitor
Visitor Pattern. |
Constructor Summary | |
---|---|
protected |
MSeparationUtility()
Default constructor. |
Method Summary | |
---|---|
Map<INode,Set<INode>> |
buildClosedAdjacentNodeMap(Set<INode> allKeys)
Builds a map containing a temporally reference to all adjacent nodes, given a key node. |
Set<INode> |
getAllAncestors(Set<INode> nodes)
Method to get all ancestors of a given set of nodes. |
protected Set<INode> |
getAllAncestors(Set<INode> nodes,
Set<INode> nodesToStop)
Method to get all ancestors of a given set of nodes. |
Set<INode> |
getAllDescendants(Set<INode> nodes)
Method to get all descendants of a given set of nodes. |
protected Set<INode> |
getAllDescendants(Set<INode> nodes,
Set<INode> nodesToStop,
MSeparationUtility.MSeparationUtilityNodeVisitor visitor)
Method to get all descendants of a given set of nodes. |
Set<INode> |
getAllDSeparatedNodes(Set<INode> consideredNodes,
Set<INode> from,
Set<INode> separators)
Obtains all nodes within graph which is d-separated from the set "from" given the separators. |
Set<List<INode>> |
getRoutes(INode from,
INode to)
Obtains a set of path/routes between two nodes, including themselves. |
Set<List<INode>> |
getRoutes(INode from,
INode to,
Map<INode,Set<INode>> closedAdjacentNodeMap)
Obtains a set of path/routes between two nodes, including themselves. |
Set<List<INode>> |
getRoutes(INode from,
INode to,
Map<INode,Set<INode>> closedAdjacentNodeMap,
Set<INode> nodesNotToContain,
int maxRoutes)
Obtains a set of path/routes between two nodes, including themselves. |
Set<List<INode>> |
getRoutes(INode from,
Set<INode> setTo,
Map<INode,Set<INode>> closedAdjacentNodeMap,
Set<INode> nodesNotToContain,
int maxRoutes)
Obtains a set of path/routes between two nodes, including themselves. |
boolean |
isDSeparated(Set<INode> consideredNodes,
Set<INode> from,
Set<INode> to,
Set<INode> separators)
Checks if the nodes within "from" are m-separated from nodes from "to", given a set of "separators". |
Map<INode,Set<INode>> |
makeItMoral(Map<INode,Set<INode>> closedAdjacentNodeMap)
If a node has a common child, make them adjacent (marry them - this is something moral). |
static MSeparationUtility |
newInstance()
Default constructor method. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
protected MSeparationUtility()
Method Detail |
---|
public static MSeparationUtility newInstance()
public Map<INode,Set<INode>> buildClosedAdjacentNodeMap(Set<INode> allKeys)
Node#getAdjacents()
It also guarantees that the map is "closed" (destination nodes are also keys).
I.E. if "key" is mapped to "node", then "node" must be a key in this map too.
It does not go down/up recursively (so that it guarantees only the nodes within
the parameter is mapped).
allKeys
- Node#getAdjacents()}
,
Node#makeAdjacents()}
public Map<INode,Set<INode>> makeItMoral(Map<INode,Set<INode>> closedAdjacentNodeMap)
closedAdjacentNodeMap
- : OBS. in/out parameter.
public Set<List<INode>> getRoutes(INode from, INode to, Map<INode,Set<INode>> closedAdjacentNodeMap, Set<INode> nodesNotToContain, int maxRoutes)
from
- : a node to start fromto
- : a destination nodeclosedAdjacentNodeMap
- : a map indicating all node's adjacency.nodesNotToContain
- : nodes that a returned path should not contain. The algorithm will ignore
a path if it contains any node within it.
If set to null, this method will start using INode#getChildren()
to build a directed path.maxRoutes
- : maximum number of routes to obtain.
public Set<List<INode>> getRoutes(INode from, Set<INode> setTo, Map<INode,Set<INode>> closedAdjacentNodeMap, Set<INode> nodesNotToContain, int maxRoutes)
from
- : a node to start fromsetTo
- : a set of possible destination node. A returning path will contain (only) one node within setTo at the end of path.closedAdjacentNodeMap
- : a map indicating all node's adjacency.
If set to null, this method will start using INode#getChildren()
to build a directed path.nodesNotToContain
- : nodes that a returned path should not contain. The algorithm will ignore
a path if it contains any node within it.maxRoutes
- : maximum number of routes to obtain.
public Set<List<INode>> getRoutes(INode from, INode to, Map<INode,Set<INode>> closedAdjacentNodeMap)
#getRoutesRec(INode, INode, Map, List, null)
from
- : a node to start fromto
- : a destination nodeclosedAdjacentNodeMap
- : a map indicating all node's adjacency.
a path if it contains any node within it.
If set to null, this method will start using INode#getChildren()
to build a directed path.
public Set<List<INode>> getRoutes(INode from, INode to)
getRoutes(INode, INode, Map)
setting the Map as null.
Cycles are not counted as new routes.
from
- : a node to start fromto
- : a destination node
If set to null, this method will start using INode#getChildren()
to build a directed path.
getRoutes(INode, INode, Map)
public Set<INode> getAllAncestors(Set<INode> nodes)
#getAllAncestors(Set, null)
nodes
- : nodes to be analyzed.
getAllAncestors(Set, Set)
protected Set<INode> getAllAncestors(Set<INode> nodes, Set<INode> nodesToStop)
nodes
- : nodes to be analyzed.nodesToStop
- : the recursive search for further ancestors will stop if any of those nodes are detected as direct ancestor.
Only the current recursion will stop, so, only the nodes which are exclusively ancestors
of nodesToStop will be ignored.
public Set<INode> getAllDescendants(Set<INode> nodes)
nodes
- : nodes to be analyzed.
protected Set<INode> getAllDescendants(Set<INode> nodes, Set<INode> nodesToStop, MSeparationUtility.MSeparationUtilityNodeVisitor visitor)
nodes
- : nodes to be analyzed.nodesToStop
- : the recursive search for further descendants will stop if any of those nodes are detected.
Only the current recursion will stop, so, only the nodes which are exclusively descendants
of nodesToStop will be ignored.
Using null to this param will make this method to find all descendantsvisitor
- : visitor to be executed when any of nodesToStop is detected. A node inside nodesToStop
will be passed as argument and its return will be added to return. Set it to null if nothing must be done.
public boolean isDSeparated(Set<INode> consideredNodes, Set<INode> from, Set<INode> to, Set<INode> separators)
isDSeparated
in interface IDSeparationUtility
graph
- : NOT USED BY THIS IMPLEMENTATION (since it uses only the parents/children of the nodes)from
- : set 1 of nodes which m-separation is going to be testedto
- : set 2 of nodes which m-separation is going to be testedseparators
- : set of separators.
public Set<INode> getAllDSeparatedNodes(Set<INode> consideredNodes, Set<INode> from, Set<INode> separators)
IDSeparationUtility
getAllDSeparatedNodes
in interface IDSeparationUtility
consideredNodes
- : nodes to be tested. They must reside in the same network containing the nodes within from, and separators sets.from
- set of nodes which d-separation is going to be testedseparators
- : set of separators.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |