edu.memphis.ccrg.lida.framework.shared
Interface NodeStructure

All Known Subinterfaces:
WorkspaceContent
All Known Implementing Classes:
NodeStructureImpl, PerceptualAssociativeMemoryImpl.PamNodeStructure, UnmodifiableNodeStructureImpl

public interface NodeStructure

A NodeStructure holds a collection of Nodes an Links. It is used as a main conceptual representation among LIDA modules.

Author:
Javier Snaider, Ryan J. McCall
See Also:
NodeStructureImpl

Method Summary
 Link addDefaultLink(int idSource, ExtendedId idSink, LinkCategory type, double activation, double removalThreshold)
          Creates and adds a new Link with specified attributes.
 Link addDefaultLink(int idSource, int idSink, LinkCategory type, double activation, double removalThreshold)
          Creates and adds a new Link with specified attributes.
 Link addDefaultLink(Link l)
          Copies specified Link and then adds the copy to this NodeStructure.
 Link addDefaultLink(Node source, Linkable sink, LinkCategory category, double activation, double removalThreshold)
           
 java.util.Collection<Link> addDefaultLinks(java.util.Collection<Link> links)
          Copies specified Links and then adds the copies to this NodeStructure.
 Node addDefaultNode(Node n)
          Adds a COPY of specified Node to this NodeStructure.
 java.util.Collection<Node> addDefaultNodes(java.util.Collection<Node> nodes)
           
 Link addLink(Link l, java.lang.String linkType)
          Adds copy of specified Link.
 Node addNode(Node n, java.lang.String factoryType)
          Add a Node of a specified factory type to this NodeStructure
 void clearLinks()
          Removes all links from this NodeStructure
 void clearNodeStructure()
          Removes all nodes and links from this nodestructure
 boolean containsLink(ExtendedId id)
          Returns whether this NodeStructure contains Link with specified ExtendedId.
 boolean containsLink(Link l)
          Returns whether this NodeStructure contains specified Link.
 boolean containsLinkable(ExtendedId id)
          Returns whether this NodeStructure contains Linkable with specified ExtendedId.
 boolean containsLinkable(Linkable l)
          Returns whether this NodeStructure contains specified Linkable.
 boolean containsNode(ExtendedId id)
          Returns whether this NodeStructure contains Node with specified ExtendedId.
 boolean containsNode(int id)
          Returns whether this NodeStructure contains Node with specified id.
 boolean containsNode(Node n)
          Returns whether this NodeStructure contains specified Node.
 NodeStructure copy()
          Returns a deep copy of this NodeStructure
 void decayNodeStructure(long ticks)
          Decays the Linkables of this NodeStructure.
 java.util.Set<Link> getAttachedLinks(Linkable l)
          Gets all Links directly connected to specified Linkable.
 java.util.Set<Link> getAttachedLinks(Linkable linkable, LinkCategory cat)
          Gets all Links directly connected to specified Linkable with specified LinkCategory
 java.util.Map<Linkable,Link> getConnectedSinks(Node n)
          Finds and returns a Map of all sink Linkables connected to specified Node.
 java.util.Map<Node,Link> getConnectedSources(Linkable linkable)
          Finds and returns a Map of all source Nodes connected to specified Linkable.
 java.lang.String getDefaultLinkType()
          Gets defaultLinkType
 java.lang.String getDefaultNodeType()
          Gets defaultNodeType
 Link getLink(ExtendedId ids)
          Gets Link with specified ExtendedId if present.
 Linkable getLinkable(ExtendedId eid)
          Gets Linkable with specified ExtendedId
 int getLinkableCount()
          Returns count of Linkables
 java.util.Map<Linkable,java.util.Set<Link>> getLinkableMap()
          Returns linkableMap
 java.util.Collection<Linkable> getLinkables()
          Returns all Linkables, all Nodes and Links, in this NodeStructure
 int getLinkCount()
          returns a count of links
 java.util.Collection<Link> getLinks()
          Returns the Links of this NodeStructure
 java.util.Set<Link> getLinks(LinkCategory cat)
          Returns all Links of this NodeStructure with specified LinkCategory
 Node getNode(ExtendedId eid)
          Returns a copy of the node in this nodestructure with specified ExtendedId
 Node getNode(int id)
          Returns a copy of the node in this nodestructure with specified id
 int getNodeCount()
          Returns a count of nodes
 java.util.Collection<Node> getNodes()
          Returns all Nodes
 void mergeWith(NodeStructure ns)
          Merges specified NodeStructure into this one.
 void removeLink(Link l)
          Removes specified Link if present.
 void removeLinkable(ExtendedId id)
          Removes Linkable with specified ExtendedId if present.
 void removeLinkable(Linkable l)
          Removes specified Linkable if present.
 void removeNode(Node n)
          Removes specified Node if present.
 

Method Detail

