public class DefaultSemanticNetwork extends java.lang.Object implements SemanticNetwork
Constructor and Description |
---|
DefaultSemanticNetwork()
Creates a new instance of DefaultSemanticNetwork
|
Modifier and Type | Method and Description |
---|---|
void |
addNode(SemanticLabel nodeLabel)
Adds a node to the semantic network.
|
double |
getAssociation(SemanticLabel from,
SemanticLabel to)
Gets the association between two nodes in the network.
|
java.util.Collection<SemanticLabel> |
getNodes()
Gets the nodes that are in the network.
|
int |
getNumNodes()
Gets the total number of nodes in the network.
|
java.util.Collection<SemanticLabel> |
getOutLinks(SemanticLabel nodeLabel)
Gets the outgoing links from a given node.
|
boolean |
isNode(SemanticLabel label)
Returns true if the given SemanticLabel is a node in the
SemanticNetwork.
|
void |
removeNode(SemanticLabel nodeLabel)
Removes a node from the semantic network including all of the incoming
and outgoing links of the node.
|
void |
setAssociation(SemanticLabel from,
SemanticLabel to,
double weight)
Sets the association between two nodes in the network.
|
public DefaultSemanticNetwork()
public int getNumNodes()
getNumNodes
in interface SemanticNetwork
public boolean isNode(SemanticLabel label)
isNode
in interface SemanticNetwork
label
- The label to evaluate.public java.util.Collection<SemanticLabel> getNodes()
getNodes
in interface SemanticNetwork
public java.util.Collection<SemanticLabel> getOutLinks(SemanticLabel nodeLabel)
getOutLinks
in interface SemanticNetwork
nodeLabel
- The node to get the outgoing links frompublic double getAssociation(SemanticLabel from, SemanticLabel to)
getAssociation
in interface SemanticNetwork
from
- The node the association is fromto
- The node the association is topublic void addNode(SemanticLabel nodeLabel)
nodeLabel
- The semantic label of the node.public void removeNode(SemanticLabel nodeLabel)
nodeLabel
- The node to remove from the network.public void setAssociation(SemanticLabel from, SemanticLabel to, double weight)
from
- The node that the link is from.to
- The node that the link is to.weight
- The weight of the association.java.lang.IllegalArgumentException
- Thrown if either the from or to node
is not in the network.