edu.memphis.ccrg.lida.framework.shared
Class NodeStructureImpl

java.lang.Object
  extended by edu.memphis.ccrg.lida.framework.shared.NodeStructureImpl
All Implemented Interfaces:
NodeStructure, BroadcastContent, WorkspaceContent
Direct Known Subclasses:
PerceptualAssociativeMemoryImpl.PamNodeStructure, ProceduralMemoryImpl.InternalNodeStructure

public class NodeStructureImpl
extends java.lang.Object
implements NodeStructure, BroadcastContent, WorkspaceContent

Default implementation of NodeStructure. The source and sink of a link must be present before it can be added. Links can connect two nodes (simple link) or can connect a node and another SIMPLE link. Nodes and links are copied when added. This prevents having the same node (object) in two different NodeStructures.

Author:
Javier Snaider, Ryan J. McCall, Daqi Dong, Pulin Agrawal
See Also:
ExtendedId

Constructor Summary
NodeStructureImpl()
          Default constructor.
NodeStructureImpl(NodeStructure ns)
          Copy constructor.
NodeStructureImpl(java.lang.String nodeType, java.lang.String linkType)
          Creates a new NodeStructureImpl with specified default Node type and link Type.
 
Method Summary
 Link addDefaultLink(int sourceId, ExtendedId sinkId, LinkCategory category, double activation, double removalThreshold)
          Creates and adds a new Link of default type with specified attributes.
 Link addDefaultLink(int sourceId, int sinkId, LinkCategory cat, double activation, double removalThreshold)
          Creates and adds a new Link of default type with specified attributes.
 Link addDefaultLink(Link l)
          Adds a copy, of default link type, based on the specified Link, to this NodeStructure.
 Link addDefaultLink(Node source, Linkable sink, LinkCategory category, double activation, double removalThreshold)
          Creates and adds a new Link of default type with specified attributes.
 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.
 Node addDefaultNode(java.lang.String label, double a, double rt)
          Creates, adds and returns a new Node of default type with specified attributes.
 java.util.Collection<Node> addDefaultNodes(java.util.Collection<Node> nodes)
           
 Link addLink(Link l, java.lang.String type)
          Adds copy of specified Link.
 Link addLink(java.lang.String type, int srcId, ExtendedId snkId, LinkCategory cat, double a, double rt)
          Creates and adds a new Link of specified type with specified attributes.
 Link addLink(java.lang.String type, Node src, Linkable sink, LinkCategory cat, double a, double rt)
          Creates and adds a new Link of specified type with specified attributes.
protected  Node addNode(Node n, boolean shouldCopy)
          If copy is false, this method adds a already generated Node to this NodeStructure without copying it.
 Node addNode(Node n, java.lang.String type)
          Add a Node of a specified type to this NodeStructure.
If a Node with the same id already exists in the NodeStructure the existing Node will have its activation updated.
 Node addNode(java.lang.String type, java.lang.String label, double a, double rt)
          Creates, adds and returns a new Node of specified type with specified attributes.
 void clearLinks()
          Removes all links from this NodeStructure.
 void clearNodeStructure()
          Removes all nodes and links from this NodeStructure.
static boolean compareNodeStructures(NodeStructure ns1, NodeStructure ns2)
          Returns true if two NodeStructures are meaningfully equal, else false.
 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 lnk)
          Gets all Link objects directly connected to specified Linkable.
 java.util.Set<Link> getAttachedLinks(Linkable lnk, LinkCategory cat)
          Gets all Links directly connected to specified Linkable with specified LinkCategory
 java.util.Map<Linkable,Link> getConnectedSinks(Node n)
          Returns a Map of all sink Linkable objects connected to specified Node.
 java.util.Map<Node,Link> getConnectedSources(Linkable lnk)
          Returns a Map of all Nodes connected to specified Linkable as a source.
 java.lang.String getDefaultLinkType()
          Gets default Link type of the NodeStructure.
 java.lang.String getDefaultNodeType()
          Gets default Node type of the NodeStructure.
 Link getLink(ExtendedId id)
          Gets Link with specified ExtendedId if present.
 Linkable getLinkable(ExtendedId ids)
          Gets Linkable with specified ExtendedId.
 int getLinkableCount()
          Gets the number of linkables (nodes and links).
 java.util.Map<Linkable,java.util.Set<Link>> getLinkableMap()
          Returns a map of all the Linkable objects currently in the NodeStructure and their attached links.
 java.util.Collection<Linkable> getLinkables()
          Returns all Linkables, all Nodes and Links, currently in this NodeStructure.
 int getLinkCount()
          Gets the number 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.
