public class Layout
extends java.lang.Object
implements java.lang.Cloneable, java.io.Serializable
Modifier and Type | Field and Description |
---|---|
protected double[][] |
coordinates
Coordinates of each node.
|
protected int |
nNodes
Number of nodes.
|
Constructor and Description |
---|
Layout(double[][] coordinates)
Constructs a layout using specified coordinates for each node.
|
Layout(int nNodes)
Constructs a random layout for a specified number of nodes.
|
Layout(int nNodes,
java.util.Random random)
Constructs a random layout for a specified number of nodes.
|
Modifier and Type | Method and Description |
---|---|
Layout |
clone()
Clones the layout.
|
void |
flip(int dimension)
Flips a layout.
|
double |
getAverageDistance()
Returns the average distance between all pairs of nodes.
|
double[][] |
getCoordinates()
Returns the coordinates of each node.
|
double[] |
getCoordinates(int node)
Returns the coordinates of a node.
|
double[] |
getMaxCoordinates()
Returns the maximum of the coordinates of all node.
|
double[] |
getMinCoordinates()
Returns the minimum of the coordinates of all node.
|
int |
getNNodes()
Returns the number of nodes.
|
void |
initRandomCoordinates()
Initializes a random layout.
|
void |
initRandomCoordinates(java.util.Random random)
Initializes a random layout.
|
static Layout |
load(java.lang.String fileName)
Loads a layout from a file.
|
void |
rotate(double angle)
Rotates a layout.
|
void |
save(java.lang.String fileName)
Saves the layout in a file.
|
void |
setCoordinates(int node,
double[] coordinates)
Positions a node at coordinates.
|
void |
standardize(boolean standardizeDistances)
Standardizes a layout.
|
protected int nNodes
protected double[][] coordinates
public Layout(int nNodes)
nNodes
- Number of nodespublic Layout(int nNodes, java.util.Random random)
nNodes
- Number of nodesrandom
- Random number generatorpublic Layout(double[][] coordinates)
coordinates
- Coordinates of each nodepublic static Layout load(java.lang.String fileName) throws java.lang.ClassNotFoundException, java.io.IOException
fileName
- File from which a layout is loadedjava.lang.ClassNotFoundException
- Class not foundjava.io.IOException
- Could not read the filesave(String fileName)
public Layout clone()
clone
in class java.lang.Object
public void save(java.lang.String fileName) throws java.io.IOException
fileName
- File in which the layout is savedjava.io.IOException
- Could not write to the fileload(String fileName)
public int getNNodes()
public double[][] getCoordinates()
public double[] getCoordinates(int node)
node
- Nodepublic double[] getMinCoordinates()
public double[] getMaxCoordinates()
public double getAverageDistance()
public void setCoordinates(int node, double[] coordinates)
node
- Nodecoordinates
- Coordinatespublic void initRandomCoordinates()
Each node is positioned at random coordinates.
public void initRandomCoordinates(java.util.Random random)
Each node is positioned at random coordinates.
random
- Random number generatorpublic void standardize(boolean standardizeDistances)
Standardization involves translation, rotation, reflection, and
optionally dilation. The layout is translated so that it is centered at
the origin. The layout is rotated so that the variance in the horizontal
dimension is maximized. The layout is reflected so that in both the
horizontal and the vertical dimension the median of the coordinates is
non-positive. If standardizeDistances = true
, the layout is
dilated so that the average distance between nodes equals one.
standardizeDistances
- Standardize distancespublic void rotate(double angle)
angle
- Anglepublic void flip(int dimension)
dimension
- Dimension