jsat.classifiers.bayesian.graphicalmodel
Class DirectedGraph<N>
- java.lang.Object
-
- jsat.classifiers.bayesian.graphicalmodel.DirectedGraph<N>
-
- All Implemented Interfaces:
- java.lang.Cloneable
public class DirectedGraph<N> extends java.lang.Object implements java.lang.CloneableProvides a class representing an undirected graph. Mutations to the graph should be done exclusively through the methods provided by the class. Alterations should not be done to the sets returned by any method.
-
-
Constructor Summary
Constructors Constructor and Description DirectedGraph()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description voidaddEdge(N a, N b)Adds a directed edge into the network from a to b.voidaddNode(N node)Adds a new node to the graphvoidaddNodes(java.util.Collection<? extends N> c)Adds all the objects in c as nodes in the graphbooleancontainsNode(N a)Returns true if a is a node in the graph, or false otherwise.java.util.Set<N>getChildren(N n)Returns the set of all children of the requested node, or null if the node does not exist in the graph.java.util.Set<N>getNodes()Returns the set of all nodes currently in the graphjava.util.Set<N>getParents(N n)Returns the set of all parents of the requested node, or null if the node does not exist in the graphvoidremoveEdge(N a, N b)Removes a directed edge from the network connecting a to b.voidremoveNode(N node)Removes the specified node from the graph.
-
-
-
Method Detail
-
getNodes
public java.util.Set<N> getNodes()
Returns the set of all nodes currently in the graph- Returns:
- the set of all nodes in the graph
-
addNodes
public void addNodes(java.util.Collection<? extends N> c)
Adds all the objects in c as nodes in the graph- Parameters:
c- a collection of nodes to add
-
addNode
public void addNode(N node)
Adds a new node to the graph- Parameters:
node- the object to make a node
-
getParents
public java.util.Set<N> getParents(N n)
Returns the set of all parents of the requested node, or null if the node does not exist in the graph- Parameters:
n- the node to obtain the parents of- Returns:
- the set of parents, or null if the node is not in the graph
-
getChildren
public java.util.Set<N> getChildren(N n)
Returns the set of all children of the requested node, or null if the node does not exist in the graph.- Parameters:
n- the node to obtain the children of- Returns:
- the set of parents, or null if the node is not in the graph
-
removeNode
public void removeNode(N node)
Removes the specified node from the graph. If the node was not in the graph, not change occurs- Parameters:
node- the node to remove from the graph
-
addEdge
public void addEdge(N a, N b)
Adds a directed edge into the network from a to b. If a and b are not nodes in the graph, nothing occurs.- Parameters:
a- the parent nodeb- the child node
-
removeEdge
public void removeEdge(N a, N b)
Removes a directed edge from the network connecting a to b. If a and b are not nodes in the graph, nothing occurs.- Parameters:
a- the parent nodeb- the child node
-
containsNode
public boolean containsNode(N a)
Returns true if a is a node in the graph, or false otherwise.- Parameters:
a- the node in question- Returns:
- true if the node exists, false otherwise
-
-
DataMelt 3.0 © DataMelt by jWork.ORG