protected  Link getNewLink(Link oLink, java.lang.String newType, Node src, Linkable snk, LinkCategory cat)
          This method can be overridden to customize the Link Creation.
protected  Node getNewNode(Node oNode, java.lang.String desiredType)
          This method can be overwritten to customize the Node Creation.
 Node getNode(ExtendedId id)
          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()
          Gets the number of nodes.
 java.util.Collection<Node> getNodes()
          Returns all Nodes.
 NodeStructure getSubgraph(java.util.Collection<Node> nodes, int d)
          Returns a copy of a subgraph of this NodeStructure.
 NodeStructure getSubgraph(java.util.Collection<Node> nodes, int d, double threshold)
          Returns a copy of a subgraph of this NodeStructure.
 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 linkable)
          Removes specified Linkable if present.
 void removeNode(Node n)
          Removes specified Node if present.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

NodeStructureImpl

public NodeStructureImpl()
Default constructor. Uses the default node and link types of the factory


NodeStructureImpl

public NodeStructureImpl(java.lang.String nodeType,
                         java.lang.String linkType)
Creates a new NodeStructureImpl with specified default Node type and link Type. If either is not in the factory the factory's defaults are used.

Parameters:
nodeType - kind of node used in this NodeStructure
linkType - kind of link used in this NodeStructure
See Also:
ElementFactory

NodeStructureImpl

public NodeStructureImpl(NodeStructure ns)
Copy constructor. Specifies Node and Link types used to copy Node and Links. Specified types are the default types for the copy.

Parameters:
ns - original NodeStructure
See Also:
mergeWith(NodeStructure)
Method Detail

addDefaultNode

public Node addDefaultNode(Node n)
Description copied from interface: NodeStructure
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.

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

addDefaultNodes

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

addNode

public Node addNode(Node n,
                    java.lang.String type)
Description copied from interface: NodeStructure
Add a Node of a specified type to this NodeStructure.
If a Node with the same id already exists in the NodeStructure the existing Node will have its activation updated. In this case the Node's type doesn't change.

Specified by:
addNode in interface NodeStructure
Parameters:
n - Node
type - name of node's type in ElementFactory
Returns:
copy of node actually added.

addDefaultNode

public Node addDefaultNode(java.lang.String label,
                           double a,
                           double rt)
Description copied from interface: NodeStructure
Creates, adds and returns a new Node of default type with specified attributes.

Specified by:
addDefaultNode in interface NodeStructure
Parameters:
label - label of new Node
a - initial activation of new Node
rt - initial removal threshold of new Node
Returns:
the Node added to the NodeStructure or null

addNode

public Node addNode(java.lang.String type,
                    java.lang.String label,
                    double a,
                    double rt)
Description copied from interface: NodeStructure
Creates, adds and returns a new Node of specified type with specified attributes.

Specified by:
addNode in interface NodeStructure
Parameters:
type - Factory type of new Node
label - label of new Node
a - initial activation of new Node
rt - initial removal threshold of new Node
Returns:
the Node added to the NodeStructure or null

addNode

protected Node addNode(Node n,
                       boolean shouldCopy)
If copy is false, this method adds a already generated Node to this NodeStructure without copying it. If copy is true, NodeStructure.addDefaultNode(Node) is used. If a Node with the same id is already in this NodeStructure, the new Node is not added. This method is intended for internal use only.

