|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object edu.memphis.ccrg.lida.framework.shared.UnmodifiableNodeStructureImpl
public class UnmodifiableNodeStructureImpl
An immutable NodeStructureImpl. Throws UnsupportedOperationException
if any methods
which modify NodeStructureImpl
are called.
Constructor Summary | |
---|---|
UnmodifiableNodeStructureImpl(NodeStructure src)
Default Constructor. |
|
UnmodifiableNodeStructureImpl(NodeStructure src,
boolean shouldCopy)
Copy Constructor. |
Method Summary | |
---|---|
Link |
addDefaultLink(int idSource,
ExtendedId idSink,
LinkCategory type,
double activation,
double removalThreshold)
Creates and adds a new Link of default type with specified attributes. |
Link |
addDefaultLink(int idSource,
int idSink,
LinkCategory type,
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 linkType)
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. |
Node |
addNode(Node n,
java.lang.String factoryType)
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. |
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 Linkable s of this NodeStructure . |
boolean |
equals(java.lang.Object o)
Returns true if both NodeStructures have the same nodes and links. |
java.util.Set<Link> |
getAttachedLinks(Linkable l)
Gets all Link objects directly connected to specified Linkable . |
java.util.Set<Link> |
getAttachedLinks(Linkable linkable,
LinkCategory cat)
Gets all Link s 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 linkable)
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 ids)
Gets Link with specified ExtendedId if present. |
Linkable |
getLinkable(ExtendedId eid)
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 . |
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()
Gets the number of nodes. |
java.util.Collection<Node> |
getNodes()
Returns all Node s. |
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 . |
int |
hashCode()
|
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. |
java.lang.String |
toString()
|
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public UnmodifiableNodeStructureImpl(NodeStructure src)
src
- supplied NodeStructurepublic UnmodifiableNodeStructureImpl(NodeStructure src, boolean shouldCopy)
src
- supplied NodeStructureshouldCopy
- If true, the supplied NodeStructure will be copied. Otherwise supplied NodeStructure
will be used directly.Method Detail |
---|
public boolean equals(java.lang.Object o)
equals
in class java.lang.Object
o
- ObjectObject.equals(java.lang.Object)
public int hashCode()
hashCode
in class java.lang.Object
public NodeStructure copy()
NodeStructure
NodeStructure
.
copy
in interface NodeStructure
NodeStructure
public Link addDefaultLink(Link l)
NodeStructure
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.
addDefaultLink
in interface NodeStructure
l
- Link to copy and add.
java.lang.UnsupportedOperationException
- Cannot modify this object once created.public Link addDefaultLink(int idSource, ExtendedId idSink, LinkCategory type, double activation, double removalThreshold)
NodeStructure
addDefaultLink
in interface NodeStructure
idSource
- id of link's sourceidSink
- ExtendedId
of link's sinktype
- Link's LinkCategory
activation
- initial link activationremovalThreshold
- amount of activation Link must maintain to remain in this NodeStructure after decaying.
java.lang.UnsupportedOperationException
- Cannot modify this object once created.public Link addDefaultLink(int idSource, int idSink, LinkCategory type, double activation, double removalThreshold)
NodeStructure
addDefaultLink
in interface NodeStructure
idSource
- id of link's sourceidSink
- id of link's sinktype
- Link's LinkCategory
activation
- initial link activationremovalThreshold
- amount of activation Link must maintain to remain in this NodeStructure after decaying.
java.lang.UnsupportedOperationException
- Cannot modify this object once created.public java.util.Collection<Link> addDefaultLinks(java.util.Collection<Link> links)
NodeStructure
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.
addDefaultLinks
in interface NodeStructure
links
- Links to copy and add.
java.lang.UnsupportedOperationException
- Cannot modify this object once created.public Node addDefaultNode(Node n)
NodeStructure
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.
addDefaultNode
in interface NodeStructure
n
- Node to add.
java.lang.UnsupportedOperationException
- Cannot modify this object once created.public Link addLink(Link l, java.lang.String linkType)
NodeStructure
addLink
in interface NodeStructure
l
- original Link
linkType
- type of copied Link
Link
or null if such a link cannot be created.
java.lang.UnsupportedOperationException
- Cannot modify this object once created.public Node addNode(Node n, java.lang.String factoryType)
NodeStructure
addNode
in interface NodeStructure
n
- NodefactoryType
- name of node's type in ElementFactory
java.lang.UnsupportedOperationException
- Cannot modify this object once created.public java.util.Collection<Node> addDefaultNodes(java.util.Collection<Node> nodes)
addDefaultNodes
in interface NodeStructure
nodes
- Node to be added.
java.lang.UnsupportedOperationException
- Cannot modify this object once created.NodeStructure.addDefaultNode(Node)
public void removeLink(Link l)
NodeStructure
Link
if present.
removeLink
in interface NodeStructure
l
- Link to remove.
java.lang.UnsupportedOperationException
- Cannot modify this object once created.public void removeLinkable(Linkable l)
NodeStructure
Linkable
if present.
removeLinkable
in interface NodeStructure
l
- Linkable to remove.
java.lang.UnsupportedOperationException
- Cannot modify this object once created.public void removeNode(Node n)
NodeStructure
Node
if present.
removeNode
in interface NodeStructure
n
- Node to remove.
java.lang.UnsupportedOperationException
- Cannot modify this object once created.public void removeLinkable(ExtendedId id)
NodeStructure
Linkable
with specified ExtendedId
if present.
removeLinkable
in interface NodeStructure
id
- ExtendedId of Linkable to remove.
java.lang.UnsupportedOperationException
- Cannot modify this object once created.public void clearLinks()
NodeStructure
NodeStructure
.
clearLinks
in interface NodeStructure
java.lang.UnsupportedOperationException
- Cannot modify this object once created.public void clearNodeStructure()
NodeStructure
clearNodeStructure
in interface NodeStructure
java.lang.UnsupportedOperationException
- Cannot modify this object once created.public void mergeWith(NodeStructure ns)
NodeStructure
mergeWith
in interface NodeStructure
ns
- NodeStructure
java.lang.UnsupportedOperationException
- Cannot modify this object once created.public Link addDefaultLink(Node source, Linkable sink, LinkCategory category, double activation, double removalThreshold)
NodeStructure
addDefaultLink
in interface NodeStructure
source
- Link's source Node
sink
- Link's sink, a Node
or a Link
category
- Link's LinkCategory
activation
- initial link activationremovalThreshold
- amount of activation Link must maintain to remain in this NodeStructure after decaying.
java.lang.UnsupportedOperationException
- Cannot modify this object once created.public Node addDefaultNode(java.lang.String label, double a, double rt)
NodeStructure
Node
of default type with specified attributes.
addDefaultNode
in interface NodeStructure
label
- label of new Node
a
- initial activation of new Node
rt
- initial removal threshold of new Node
Node
added to the NodeStructure or null
java.lang.UnsupportedOperationException
- Cannot modify this object once created.public Link addLink(java.lang.String type, int srcId, ExtendedId snkId, LinkCategory cat, double a, double rt)
NodeStructure
Link
of specified type with specified attributes. Source and sink must
already be in this NodeStructure.
addLink
in interface NodeStructure
type
- Factory type of the link to be createdsrcId
- id of link's sourcesnkId
- ExtendedId
of link's sinkcat
- Link's LinkCategory
a
- initial link activationrt
- removal threshold, amount of activation Link must maintain to remain in this NodeStructure after decaying.
java.lang.UnsupportedOperationException
- Cannot modify this object once created.public Node addNode(java.lang.String type, java.lang.String label, double a, double rt)
NodeStructure
Node
of specified type with specified attributes.
addNode
in interface NodeStructure
type
- Factory type of new Node
label
- label of new Node
a
- initial activation of new Node
rt
- initial removal threshold of new Node
Node
added to the NodeStructure or null
java.lang.UnsupportedOperationException
- Cannot modify this object once created.public Link addLink(java.lang.String type, Node src, Linkable sink, LinkCategory cat, double a, double rt)
NodeStructure
Link
of specified type with specified attributes. Source and sink must
already be in this NodeStructure.
addLink
in interface NodeStructure
type
- Factory type of the link to be createdsrc
- the link's source Node
sink
- the link's sink Linkable
cat
- the link's LinkCategory
a
- initial link activationrt
- removal threshold, amount of activation Link must maintain to remain in this NodeStructure after decaying.
java.lang.UnsupportedOperationException
- Cannot modify this object once created.public void decayNodeStructure(long ticks)
NodeStructure
Linkable
s of this NodeStructure
.
decayNodeStructure
in interface NodeStructure
ticks
- the number of ticks to decay for.
java.lang.UnsupportedOperationException
- Cannot modify this object once created.public boolean containsLink(Link l)
NodeStructure
containsLink
in interface NodeStructure
l
- Link checked for.
public boolean containsLink(ExtendedId id)
NodeStructure
ExtendedId
.
containsLink
in interface NodeStructure
id
- Link checked for.
Link
with the same ExtendedId
.public boolean containsLinkable(Linkable l)
NodeStructure
Linkable
.
containsLinkable
in interface NodeStructure
l
- Linkable
checked for.
Linkable
with the same ExtendedId
.public boolean containsLinkable(ExtendedId id)
NodeStructure
Linkable
with specified ExtendedId
.
containsLinkable
in interface NodeStructure
id
- Linkable
checked for.
Linkable
with the same ExtendedId
.public boolean containsNode(Node n)
NodeStructure
containsNode
in interface NodeStructure
n
- Node checked for.
public boolean containsNode(int id)
NodeStructure
containsNode
in interface NodeStructure
id
- id of Node checked for.
public boolean containsNode(ExtendedId id)
NodeStructure
containsNode
in interface NodeStructure
id
- ExtendedId of Node checked for.
public java.util.Set<Link> getAttachedLinks(Linkable l)
NodeStructure
Link
objects directly connected to specified Linkable
.
getAttachedLinks
in interface NodeStructure
l
- the Linkable whose attached links will be returned
UnmodifiableSet
of all Links connected to specified Linkable
public java.util.Set<Link> getAttachedLinks(Linkable linkable, LinkCategory cat)
NodeStructure
Link
s directly connected to specified Linkable
with specified LinkCategory
getAttachedLinks
in interface NodeStructure
linkable
- a Linkable
cat
- LinkCategory
public java.util.Map<Linkable,Link> getConnectedSinks(Node n)
NodeStructure
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
.
getConnectedSinks
in interface NodeStructure
n
- supplied node
public java.util.Map<Node,Link> getConnectedSources(Linkable linkable)
NodeStructure
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
getConnectedSources
in interface NodeStructure
linkable
- the Linkable
whose connected sources will be returned
Map
of all sources connected to lnk and the links connecting them to lnkpublic java.lang.String getDefaultLinkType()
NodeStructure
Link
type of the NodeStructure.
getDefaultLinkType
in interface NodeStructure
Link
objects in the NodeStructurepublic java.lang.String getDefaultNodeType()
NodeStructure
Node
type of the NodeStructure.
getDefaultNodeType
in interface NodeStructure
Node
objects in the NodeStructurepublic Link getLink(ExtendedId ids)
NodeStructure
Link
with specified ExtendedId
if present.
getLink
in interface NodeStructure
ids
- ExtendedId
of sought Link
public int getLinkCount()
NodeStructure
getLinkCount
in interface NodeStructure
public Linkable getLinkable(ExtendedId eid)
NodeStructure
Linkable
with specified ExtendedId
.
getLinkable
in interface NodeStructure
eid
- ExtendedId
public int getLinkableCount()
NodeStructure
getLinkableCount
in interface NodeStructure
Linkable
objects currently in the NodeStructurepublic java.util.Map<Linkable,java.util.Set<Link>> getLinkableMap()
NodeStructure
Linkable
objects currently in the NodeStructure and their attached links.
getLinkableMap
in interface NodeStructure
UnmodifiableMap
of the Linkable
objects in this NodeStructure and their attached links.public java.util.Collection<Linkable> getLinkables()
NodeStructure
NodeStructure
.
getLinkables
in interface NodeStructure
public java.util.Collection<Link> getLinks()
NodeStructure
getLinks
in interface NodeStructure
UnmodifiableCollection
of all Linkspublic java.util.Set<Link> getLinks(LinkCategory cat)
NodeStructure
LinkCategory
.
getLinks
in interface NodeStructure
cat
- the LinkCategory
to search for
LinkCategory
public Node getNode(int id)
NodeStructure
getNode
in interface NodeStructure
id
- id of node
public Node getNode(ExtendedId eid)
NodeStructure
ExtendedId
.
getNode
in interface NodeStructure
eid
- ExtendedId of node
public int getNodeCount()
NodeStructure
getNodeCount
in interface NodeStructure
public java.util.Collection<Node> getNodes()
NodeStructure
Node
s.
getNodes
in interface NodeStructure
Node
s in this NodeStructurepublic java.lang.String toString()
toString
in class java.lang.Object
public NodeStructure getSubgraph(java.util.Collection<Node> nodes, int d)
NodeStructure
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.
getSubgraph
in interface NodeStructure
nodes
- 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)
NodeStructure
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.
getSubgraph
in interface NodeStructure
nodes
- 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.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |