public class DynamicHashNetwork extends java.lang.Object implements DynamicNetwork
dynamic network
. This is a simple
implementation which wraps around multiple instances of Network
objects. Each of these instances represent a moment in time in which
nodes or links were added.Constructor and Description |
---|
DynamicHashNetwork()
Constructor
Starts with a dynamic network with an initial time instant of 0, this
represents an initial state of the network.
|
Modifier and Type | Method and Description |
---|---|
Link |
addLink(Node node1,
Node node2)
Adds a Link to the graph.
|
boolean |
addLink(Node node1,
Node node2,
Link link)
Creates and adds a link to the network between the given nodes.
|
boolean |
addNode(Node node)
Adds a node to the network.
|
boolean |
containsDirectedLink(Node node1,
Node node2)
Returns true of the given link is in the network.
|
boolean |
containsLink(Link link)
Returns true of the given link is in the network.
|
boolean |
containsLink(Node node1,
Node node2)
Returns true of the given link is in the network.
|
boolean |
containsNode(Node node)
Returns true of the given node is in the network.
|
Link |
createLink()
Creates a new link that can be added to the network.
|
Node |
createNode()
Creates a new node that can be added to the network.
|
int |
getCurrentTime()
Returns the current time instant in which you are working
|
int |
getFirstTime()
Returns the first time instant of this network
|
java.util.Collection<? extends Link> |
getInLinks(Node node)
Returns a collection of links coming to the given node from other
nodes.
|
int |
getLastTime()
Returns the last time instant of this network
|
Link |
getLink(int id)
Returns a link by its Integer id or null if the node does not exist.
|
Link |
getLink(Node node1,
Node node2)
Returns a link given the two nodes it connects.
|
int |
getLinkCount()
Returns the number of links in the network.
|
java.util.Collection<? extends Link> |
getLinks()
Returns a collection of all the links in the network.
|
java.util.Collection<? extends Link> |
getLinks(Node node)
Returns a collection of links attached to the given node.
|
java.util.Collection<? extends Node> |
getNeighbours(int id)
Returns a collection of nodes attached to the node with the given id by
some link.
|
java.util.Collection<? extends Node> |
getNeighbours(Node node)
Returns a collection of nodes attached to the given node by some link.
|
Node |
getNode(int id)
Returns a node by its Integer id or null if the node does not exist.
|
int |
getNodeCount()
Returns the number of nodes in the network.
|
java.util.Collection<? extends Node> |
getNodes()
Returns a collection of all the nodes in the network.
|
org.apache.commons.lang3.tuple.Pair<Node,Node> |
getNodes(int linkID)
Returns the two nodes attached to a link with the given id.
|
org.apache.commons.lang3.tuple.Pair<Node,Node> |
getNodes(Link link)
Returns the two nodes that the given link connects.
|
java.util.Collection<? extends Link> |
getOutLinks(Node node)
Returns a collection of links coming from the given node to other
nodes.
|
java.util.Collection<? extends Node> |
getPredecessors(Node node)
Returns a collection of nodes attached to links coming to the given node.
|
java.util.Collection<? extends Node> |
getSuccessors(Node node)
Returns a collection of nodes attached to link coming from the given
node.
|
java.util.Set<? extends java.lang.Integer> |
getTimeInstances()
Returns the set of time instances for which there are events of node /
link insertion, etc.
|
boolean |
removeLink(int id)
Removes a link from the network based on its id.
|
boolean |
removeLink(Link link)
Removes a link from the network.
|
boolean |
removeNode(int id)
Removes a node from the network based on its ID.
|
boolean |
removeNode(Node node)
Removes a node from the network.
|
void |
setCurrentTime(int t)
Changes the current time instant of this dynamic network.
|
@Inject public DynamicHashNetwork()
setTime
operation, this
network works exactly like a normal network would.public boolean addNode(Node node)
Network
public Link addLink(Node node1, Node node2)
Network
public boolean addLink(Node node1, Node node2, Link link)
Network
public boolean removeNode(Node node)
Network
removeNode
in interface Network
node
- the node to be removedpublic boolean removeNode(int id)
Network
removeNode
in interface Network
id
- the id of the node to be removedpublic boolean removeLink(Link link)
Network
removeLink
in interface Network
link
- the link to be removedpublic boolean removeLink(int id)
Network
removeLink
in interface Network
id
- the id of the link to be removedpublic Node getNode(int id)
Network
public Link getLink(int id)
Network
public Link getLink(Node node1, Node node2)
Network
public java.util.Collection<? extends Link> getLinks(Node node)
Network
public java.util.Collection<? extends Link> getOutLinks(Node node)
Network
getOutLinks
in interface Network
node
- the node from which we wish to extract the links from.public java.util.Collection<? extends Link> getInLinks(Node node)
Network
getInLinks
in interface Network
node
- the node from which we wish to extract the links from.public java.util.Collection<? extends Node> getSuccessors(Node node)
Network
getSuccessors
in interface Network
node
- the current node we want the successors frompublic java.util.Collection<? extends Node> getPredecessors(Node node)
Network
getPredecessors
in interface Network
node
- the current node we want the predecessors frompublic java.util.Collection<? extends Node> getNeighbours(Node node)
Network
getNeighbours
in interface Network
node
- the node we want the neighbours from.public java.util.Collection<? extends Node> getNeighbours(int id)
Network
getNeighbours
in interface Network
id
- the id of the node we want the neighbours from.public java.util.Collection<? extends Node> getNodes()
Network
public java.util.Collection<? extends Link> getLinks()
Network
public org.apache.commons.lang3.tuple.Pair<Node,Node> getNodes(int linkID)
Network
getNodes
in interface Network
linkID
- the id of the link from which we want to retrieve the nodes.(from org.apache.commons.lang3.tuple.Pair )
public org.apache.commons.lang3.tuple.Pair<Node,Node> getNodes(Link link)
Network
getNodes
in interface Network
link
- the link from which we want to extract the nodes.(from org.apache.commons.lang3.tuple.Pair )
public int getNodeCount()
Network
getNodeCount
in interface Network
public int getLinkCount()
Network
getLinkCount
in interface Network
public boolean containsNode(Node node)
Network
containsNode
in interface Network
node
- a node we want to checkpublic boolean containsLink(Link link)
Network
containsLink
in interface Network
link
- a link we want to checkpublic Node createNode()
Network
createNode
in interface Network
Node
public Link createLink()
Network
createLink
in interface Network
Link
public boolean containsLink(Node node1, Node node2)
Network
containsLink
in interface Network
node1
- one of the nodes for the linknode2
- one of the nodes for the linkpublic boolean containsDirectedLink(Node node1, Node node2)
Network
containsDirectedLink
in interface Network
node1
- one of the nodes for the linknode2
- one of the nodes for the linkpublic void setCurrentTime(int t)
setCurrentTime
in interface DynamicNetwork
t
- a discrete time with t >= 0public int getCurrentTime()
DynamicNetwork
getCurrentTime
in interface DynamicNetwork
public java.util.Set<? extends java.lang.Integer> getTimeInstances()
DynamicNetwork
getTimeInstances
in interface DynamicNetwork
public int getLastTime()
DynamicNetwork
getLastTime
in interface DynamicNetwork
public int getFirstTime()
DynamicNetwork
getFirstTime
in interface DynamicNetwork