Parameters:
n - the Node to add
shouldCopy - determines if the node is copied or not.
Returns:
The Node stored in this NodeStructure

getNewNode

protected Node getNewNode(Node oNode,
                          java.lang.String desiredType)
This method can be overwritten to customize the Node Creation. This implementation returns a new Node of specified type that is compatible in the NodeStrucutreImpl. If an original node is specified the new Node will copy the relevant attributes of the original.

Parameters:
oNode - The original Node or null
desiredType - the ElementFactory name of the desired node type
Returns:
a new Node if is no original was specified, or a copy of the specified original node
See Also:
ElementFactory.getNode(String, Node, String)

addDefaultLink

public Link addDefaultLink(Link l)
Description copied from interface: NodeStructure
Adds a copy, of default link type, based on the specified Link, 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.

Specified by:
addDefaultLink in interface NodeStructure
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

public java.util.Collection<Link> addDefaultLinks(java.util.Collection<Link> links)
Description copied from interface: NodeStructure
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.

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

addLink

public Link addLink(Link l,
                    java.lang.String type)
Description copied from interface: NodeStructure
Adds copy of specified Link. Copy is of specified type.

Specified by:
addLink in interface NodeStructure
Parameters:
l - original Link
type - type of copied Link
Returns:
new Link or null if such a link cannot be created.

addDefaultLink

public Link addDefaultLink(Node source,
                           Linkable sink,
                           LinkCategory category,
                           double activation,
                           double removalThreshold)
Description copied from interface: NodeStructure
Creates and adds a new Link of default type with specified attributes. Source and sink must already be in this NodeStructure.

Specified by:
addDefaultLink in interface NodeStructure
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

public Link addDefaultLink(int sourceId,
                           ExtendedId sinkId,
                           LinkCategory category,
                           double activation,
                           double removalThreshold)
Description copied from interface: NodeStructure
Creates and adds a new Link of default type with specified attributes. Source and sink must already be in this NodeStructure.

Specified by:
addDefaultLink in interface NodeStructure
Parameters:
sourceId - id of link's source
sinkId - ExtendedId of link's sink
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

public Link addDefaultLink(int sourceId,
                           int sinkId,
                           LinkCategory cat,
                           double activation,
                           double removalThreshold)
Description copied from interface: NodeStructure
Creates and adds a new Link of default type 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.

Specified by:
addDefaultLink in interface NodeStructure
Parameters:
sourceId - id of link's source
sinkId - id of link's sink
cat - 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.

addLink

public Link addLink(java.lang.String type,
                    Node src,
                    Linkable sink,
                    LinkCategory cat,
                    double a,
                    double rt)
Description copied from interface: NodeStructure
Creates and adds a new Link of specified type with specified attributes. Source and sink must already be in this NodeStructure.

Specified by:
addLink in interface NodeStructure
Parameters:
type - Factory type of the link to be created
src - the link's source Node
sink - the link's sink Linkable
cat - the link's LinkCategory
a - initial link activation
rt - removal threshold, 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.

addLink

public Link addLink(java.lang.String type,
                    int srcId,
                    ExtendedId snkId,
                    LinkCategory cat,
                    double a,
                    double rt)
Description copied from interface: NodeStructure
Creates and adds a new Link of specified type with specified attributes. Source and sink must already be in this NodeStructure.

Specified by:
addLink in interface NodeStructure
Parameters:
type - Factory type of the link to be created
srcId - id of link's source
snkId - ExtendedId of link's sink
cat - Link's LinkCategory
a - initial link activation
rt - removal threshold, 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.

getNewLink

protected Link getNewLink(Link oLink,
                          java.lang.String newType,
                          Node src,
                          Linkable snk,
                          LinkCategory cat)
This method can be overridden to customize the Link Creation. some of the parameter could be redundant in some cases.