addDefaultLink

Link addDefaultLink(Link l)
Copies specified Link and then adds the copy to this NodeStructure. If Link with the same id already exists then the old Link's activation is updated. Copied link will have the default link type of this NodeStructure when it is added.

Parameters:
l - Link to copy and add.
Returns:
the copied Link that is actually stored in this NodeStructure, or the existing link that is updated. If Link cannot be added then null is returned.

addDefaultLinks

java.util.Collection<Link> addDefaultLinks(java.util.Collection<Link> links)
Copies specified Links and then adds the copies to this NodeStructure. If any Link with the same id already exists then the old Link's activation is updated. Copied links will have the default link type of this NodeStructure when they are added. Note if Links in supplied Collection link to each other then this method does NOT guarantee that all Links will be added properly. Links should be added one at a time in this case after the dependent links are already present.

Parameters:
links - Links to copy and add.
Returns:
the copied Links that are actually stored in this NodeStructure, or any existing links.

addLink

Link addLink(Link l,
             java.lang.String linkType)
Adds copy of specified Link. Copy is of specified type.

Parameters:
l - original Link
linkType - type of copied Link
Returns:
new Link or null if such a link cannot be created.

addDefaultLink

Link addDefaultLink(Node source,
                    Linkable sink,
                    LinkCategory category,
                    double activation,
                    double removalThreshold)
Parameters:
source - Link's source Node
sink - Link's sink, a Node or a Link
category - Link's LinkCategory
activation - initial link activation
removalThreshold - amount of activation Link must maintain to remain in this NodeStructure after decaying.
Returns:
created Link or null if either source or sink are not already present.

addDefaultLink

Link addDefaultLink(int idSource,
                    ExtendedId idSink,
                    LinkCategory type,
                    double activation,
                    double removalThreshold)
Creates and adds a new Link with specified attributes. Source and sink must already be in this NodeStructure.

Parameters:
idSource - id of link's source
idSink - ExtendedId of link's sink
type - Link's LinkCategory
activation - initial link activation
removalThreshold - amount of activation Link must maintain to remain in this NodeStructure after decaying.
Returns:
created Link or null if either source or sink are not already present.

addDefaultLink

Link addDefaultLink(int idSource,
                    int idSink,
                    LinkCategory type,
                    double activation,
                    double removalThreshold)
Creates and adds a new Link with specified attributes. Source and sink must already be in this NodeStructure. Allows multiple links from the same source and sink as long as their LinkCategory differs.

Parameters:
idSource - id of link's source
idSink - id of link's sink
type - Link's LinkCategory
activation - initial link activation
removalThreshold - amount of activation Link must maintain to remain in this NodeStructure after decaying.
Returns:
created Link or null if either source or sink are not already present.

addDefaultNode

Node addDefaultNode(Node n)
Adds a COPY of specified Node to this NodeStructure. The copy will be of the default type of this NodeStructure, NOT of the type of the specified node. If Node with the same id already exists the the old node's activation is updated ONLY IF it is higher than the existing activation.

Parameters:
n - Node to add.
Returns:
The copied Node that is stored in this NodeStructure or the existing, updated, Node already there.

addDefaultNodes

java.util.Collection<Node> addDefaultNodes(java.util.Collection<Node> nodes)
Parameters:
nodes - Node to be added.
Returns:
copied and/or updated nodes that are now present in this nodestructure
See Also:
addDefaultNode(Node)

addNode

Node addNode(Node n,
             java.lang.String factoryType)
Add a Node of a specified factory type to this NodeStructure

Parameters:
n - Node
factoryType - name of node's type in the factory
Returns:
copy of node actually added.

removeLink

void removeLink(Link l)
Removes specified Link if present.

Parameters:
l - Link to remove.

removeNode

void removeNode(Node n)
Removes specified Node if present.

Parameters:
n - Node to remove.

removeLinkable

void removeLinkable(Linkable l)
Removes specified Linkable if present.

Parameters:
l - Linkable to remove.

removeLinkable

void removeLinkable(ExtendedId id)
Removes Linkable with specified ExtendedId if present.

Parameters:
id - ExtendedId of Linkable to remove.

clearLinks

void clearLinks()
Removes all links from this NodeStructure


clearNodeStructure

void clearNodeStructure()
Removes all nodes and links from this nodestructure


containsNode

boolean containsNode(Node n)
Returns whether this NodeStructure contains specified Node.

Parameters:
n - Node checked for.
Returns:
true if contains a Node with the same id.

containsNode

boolean containsNode(int id)
Returns whether this NodeStructure contains Node with specified id.

Parameters:
id - id of Node checked for.
Returns:
true if contains a Node with the same id.

containsNode

boolean containsNode(ExtendedId id)
Returns whether this NodeStructure contains Node with specified ExtendedId.

