Class City
- java.lang.Object
-
- org.apache.commons.math4.examples.sofm.tsp.City
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static double[]
barycentre(Set<City> cities)
Computes the barycentre of all city locations.static City
closest(double x, double y, Set<City> cities)
double
distance(double x, double y)
Computes the distance between this city and the given point.boolean
equals(Object o)
double[]
getCoordinates()
String
getName()
int
hashCode()
static double
largestDistance(double x, double y, Set<City> cities)
Computes the largest distance between the point at coordinates(x, y)
and any of the cities.String
toString()
static Set<City>
unique(City[] cities)
-
-
-
Method Detail
-
getCoordinates
public double[] getCoordinates()
- Returns:
- the (x, y) coordinates.
-
distance
public double distance(double x, double y)
Computes the distance between this city and the given point.- Parameters:
x
- x-coordinate.y
- y-coordinate.- Returns:
- the distance between
(x, y)
and this city.
-
closest
public static City closest(double x, double y, Set<City> cities)
- Parameters:
x
- x-coordinate.y
- y-coordinate.cities
- City list.- Returns:
- the city whose coordinates are closest to
(x, y)
.
-
barycentre
public static double[] barycentre(Set<City> cities)
Computes the barycentre of all city locations.- Parameters:
cities
- City list.- Returns:
- the barycentre.
-
largestDistance
public static double largestDistance(double x, double y, Set<City> cities)
Computes the largest distance between the point at coordinates(x, y)
and any of the cities.- Parameters:
x
- x-coordinate.y
- y-coordinate.cities
- City list.- Returns:
- the largest distance.
-
unique
public static Set<City> unique(City[] cities)
- Parameters:
cities
- List of cities.- Returns:
- a list with no duplicate city.
-
-