Parameters:
oLink - original Link
newType - the ElementFactory name of the new Link type
src - The new source
snk - The new sink
cat - the type of the link
Returns:
The link to be used in this NodeStructure

copy

public NodeStructure copy()
Description copied from interface: NodeStructure
Returns a deep copy of this NodeStructure.

Specified by:
copy in interface NodeStructure
Returns:
NodeStructure

mergeWith

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

Specified by:
mergeWith in interface NodeStructure
Parameters:
ns - NodeStructure

removeNode

public void removeNode(Node n)
Description copied from interface: NodeStructure
Removes specified Node if present.

Specified by:
removeNode in interface NodeStructure
Parameters:
n - Node to remove.

removeLink

public void removeLink(Link l)
Description copied from interface: NodeStructure
Removes specified Link if present.

Specified by:
removeLink in interface NodeStructure
Parameters:
l - Link to remove.

removeLinkable

public void removeLinkable(Linkable linkable)
Description copied from interface: NodeStructure
Removes specified Linkable if present.

Specified by:
removeLinkable in interface NodeStructure
Parameters:
linkable - Linkable to remove.

removeLinkable

public void removeLinkable(ExtendedId id)
Description copied from interface: NodeStructure
Removes Linkable with specified ExtendedId if present.

Specified by:
removeLinkable in interface NodeStructure
Parameters:
id - ExtendedId of Linkable to remove.

clearLinks

public void clearLinks()
Description copied from interface: NodeStructure
Removes all links from this NodeStructure.

Specified by:
clearLinks in interface NodeStructure

clearNodeStructure

public void clearNodeStructure()
Description copied from interface: NodeStructure
Removes all nodes and links from this NodeStructure.

Specified by:
clearNodeStructure in interface NodeStructure

decayNodeStructure

public void decayNodeStructure(long ticks)
Description copied from interface: NodeStructure
Decays the Linkables of this NodeStructure.

Specified by:
decayNodeStructure in interface NodeStructure
Parameters:
ticks - the number of ticks to decay for.

getNode

public Node getNode(int id)
Description copied from interface: NodeStructure
Returns a copy of the node in this NodeStructure with specified id.

Specified by:
getNode in interface NodeStructure
Parameters:
id - id of node
Returns:
Node with specified id or null if not present

getNode

public Node getNode(ExtendedId id)
Description copied from interface: NodeStructure
Returns a copy of the node in this NodeStructure with specified ExtendedId.

Specified by:
getNode in interface NodeStructure
Parameters:
id - ExtendedId of node
Returns:
Node with specified ExtendedId or null if not present

getNodes

public java.util.Collection<Node> getNodes()
Description copied from interface: NodeStructure
Returns all Nodes.

Specified by:
getNodes in interface NodeStructure
Returns:
all Nodes in this NodeStructure

getNodeCount

public int getNodeCount()
Description copied from interface: NodeStructure
Gets the number of nodes.

Specified by:
getNodeCount in interface NodeStructure
Returns:
number of nodes currently in the NodeStructure

getLink

public Link getLink(ExtendedId id)
Description copied from interface: NodeStructure
Gets Link with specified ExtendedId if present.

Specified by:
getLink in interface NodeStructure
Parameters:
id - ExtendedId of sought Link
Returns:
Link or null if no Link exists

getLinks

public java.util.Set<Link> getLinks(LinkCategory cat)
Description copied from interface: NodeStructure
Returns all Links of this NodeStructure with specified LinkCategory.

Specified by:
getLinks in interface NodeStructure
Parameters:
cat - the LinkCategory to search for
Returns:
Links having specified LinkCategory

getLinks

public java.util.Collection<Link> getLinks()
Description copied from interface: NodeStructure
Returns the Links of this NodeStructure.

Specified by:
getLinks in interface NodeStructure
Returns:
an UnmodifiableCollection of all Links

getLinkCount

public int getLinkCount()
Description copied from interface: NodeStructure
Gets the number of links.

