|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectedu.memphis.ccrg.lida.framework.shared.NodeStructureImpl
public class NodeStructureImpl
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.
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 |
|---|
public NodeStructureImpl()
public NodeStructureImpl(java.lang.String nodeType,
java.lang.String linkType)
nodeType - kind of node used in this NodeStructurelinkType - kind of link used in this NodeStructureElementFactorypublic NodeStructureImpl(NodeStructure ns)
ns - original NodeStructuremergeWith(NodeStructure)| Method Detail |
|---|
public Node addDefaultNode(Node n)
NodeStructureNode 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.
addDefaultNode in interface NodeStructuren - Node to add.
public java.util.Collection<Node> addDefaultNodes(java.util.Collection<Node> nodes)
addDefaultNodes in interface NodeStructurenodes - Node to be added.
NodeStructure.addDefaultNode(Node)
public Node addNode(Node n,
java.lang.String type)
NodeStructure
addNode in interface NodeStructuren - Nodetype - name of node's type in ElementFactory
public Node addDefaultNode(java.lang.String label,
double a,
double rt)
NodeStructureNode of default type with specified attributes.
addDefaultNode in interface NodeStructurelabel - label of new Nodea - initial activation of new Nodert - initial removal threshold of new Node
Node added to the NodeStructure or null
public Node addNode(java.lang.String type,
java.lang.String label,
double a,
double rt)
NodeStructureNode of specified type with specified attributes.
addNode in interface NodeStructuretype - Factory type of new Nodelabel - label of new Nodea - initial activation of new Nodert - initial removal threshold of new Node
Node added to the NodeStructure or null
protected Node addNode(Node n,
boolean shouldCopy)
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.
n - the Node to addshouldCopy - determines if the node is copied or not.
protected Node getNewNode(Node oNode,
java.lang.String desiredType)
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.
oNode - The original Node or nulldesiredType - the ElementFactory name of the desired node type
ElementFactory.getNode(String, Node, String)public Link addDefaultLink(Link l)
NodeStructureLink, 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.
addDefaultLink in interface NodeStructurel - Link to copy and add.
public java.util.Collection<Link> addDefaultLinks(java.util.Collection<Link> links)
NodeStructureNodeStructure 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.
addDefaultLinks in interface NodeStructurelinks - Links to copy and add.
public Link addLink(Link l,
java.lang.String type)
NodeStructure
addLink in interface NodeStructurel - original Linktype - type of copied Link
Link or null if such a link cannot be created.
public Link addDefaultLink(Node source,
Linkable sink,
LinkCategory category,
double activation,
double removalThreshold)
NodeStructure
addDefaultLink in interface NodeStructuresource - Link's source Nodesink - Link's sink, a Node or a Linkcategory - Link's LinkCategoryactivation - initial link activationremovalThreshold - amount of activation Link must maintain to remain in this NodeStructure after decaying.
public Link addDefaultLink(int sourceId,
ExtendedId sinkId,
LinkCategory category,
double activation,
double removalThreshold)
NodeStructure
addDefaultLink in interface NodeStructuresourceId - id of link's sourcesinkId - ExtendedId of link's sinkcategory - Link's LinkCategoryactivation - initial link activationremovalThreshold - amount of activation Link must maintain to remain in this NodeStructure after decaying.
public Link addDefaultLink(int sourceId,
int sinkId,
LinkCategory cat,
double activation,
double removalThreshold)
NodeStructure
addDefaultLink in interface NodeStructuresourceId - id of link's sourcesinkId - id of link's sinkcat - Link's LinkCategoryactivation - initial link activationremovalThreshold - amount of activation Link must maintain to remain in this NodeStructure after decaying.
public Link addLink(java.lang.String type,
Node src,
Linkable sink,
LinkCategory cat,
double a,
double rt)
NodeStructureLink of specified type with specified attributes. Source and sink must
already be in this NodeStructure.
addLink in interface NodeStructuretype - Factory type of the link to be createdsrc - the link's source Nodesink - the link's sink Linkablecat - the link's LinkCategorya - initial link activationrt - removal threshold, amount of activation Link must maintain to remain in this NodeStructure after decaying.
public Link addLink(java.lang.String type,
int srcId,
ExtendedId snkId,
LinkCategory cat,
double a,
double rt)
NodeStructureLink of specified type with specified attributes. Source and sink must
already be in this NodeStructure.
addLink in interface NodeStructuretype - Factory type of the link to be createdsrcId - id of link's sourcesnkId - ExtendedId of link's sinkcat - Link's LinkCategorya - initial link activationrt - removal threshold, amount of activation Link must maintain to remain in this NodeStructure after decaying.
protected Link getNewLink(Link oLink,
java.lang.String newType,
Node src,
Linkable snk,
LinkCategory cat)
oLink - original LinknewType - the ElementFactory name of the new Link typesrc - The new sourcesnk - The new sinkcat - the type of the link
public NodeStructure copy()
NodeStructureNodeStructure.
copy in interface NodeStructureNodeStructurepublic void mergeWith(NodeStructure ns)
NodeStructure
mergeWith in interface NodeStructurens - NodeStructurepublic void removeNode(Node n)
NodeStructureNode if present.
removeNode in interface NodeStructuren - Node to remove.public void removeLink(Link l)
NodeStructureLink if present.
removeLink in interface NodeStructurel - Link to remove.public void removeLinkable(Linkable linkable)
NodeStructureLinkable if present.
removeLinkable in interface NodeStructurelinkable - Linkable to remove.public void removeLinkable(ExtendedId id)
NodeStructureLinkable with specified ExtendedId if present.
removeLinkable in interface NodeStructureid - ExtendedId of Linkable to remove.public void clearLinks()
NodeStructureNodeStructure.
clearLinks in interface NodeStructurepublic void clearNodeStructure()
NodeStructure
clearNodeStructure in interface NodeStructurepublic void decayNodeStructure(long ticks)
NodeStructureLinkables of this NodeStructure.
decayNodeStructure in interface NodeStructureticks - the number of ticks to decay for.public Node getNode(int id)
NodeStructure
getNode in interface NodeStructureid - id of node
public Node getNode(ExtendedId id)
NodeStructureExtendedId.
getNode in interface NodeStructureid - ExtendedId of node
public java.util.Collection<Node> getNodes()
NodeStructureNodes.
getNodes in interface NodeStructureNodes in this NodeStructurepublic int getNodeCount()
NodeStructure
getNodeCount in interface NodeStructurepublic Link getLink(ExtendedId id)
NodeStructureLink with specified ExtendedId if present.
getLink in interface NodeStructureid - ExtendedId of sought Link
public java.util.Set<Link> getLinks(LinkCategory cat)
NodeStructureLinkCategory.
getLinks in interface NodeStructurecat - the LinkCategory to search for
LinkCategorypublic java.util.Collection<Link> getLinks()
NodeStructure
getLinks in interface NodeStructureUnmodifiableCollection of all Linkspublic int getLinkCount()
NodeStructure
getLinkCount in interface NodeStructurepublic Linkable getLinkable(ExtendedId ids)
NodeStructureLinkable with specified ExtendedId.
getLinkable in interface NodeStructureids - ExtendedId
public java.util.Collection<Linkable> getLinkables()
NodeStructureNodeStructure.
getLinkables in interface NodeStructurepublic java.util.Map<Linkable,java.util.Set<Link>> getLinkableMap()
NodeStructureLinkable objects currently in the NodeStructure and their attached links.
getLinkableMap in interface NodeStructureUnmodifiableMap of the Linkable objects in this NodeStructure and their attached links.public int getLinkableCount()
NodeStructure
getLinkableCount in interface NodeStructureLinkable objects currently in the NodeStructurepublic java.util.Set<Link> getAttachedLinks(Linkable lnk)
NodeStructureLink objects directly connected to specified Linkable.
getAttachedLinks in interface NodeStructurelnk - the Linkable whose attached links will be returned
UnmodifiableSet of all Links connected to specified Linkable
public java.util.Set<Link> getAttachedLinks(Linkable lnk,
LinkCategory cat)
NodeStructureLinks directly connected to specified Linkable with specified LinkCategory
getAttachedLinks in interface NodeStructurelnk - a Linkablecat - LinkCategory
public java.util.Map<Node,Link> getConnectedSources(Linkable lnk)
NodeStructureMap 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
getConnectedSources in interface NodeStructurelnk - the Linkable whose connected sources will be returned
Map of all sources connected to lnk and the links connecting them to lnkpublic java.util.Map<Linkable,Link> getConnectedSinks(Node n)
NodeStructureMap 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.
getConnectedSinks in interface NodeStructuren - supplied node
public java.lang.String getDefaultLinkType()
NodeStructureLink type of the NodeStructure.
getDefaultLinkType in interface NodeStructureLink objects in the NodeStructurepublic java.lang.String getDefaultNodeType()
NodeStructureNode type of the NodeStructure.
getDefaultNodeType in interface NodeStructureNode objects in the NodeStructurepublic boolean containsNode(Node n)
NodeStructure
containsNode in interface NodeStructuren - Node checked for.
public boolean containsNode(int id)
NodeStructure
containsNode in interface NodeStructureid - id of Node checked for.
public boolean containsNode(ExtendedId id)
NodeStructure
containsNode in interface NodeStructureid - ExtendedId of Node checked for.
public boolean containsLink(Link l)
NodeStructure
containsLink in interface NodeStructurel - Link checked for.
public boolean containsLink(ExtendedId id)
NodeStructureExtendedId.
containsLink in interface NodeStructureid - Link checked for.
Link with the same ExtendedId.public boolean containsLinkable(Linkable l)
NodeStructureLinkable.
containsLinkable in interface NodeStructurel - Linkable checked for.
Linkable with the same ExtendedId.public boolean containsLinkable(ExtendedId id)
NodeStructureLinkable with specified ExtendedId.
containsLinkable in interface NodeStructureid - Linkable checked for.
Linkable with the same ExtendedId.
public NodeStructure getSubgraph(java.util.Collection<Node> nodes,
int d)
NodeStructureNodeStructure.
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.
getSubgraph in interface NodeStructurenodes - the nodes which will be the roots from which the subgraph will be formedd - the greatest distance a node can be from a specified nodes to be included in the subgraph
public NodeStructure getSubgraph(java.util.Collection<Node> nodes,
int d,
double threshold)
NodeStructureNodeStructure.
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.
getSubgraph in interface NodeStructurenodes - the nodes which will be the roots from which the subgraph will be formedd - the greatest distance a node can be from a specified nodes to be included in the subgraphthreshold - activation requirement for a node to be part of the subgraph.
public java.lang.String toString()
toString in class java.lang.Object
public static boolean compareNodeStructures(NodeStructure ns1,
NodeStructure ns2)
ns1 - first NodeStructurens2 - second NodeStructure
NodeStructures are equal
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||