urv.util.graph
Class NetworkGraph<N,W>

java.lang.Object
  extended by urv.util.graph.NetworkGraph<N,W>
All Implemented Interfaces:
java.io.Serializable, BandwidthUpdatable

public class NetworkGraph<N,W>
extends java.lang.Object
implements java.io.Serializable, BandwidthUpdatable

This class represents file network in edge-list terms A node list is also stored, necessary for mapping from file to net ids

Author:
Marcel Arrufat
See Also:
Serialized Form

Constructor Summary
NetworkGraph()
           
 
Method Summary
 void addEdge(N source, N target, Weight weight)
          Add a new (directed) Edge to the network structure
 void addNode(N node)
          Add a new node to network structure This structure will be needed when mapping fileIds into netIds
 boolean areLinked(N node1, N node2)
          Checks is node1 has node2 as neighbour or node2 has node1 as neighbour
 boolean areNeighbours(N node1, N node2)
          Checks is node1 has node2 has neighbour
 void assignWeightToAllEdges(java.lang.Float float1)
           
 void clear()
          Empties the graph, nodes, edges and neighbours
 java.lang.Object clone()
           
 Edge getEdgeBetween(N node1, N node2)
           
 java.util.LinkedList<Edge> getEdges()
          Return edge list from actual network graph
 java.util.LinkedList<Edge> getEdges(N node)
          Return edge list where the node n is the source or the target
 java.util.Set<N> getLinkedNodes(N node1)
          Returns a list of nodes that are in the neighbor list of node1 or that have node1 in their own neighbor list
 java.util.Set<N> getNeighbours(N node1)
          Returns a list of neighbours of the current node
 int getNetworkSize()
          Returns the total number of nodes in the network
 java.util.Set<N> getNodeList()
          Return node list from actual network graph
 java.util.HashSet<N> getSubtree(N node1)
          Returns all the nodes under the current node (in a directed graph) without the current node
 void removeEdge(N src, N dst, Weight w)
          Removes an edge from the graph
 void removeEdges(N node)
          Removes edges where the node n is the source or the target.
 void removeEdges(N node1, N node2)
          Removes edges that link either node1 to node2 or node2 to node1
 void removeEdgesWithTarget(N node)
          Removes edges that have node as target
 void removeIsolatedNodes()
           
 java.lang.String toPajek(java.lang.String fileName, boolean writeFile)
          Method that allows to print the network graph into a pajek file
 java.lang.String toString()
          Prints the list of nodes and edges
 void updateBwOf(OLSRNode node)
           
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

NetworkGraph

public NetworkGraph()
Method Detail

clone

public java.lang.Object clone()
Overrides:
clone in class java.lang.Object

toString

public java.lang.String toString()
Prints the list of nodes and edges

Overrides:
toString in class java.lang.Object

updateBwOf

public void updateBwOf(OLSRNode node)
Specified by:
updateBwOf in interface BandwidthUpdatable

addEdge

public void addEdge(N source,
                    N target,
                    Weight weight)
Add a new (directed) Edge to the network structure

Parameters:
source -
target -
weight -

addNode

public void addNode(N node)
Add a new node to network structure This structure will be needed when mapping fileIds into netIds

Parameters:
node -

areLinked

public boolean areLinked(N node1,
                         N node2)
Checks is node1 has node2 as neighbour or node2 has node1 as neighbour

Parameters:
node1 -
node2 -
Returns:

areNeighbours

public boolean areNeighbours(N node1,
                             N node2)
Checks is node1 has node2 has neighbour

Parameters:
node1 -
node2 -
Returns:

assignWeightToAllEdges

public void assignWeightToAllEdges(java.lang.Float float1)

clear

public void clear()
Empties the graph, nodes, edges and neighbours


getEdgeBetween

public Edge getEdgeBetween(N node1,
                           N node2)

getEdges

public java.util.LinkedList<Edge> getEdges()
Return edge list from actual network graph

Returns:

getEdges

public java.util.LinkedList<Edge> getEdges(N node)
Return edge list where the node n is the source or the target

Returns:

getLinkedNodes

public java.util.Set<N> getLinkedNodes(N node1)
Returns a list of nodes that are in the neighbor list of node1 or that have node1 in their own neighbor list

Parameters:
node1 -
Returns:

getNeighbours

public java.util.Set<N> getNeighbours(N node1)
Returns a list of neighbours of the current node

Parameters:
node1 -
Returns:

getNetworkSize

public int getNetworkSize()
Returns the total number of nodes in the network

Returns:
nodes in the network

getNodeList

public java.util.Set<N> getNodeList()
Return node list from actual network graph

Returns:

getSubtree

public java.util.HashSet<N> getSubtree(N node1)
Returns all the nodes under the current node (in a directed graph) without the current node

Parameters:
node1 -
Returns:

removeEdge

public void removeEdge(N src,
                       N dst,
                       Weight w)
Removes an edge from the graph

Parameters:
src -
dst -
w -

removeEdges

public void removeEdges(N node)
Removes edges where the node n is the source or the target. It also removes the node


removeEdges

public void removeEdges(N node1,
                        N node2)
Removes edges that link either node1 to node2 or node2 to node1


removeEdgesWithTarget

public void removeEdgesWithTarget(N node)
Removes edges that have node as target

Parameters:
node -

removeIsolatedNodes

public void removeIsolatedNodes()

toPajek

public java.lang.String toPajek(java.lang.String fileName,
                                boolean writeFile)
Method that allows to print the network graph into a pajek file