Specified by:
getLinkCount in interface NodeStructure
Returns:
number of links currently in the NodeStructure

getLinkable

public Linkable getLinkable(ExtendedId ids)
Description copied from interface: NodeStructure
Gets Linkable with specified ExtendedId.

Specified by:
getLinkable in interface NodeStructure
Parameters:
ids - ExtendedId
Returns:
a Linkable

getLinkables

public java.util.Collection<Linkable> getLinkables()
Description copied from interface: NodeStructure
Returns all Linkables, all Nodes and Links, currently in this NodeStructure.

Specified by:
getLinkables in interface NodeStructure
Returns:
all Linkables

getLinkableMap

public java.util.Map<Linkable,java.util.Set<Link>> getLinkableMap()
Description copied from interface: NodeStructure
Returns a map of all the Linkable objects currently in the NodeStructure and their attached links.

Specified by:
getLinkableMap in interface NodeStructure
Returns:
an UnmodifiableMap of the Linkable objects in this NodeStructure and their attached links.

getLinkableCount

public int getLinkableCount()
Description copied from interface: NodeStructure
Gets the number of linkables (nodes and links).

Specified by:
getLinkableCount in interface NodeStructure
Returns:
number of Linkable objects currently in the NodeStructure

getAttachedLinks

public java.util.Set<Link> getAttachedLinks(Linkable lnk)
Description copied from interface: NodeStructure
Gets all Link objects directly connected to specified Linkable.

Specified by:
getAttachedLinks in interface NodeStructure
Parameters:
lnk - the Linkable whose attached links will be returned
Returns:
an UnmodifiableSet of all Links connected to specified Linkable

getAttachedLinks

public java.util.Set<Link> getAttachedLinks(Linkable lnk,
                                            LinkCategory cat)
Description copied from interface: NodeStructure
Gets all Links directly connected to specified Linkable with specified LinkCategory

Specified by:
getAttachedLinks in interface NodeStructure
Parameters:
lnk - a Linkable
cat - LinkCategory
Returns:
Links

getConnectedSources

public java.util.Map<Node,Link> getConnectedSources(Linkable lnk)
Description copied from interface: NodeStructure
Returns a Map of all Nodes connected to specified Linkable as a source. The keys of the map are the connected sources and the values are the Links connecting the sources to the specified Linkable

Specified by:
getConnectedSources in interface NodeStructure
Parameters:
lnk - the Linkable whose connected sources will be returned
Returns:
Map of all sources connected to lnk and the links connecting them to lnk

getConnectedSinks

public java.util.Map<Linkable,Link> getConnectedSinks(Node n)
Description copied from interface: NodeStructure
Returns a Map of all sink Linkable objects connected to specified Node. The keys of the map are the connected sinks and the values are the Links connecting the sinks to the specified Node.

Specified by:
getConnectedSinks in interface NodeStructure
Parameters:
n - supplied node
Returns:
map of sinks and links connecting node to them

getDefaultLinkType

public java.lang.String getDefaultLinkType()
Description copied from interface: NodeStructure
Gets default Link type of the NodeStructure.

Specified by:
getDefaultLinkType in interface NodeStructure
Returns:
link type of Link objects in the NodeStructure

getDefaultNodeType

public java.lang.String getDefaultNodeType()
Description copied from interface: NodeStructure
Gets default Node type of the NodeStructure.

Specified by:
getDefaultNodeType in interface NodeStructure
Returns:
default type of Node objects in the NodeStructure

containsNode

public boolean containsNode(Node n)
Description copied from interface: NodeStructure
Returns whether this NodeStructure contains specified Node.

Specified by:
containsNode in interface NodeStructure
Parameters:
n - Node checked for.
Returns:
true if contains a Node with the same id.

containsNode

public boolean containsNode(int id)
Description copied from interface: NodeStructure
Returns whether this NodeStructure contains Node with specified id.

