Method Summary |
static long[][] |
floydWarshallNumberShortestPathsMatrix(Network network,
EdgeMetric computer,
double precision)
Get the numer of shortest paths (from any node to any other node) using the Floyd-Warshall algorithm. |
static long[][][] |
floydWarshallNumberShortestPathsWithIntermediatesMatrix(Network network,
EdgeMetric computer,
double precision)
Get the numer of shortest paths (from any node through a second node to a third node) using the Floyd-Warshall algorithm. |
static double[][] |
floydWarshallShortestPathsMatrix(Network network,
EdgeMetric computer)
Get the shortest paths matrix (from any node to any other node) using the Floyd-Warshall algorithm. |
static double |
getClusteringCoefficient(Network network)
Computes the clustering coefficient, i.e. |
static double |
getDensity(Network network)
Returns the density of a matrix (the ratio of number of actual edges in the network to
the maximum number of edges that can exist in the network). |
static double |
getDiameter(Network network,
EdgeMetric computer)
Computes the diameter of a network (the maximum node eccentricity). |
static boolean |
getHasSelfLoops(Network network)
Checks whether the network has self loops or not (a self-loop is a link from a node to itself). |
static double |
getInclusiveness(Network network)
Returns the inclusiveness of the network (the ratio of non-isolated nodes to total number of nodes in the network). |
static Bag |
getIsolatedNodes(Network network)
Returns a list containing the isolated nodes in the network (nodes with zero in-degree and zero out-degree). |
static double |
getLargeNetworkMeanShortestPath(Network network,
EdgeMetric computer)
Returns the average length of the shortest path between nodes in the network: memory-constrained version. |
static double |
getMeanShortestPath(Network network,
EdgeMetric computer)
Returns the average length of the shortest path between nodes in the network. |
static double |
getNodeEccentricity(Network network,
java.lang.Object node,
EdgeMetric computer)
Returns the eccentricity of a node. |
static int |
getNumberActualEdges(Network network)
Returns the number of edges in the network. |
static int |
getNumberNodes(Network network)
Returns the number of nodes in the network. |
static int |
getNumberPotentialEdges(Network network)
Returns the maximum number of edges in the network. |
static long[][] |
getNumberShortestPathsMatrix(Network network,
EdgeMetric computer,
double precision)
Get the matrix with number of shortest paths (from any node to any other node) |
static long[][][] |
getNumberShortestPathsWithIntermediatesMatrix(Network network,
EdgeMetric computer,
double precision)
Get the numer of shortest paths (from any node through a second node to a third node). |
static double |
getRadius(Network network,
EdgeMetric computer)
Compute the radius of a network (the minimum node eccentricity). |
static double |
getShortestPath(Network network,
java.lang.Object startNode,
java.lang.Object endNode,
EdgeMetric computer)
Returns the shortest path (number of edges) between two nodes indicated by their indexes in the allNodes Bag. |
static double[] |
getShortestPaths(Network network,
java.lang.Object startNode,
EdgeMetric computer)
Returns a vector with distances to the nodes in the graph. |
static double[][] |
getShortestPathsMatrix(Network network,
EdgeMetric computer)
Get the shortest paths matrix (from any node to any other node) |
static double |
getSymmetryCoefficient(Network network)
Computes the amount of symmetry in the network, ie the ratio of edges i->j and j->i over all edges. |
static boolean |
isMultigraphNetwork(Network network)
Checks whether the network is a multigraph or not (a multigraph may contain several edges from a node i to a node j). |
static long[][] |
johnsonNumberShortestPathsMatrix(Network network,
EdgeMetric computer,
double precision)
Get the shortest paths matrix (from any node to any other node) using the Johnson algorithm for sparse graphs. |
static double[][] |
johnsonShortestPathsMatrix(Network network,
EdgeMetric computer)
Get the shortest paths matrix (from any node to any other node) using the Johnson algorithm for sparse graphs. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
NetworkStatistics
public NetworkStatistics()
getNumberNodes
public static int getNumberNodes(Network network)
- Returns the number of nodes in the network.
getNumberPotentialEdges
public static int getNumberPotentialEdges(Network network)
- Returns the maximum number of edges in the network. Assumes the network is simple,
in the sense that there can be at most an edge from node i to node j (for any i and j).
With this assumption, there are N*(N-1) potential edges, not including self-loops.
getNumberActualEdges
public static int getNumberActualEdges(Network network)
- Returns the number of edges in the network. Does not pay attention whether the edges
are self-loops or not.
getDensity
public static double getDensity(Network network)
- Returns the density of a matrix (the ratio of number of actual edges in the network to
the maximum number of edges that can exist in the network).
getIsolatedNodes
public static Bag getIsolatedNodes(Network network)
- Returns a list containing the isolated nodes in the network (nodes with zero in-degree and zero out-degree).
getInclusiveness
public static double getInclusiveness(Network network)
- Returns the inclusiveness of the network (the ratio of non-isolated nodes to total number of nodes in the network).
getShortestPaths
public static double[] getShortestPaths(Network network,
java.lang.Object startNode,
EdgeMetric computer)
- Returns a vector with distances to the nodes in the graph. Double.POSITIVE_INFINITY marks nodes
that are not accessible from the startNode.
The vector is indexed based on the indexes of the nodes in the allNodes Bag in the Network.
getShortestPath
public static double getShortestPath(Network network,
java.lang.Object startNode,
java.lang.Object endNode,
EdgeMetric computer)
- Returns the shortest path (number of edges) between two nodes indicated by their indexes in the allNodes Bag.
Returns Double.POSITIVE_INFINITY if no path is found.
getClusteringCoefficient
public static double getClusteringCoefficient(Network network)
- Computes the clustering coefficient, i.e. the average ratio of neighbors of a node that are connected by direct edges.
isMultigraphNetwork
public static boolean isMultigraphNetwork(Network network)
- Checks whether the network is a multigraph or not (a multigraph may contain several edges from a node i to a node j).
getHasSelfLoops
public static boolean getHasSelfLoops(Network network)
- Checks whether the network has self loops or not (a self-loop is a link from a node to itself).
getSymmetryCoefficient
public static double getSymmetryCoefficient(Network network)
- Computes the amount of symmetry in the network, ie the ratio of edges i->j and j->i over all edges.
If there are three nodes (1,2, and 3), and three edges (1->2, 2->1 and 1->3), the symmetry coefficient is 2/3.
getShortestPathsMatrix
public static double[][] getShortestPathsMatrix(Network network,
EdgeMetric computer)
- Get the shortest paths matrix (from any node to any other node)
floydWarshallShortestPathsMatrix
public static double[][] floydWarshallShortestPathsMatrix(Network network,
EdgeMetric computer)
- Get the shortest paths matrix (from any node to any other node) using the Floyd-Warshall algorithm.
The time complexity is O(V^3), where V is the number of nodes.
johnsonShortestPathsMatrix
public static double[][] johnsonShortestPathsMatrix(Network network,
EdgeMetric computer)
- Get the shortest paths matrix (from any node to any other node) using the Johnson algorithm for sparse graphs.
The time complexity is O(V^2*log(V)+VE), where V is the number of nodes. In fact, as we know the edges have
only positive costs, we basically call Dijkstra's algorithm from each in the graph (Dijkstra's algorithm computes
single-node-shortest-paths to all other nodes in the graph).
getMeanShortestPath
public static double getMeanShortestPath(Network network,
EdgeMetric computer)
- Returns the average length of the shortest path between nodes in the network. Ignores self-loops.
getLargeNetworkMeanShortestPath
public static double getLargeNetworkMeanShortestPath(Network network,
EdgeMetric computer)
- Returns the average length of the shortest path between nodes in the network: memory-constrained version. Ignores self-loops.
This method can be used if your machine does not provide enough heap memory to store the shortest
paths matrix required in NetworkStatistics.getMeanShortestPath above (which is much faster if enough memory
is provided). The problem is likely to occur with very large networks (some > 20k nodes??).
getNodeEccentricity
public static double getNodeEccentricity(Network network,
java.lang.Object node,
EdgeMetric computer)
- Returns the eccentricity of a node. The eccentricity is defined as the longest shortest distance to another node.
If there's a node that's not accessible from the start node, the eccentricity is Double.POSITIVE_INFINITY;
getRadius
public static double getRadius(Network network,
EdgeMetric computer)
- Compute the radius of a network (the minimum node eccentricity).
getDiameter
public static double getDiameter(Network network,
EdgeMetric computer)
- Computes the diameter of a network (the maximum node eccentricity).
johnsonNumberShortestPathsMatrix
public static long[][] johnsonNumberShortestPathsMatrix(Network network,
EdgeMetric computer,
double precision)
- Get the shortest paths matrix (from any node to any other node) using the Johnson algorithm for sparse graphs.
The time complexity is O(V^2*log(V)+VE), where V is the number of nodes. In fact, as we know the edges have
only positive costs, we basically call Dijkstra's algorithm from each in the graph (Dijkstra's algorithm computes
single-node-shortest-paths to all other nodes in the graph).
floydWarshallNumberShortestPathsMatrix
public static long[][] floydWarshallNumberShortestPathsMatrix(Network network,
EdgeMetric computer,
double precision)
- Get the numer of shortest paths (from any node to any other node) using the Floyd-Warshall algorithm.
Precision is used to deal with equality of real-valued paths (two real-valued numbers are different with their
absolute difference is greater than 'precision').
The time complexity is O(V^3), where V is the number of nodes.
floydWarshallNumberShortestPathsWithIntermediatesMatrix
public static long[][][] floydWarshallNumberShortestPathsWithIntermediatesMatrix(Network network,
EdgeMetric computer,
double precision)
- Get the numer of shortest paths (from any node through a second node to a third node) using the Floyd-Warshall algorithm.
Precision is used to deal with equality of real-valued paths (two real-valued numbers are different with their
absolute difference is greater than 'precision').
The time complexity is O(V^3), where V is the number of nodes.
getNumberShortestPathsMatrix
public static long[][] getNumberShortestPathsMatrix(Network network,
EdgeMetric computer,
double precision)
- Get the matrix with number of shortest paths (from any node to any other node)
getNumberShortestPathsWithIntermediatesMatrix
public static long[][][] getNumberShortestPathsWithIntermediatesMatrix(Network network,
EdgeMetric computer,
double precision)
- Get the numer of shortest paths (from any node through a second node to a third node).
Precision is used to deal with equality of real-valued paths (two real-valued numbers are different with their
absolute difference is greater than 'precision').