com.hp.hpl.guess.layout
Class NetUtilities

java.lang.Object
  extended bycom.hp.hpl.guess.layout.NetUtilities

public class NetUtilities
extends Object

Performs various common operations on passed networks and returns them, and/or returns a statistic on a passed network and returns the result. Please note that these may be fairly "naive" algorithm implementations, and no guarantees are made about the accuracy of the statistics. The intention is that these may be used for "on the fly" qualitative evaluation of a model, but real network statistics should be done with more serious software such as UCINET or Pajek.

ALL THE METHODS CAN BE CONSIDERED BETA AND SHOULD ONLY BE USED FOR "ON THE FLY" CALCULATIONS. ACTUAL NETWORK STATISTICS SHOULD BE DONE WITH DEDICATED NETWORK ANALYSIS SOFTWARE, SUCH AS PAJEK OR UCINET.

Version:
$Revision: 1.1 $ $Date: 2005/10/05 20:19:39 $
Author:
Skye Bender-deMoll

Constructor Summary
NetUtilities()
          No-Argument constructor for convenience / aliasing.
 
Method Summary
static double calcDensity(Set nodes)
          calculates density (ratio of arcs in network to maximum possible number of arcs) of passed network.
static double calcDensity(Set nodes, boolean collapseMulti)
          Calculates density of the network, but if collapseMulti is true, it first collapses any multiplex ties.
static cern.colt.matrix.impl.DenseDoubleMatrix2D getAllShortPathMatrix(Set nodes)
           
static Set getComponents(Set nodes)
          Returns an ArrayList of length equal to the number of components in the graph, each entry of which is an ArrayList of the nodes in that component.
static int getInDegree(Node iNode)
          Returns the in degree (number of in edges) of the node.
static int getNumDirectTriads(Node iNode, Node jNode)
          Finds and returns the number of "parents" (nodes with links TO both i and j)
static int getOutDegree(Node iNode)
          Returns the out degree (number of out edges) of the node.
static boolean hasSelfLoops(Set nodes)
          Returns a boolean indicating whether the network contains self-loops (links from i -> i)
static boolean isMultiplexNet(Set nodes)
          Checks if there are any nodes i j for which there is more than one tie i -> j (almost all network statistics assume that the network is NOT multiplex)
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NetUtilities

public NetUtilities()
No-Argument constructor for convenience / aliasing.

Method Detail

calcDensity

public static double calcDensity(Set nodes)
calculates density (ratio of arcs in network to maximum possible number of arcs) of passed network. Checks to make sure network is non-multiplex. Includes self-loops.


calcDensity

public static double calcDensity(Set nodes,
                                 boolean collapseMulti)
Calculates density of the network, but if collapseMulti is true, it first collapses any multiplex ties. If collapseMulti is false, it runs without checking for multiplex ties. Note: if the argument is false, and multiplex ties exist, calcDensity will still return a value, but it will not exactly correspond to the density. But it will run much faster than calcDensity(ArrayList nodes). The possibility of self-loops is assumed

Parameters:
nodes - the ArrayList of nodes to examine

isMultiplexNet

public static boolean isMultiplexNet(Set nodes)
Checks if there are any nodes i j for which there is more than one tie i -> j (almost all network statistics assume that the network is NOT multiplex)


hasSelfLoops

public static boolean hasSelfLoops(Set nodes)
Returns a boolean indicating whether the network contains self-loops (links from i -> i)

Parameters:
nodes - the ArrayList of nodes to examine for loops

getOutDegree

public static int getOutDegree(Node iNode)
Returns the out degree (number of out edges) of the node.

Parameters:
iNode - the node the degree will be returned for

getInDegree

public static int getInDegree(Node iNode)
Returns the in degree (number of in edges) of the node. (Assumes inEdges have been set correctly)

Parameters:
iNode - the node the degree will be returned for

getNumDirectTriads

public static int getNumDirectTriads(Node iNode,
                                     Node jNode)
Finds and returns the number of "parents" (nodes with links TO both i and j)

Parameters:
iNode - one node of triad
jNode - the second node of the triad

getComponents

public static Set getComponents(Set nodes)
Returns an ArrayList of length equal to the number of components in the graph, each entry of which is an ArrayList of the nodes in that component.

Parameters:
nodes - the network in which components will be counted

getAllShortPathMatrix

public static cern.colt.matrix.impl.DenseDoubleMatrix2D getAllShortPathMatrix(Set nodes)