public class NodeCoordinates extends DistanceTable
Constructor and Description |
---|
NodeCoordinates(int size,
EdgeWeightType edgeWeightType)
Constructs a new, empty node coordinates instance.
|
NodeCoordinates(int size,
NodeCoordType type,
DistanceFunction distanceFunction)
Constructs a new, empty node coordinates instance.
|
Modifier and Type | Method and Description |
---|---|
protected void |
add(Node node)
Adds the specified node to this problem instance.
|
protected void |
clear()
Removes all nodes from this problem instance.
|
Node |
get(int id)
Returns the node with the specified identifier.
|
double |
getDistanceBetween(int id1,
int id2)
Returns the distance between the two specified nodes.
|
int[] |
getNeighborsOf(int id)
Returns the identifiers of all neighbors of the specified node.
|
int[] |
listNodes()
Returns the identifiers of all nodes in this distance table.
|
void |
load(BufferedReader reader)
Loads the distance table from the specified reader.
|
protected void |
remove(int id)
Removes the node with the specified identifier from this problem
instance.
|
int |
size()
Returns the number of nodes that this instance contains.
|
String |
toString() |
isNeighbor
public NodeCoordinates(int size, EdgeWeightType edgeWeightType)
size
- the number of nodes to load into this problem instanceedgeWeightType
- the edge weight typepublic NodeCoordinates(int size, NodeCoordType type, DistanceFunction distanceFunction)
size
- the number of nodes to load into this problem instancetype
- the type of coordinates (i.e., 2D or 3D)distanceFunction
- the distance functionpublic void load(BufferedReader reader) throws IOException
DistanceTable
load
in class DistanceTable
reader
- the reader containing the distance tableIOException
- if an I/O error occurred while reading the distance
tableprotected void add(Node node)
node
- the node to addpublic Node get(int id)
id
- the identifier of the node to returnprotected void remove(int id)
id
- the identifier of the node to removeprotected void clear()
public int size()
public int[] listNodes()
DistanceTable
listNodes
in class DistanceTable
public int[] getNeighborsOf(int id)
DistanceTable
getNeighborsOf
in class DistanceTable
id
- the identifier of the node whose neighbors are enumeratedpublic double getDistanceBetween(int id1, int id2)
DistanceTable
getDistanceBetween
in class DistanceTable
id1
- the identifier of the first nodeid2
- the identifier of the second nodeCopyright © 2016. All rights reserved.