Specified by:
containsNode in interface NodeStructure
Parameters:
id - id of Node checked for.
Returns:
true if contains a Node with the same id.

containsNode

public boolean containsNode(ExtendedId id)
Description copied from interface: NodeStructure
Returns whether this NodeStructure contains Node with specified ExtendedId.

Specified by:
containsNode in interface NodeStructure
Parameters:
id - ExtendedId of Node checked for.
Returns:
true if contains a Node with the same ExtendedId.

containsLink

public boolean containsLink(Link l)
Description copied from interface: NodeStructure
Returns whether this NodeStructure contains specified Link.

Specified by:
containsLink in interface NodeStructure
Parameters:
l - Link checked for.
Returns:
true if contains a Link with the same id.

containsLink

public boolean containsLink(ExtendedId id)
Description copied from interface: NodeStructure
Returns whether this NodeStructure contains Link with specified ExtendedId.

Specified by:
containsLink in interface NodeStructure
Parameters:
id - Link checked for.
Returns:
true if contains a Link with the same ExtendedId.

containsLinkable

public boolean containsLinkable(Linkable l)
Description copied from interface: NodeStructure
Returns whether this NodeStructure contains specified Linkable.

Specified by:
containsLinkable in interface NodeStructure
Parameters:
l - Linkable checked for.
Returns:
true if contains a Linkable with the same ExtendedId.

containsLinkable

public boolean containsLinkable(ExtendedId id)
Description copied from interface: NodeStructure
Returns whether this NodeStructure contains Linkable with specified ExtendedId.

Specified by:
containsLinkable in interface NodeStructure
Parameters:
id - Linkable checked for.
Returns:
true if contains a Linkable with the same ExtendedId.

getSubgraph

public NodeStructure getSubgraph(java.util.Collection<Node> nodes,
                                 int d)
Description copied from interface: NodeStructure
Returns a copy of a subgraph of this NodeStructure. The subgraph will contain all specified nodes with non-zero activation if they are currently present in the NodeStructure. Additionally all other nodes having distance, the number of links, less or equal to d from the specified nodes and that have non-zero activation are part of the subgraph. If a Node has non-zero activation then the depth-first search will not continue further from that Node. Finally all links that connect two Linkable elements that are both d or less from the specified nodes are included in the subgraph.

Specified by:
getSubgraph in interface NodeStructure
Parameters:
nodes - the nodes which will be the roots from which the subgraph will be formed
d - the greatest distance a node can be from a specified nodes to be included in the subgraph
Returns:
A copy of a subgraph of this NodeStructure which involves specified and all satisfied neighbor nodes

getSubgraph

public NodeStructure getSubgraph(java.util.Collection<Node> nodes,
                                 int d,
                                 double threshold)
Description copied from interface: NodeStructure
Returns a copy of a subgraph of this NodeStructure. The subgraph will contain all specified nodes with activation at or above specified threshold if they are currently present in the NodeStructure. Additionally all other nodes having distance, the number of links, less or equal to d from the specified nodes and that have sufficient activation are part of the subgraph. If a Node has insufficient activation then the depth-first search will not continue further from that Node. Finally all links that connect two Linkable elements that are both d or less from the specified nodes are included in the subgraph.

Specified by:
getSubgraph in interface NodeStructure
Parameters:
nodes - the nodes which will be the roots from which the subgraph will be formed
d - the greatest distance a node can be from a specified nodes to be included in the subgraph
threshold - activation requirement for a node to be part of the subgraph.
Returns:
A copy of a subgraph of this NodeStructure which involves specified and all satisfied neighbor nodes

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

compareNodeStructures

public static boolean compareNodeStructures(NodeStructure ns1,
                                            NodeStructure ns2)
Returns true if two NodeStructures are meaningfully equal, else false. Two NodeStructures are equal if they have the same exact nodes and links and the nodes and links are of the same type.

Parameters:
ns1 - first NodeStructure
ns2 - second NodeStructure
Returns:
boolean if the NodeStructures are equal