org.grinvin
Class Graphs
public final class Graphs
extends java.lang.Object
Provides some basic helper methods for graphs.
Note that adjacency matrix, adjacency list and distance matrix can
also be obtained from the graph bundle directory, which may cache
their values.
adjacencyList
public static int[][] adjacencyList(GraphView graph)
Returns the adjacency list representation for the given graph. The resulting array
contains an array of neighbour indices for every vertex. The length of each array is exactly
the valency of the corresponding vertex.
booleanAdjacencyMatrix
public static boolean[][] booleanAdjacencyMatrix(GraphView graph)
Returns a boolean adjacency matrix for the given graph. Row and column
indices correspond to vertex indices. Entries are true
when the corresponding vertices are adjacent (and different) and false
otherwise.
Note that the contents of this matrix are valid only for as long as the graph
given as a parameter remains unaltered.
distanceMatrix
public static int[][] distanceMatrix(GraphView graph)
Returns the distance matrix for the given graph. Row and column
indices correspond to vertex indices. Entries contains the distance
between corresponding vertices or 0 when vertices are equal or
belong to different components of the graph.
eccentricityList
public static int[] eccentricityList(GraphView graph)
Returns the list with eccentricities for the given graph. The resulting array
contains an integer for every vertex. If the graph is disconnected the array will
contain Integer.MAX_VALUE for every vertex.
eigenValues
public static double[] eigenValues(GraphView graph)
Returns the list of eigenvalues of the given graph. This are the eigenvalues
of the adjacency matrix of the graph. The resulting array contains the
eigenvalues in descending order.
If an error occurs during the calculation an array with length 0 is returned.