Parameters:
id - ExtendedId of Node checked for.
Returns:
true if contains a Node with the same ExtendedId.

containsLink

boolean containsLink(Link l)
Returns whether this NodeStructure contains specified Link.

Parameters:
l - Link checked for.
Returns:
true if contains a Link with the same id.

containsLink

boolean containsLink(ExtendedId id)
Returns whether this NodeStructure contains Link with specified ExtendedId.

Parameters:
id - Link checked for.
Returns:
true if contains a Link with the same ExtendedId.

containsLinkable

boolean containsLinkable(Linkable l)
Returns whether this NodeStructure contains specified Linkable.

Parameters:
l - Linkable checked for.
Returns:
true if contains a Linkable with the same ExtendedId.

containsLinkable

boolean containsLinkable(ExtendedId id)
Returns whether this NodeStructure contains Linkable with specified ExtendedId.

Parameters:
id - Linkable checked for.
Returns:
true if contains a Linkable with the same ExtendedId.

mergeWith

void mergeWith(NodeStructure ns)
Merges specified NodeStructure into this one. Adds all nodes and adds all Links. Activations are updated if Linkable is already present.

Parameters:
ns - NodeStructure

copy

NodeStructure copy()
Returns a deep copy of this NodeStructure

Returns:
NodeStructure

decayNodeStructure

void decayNodeStructure(long ticks)
Decays the Linkables of this NodeStructure.

Parameters:
ticks - the number of ticks to decay for.

getLink

Link getLink(ExtendedId ids)
Gets Link with specified ExtendedId if present.

Parameters:
ids - ExtendedId of sought Link.
Returns:
Link or null if no Link exists.

getLinks

java.util.Collection<Link> getLinks()
Returns the Links of this NodeStructure

Returns:
an unmodifiable Collection of all Links

getLinks

java.util.Set<Link> getLinks(LinkCategory cat)
Returns all Links of this NodeStructure with specified LinkCategory

Parameters:
cat - LinkCategory to search for.
Returns:
Links having specified LinkCategory

getAttachedLinks

java.util.Set<Link> getAttachedLinks(Linkable l)
Gets all Links directly connected to specified Linkable.

Parameters:
l - Linkable to find Links to and from.
Returns:
an unmodifiable Set of all Links connected to specified Linkable.

getAttachedLinks

java.util.Set<Link> getAttachedLinks(Linkable linkable,
                                     LinkCategory cat)
Gets all Links directly connected to specified Linkable with specified LinkCategory

Parameters:
linkable - a Linkable
cat - LinkCategory
Returns:
Links

getNode

Node getNode(int id)
Returns a copy of the node in this nodestructure with specified id

Parameters:
id - id of node
Returns:
Node with specified id or null if not present

getNode

Node getNode(ExtendedId eid)
Returns a copy of the node in this nodestructure with specified ExtendedId

Parameters:
eid - ExtendedId of node
Returns:
Node with specified ExtendedId or null if not present

getNodes

java.util.Collection<Node> getNodes()
Returns all Nodes

Returns:
All Nodes in this NodeStructure.

getLinkable

Linkable getLinkable(ExtendedId eid)
Gets Linkable with specified ExtendedId

Parameters:
eid - ExtendedId
Returns:
a Linkable

getLinkables

java.util.Collection<Linkable> getLinkables()
Returns all Linkables, all Nodes and Links, in this NodeStructure

Returns:
all Linkables

getLinkableMap

java.util.Map<Linkable,java.util.Set<Link>> getLinkableMap()
Returns linkableMap

Returns:
An unmodifiable Map of the linkables of this NodeStructure and their links.s

getNodeCount

int getNodeCount()
Returns a count of nodes

Returns:
number of nodes

getLinkCount

int getLinkCount()
returns a count of links

Returns:
number of links

getLinkableCount

int getLinkableCount()
Returns count of Linkables

Returns:
number of Linkables

getDefaultNodeType

java.lang.String getDefaultNodeType()
Gets defaultNodeType

Returns:
node type used when creating new nodes that are being added to this NodeStructure.

getDefaultLinkType

java.lang.String getDefaultLinkType()
Gets defaultLinkType

Returns:
link type used when creating new link copies that are being added to this NodeStructure.

getConnectedSinks

java.util.Map<Linkable,Link> getConnectedSinks(Node n)
Finds and returns a Map of all sink Linkables connected to specified Node. Keys are the connected sinks Values are the Links connecting the sinks to the specified Node

Parameters:
n - supplied node
Returns:
map of sinks and links connecting node to them

getConnectedSources

java.util.Map<Node,Link> getConnectedSources(Linkable linkable)
Finds and returns a Map of all source Nodes connected to specified Linkable. Keys are the connected sources Values are the Links connecting the sources to the specified Linkable

Parameters:
linkable - specified linkable
Returns:
map of sources and links connecting Linkable to them