Constructor and Description |
---|
HashNetwork()
Constructor.
|
HashNetwork(HashNetwork network) |
Modifier and Type | Method and Description |
---|---|
SimpleLink |
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.
|
SimpleLink |
createLink()
Creates a new link that can be added to the network.
|
SimpleNode |
createNode()
Creates a new node that can be added to the network.
|
java.util.Collection<? extends Link> |
getInLinks(Node node)
Returns a collection of links coming to the given node from other
nodes.
|
Link |
getLink(int id)
Returns a link by its Integer id or null if the node does not exist.
|
SimpleLink |
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.
|
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.
|
@Inject public HashNetwork()
public HashNetwork(HashNetwork network)
public boolean addNode(Node node)
Network
public SimpleLink 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 SimpleLink getLink(Node node1, Node node2)
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 Link> getLinks(Node node)
Network
public 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 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 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 SimpleNode createNode()
Network
createNode
in interface Network
Node
public SimpleLink createLink()
Network
createLink
in interface Network
Link
public java.util.Collection<? extends Node> getNodes()
Network
public java.util.Collection<? extends Link> getLinks()
Network
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 link