vertexcover
Class AbstractVCover

java.lang.Object
  extended by vertexcover.AbstractVCover
Direct Known Subclasses:
RandomVCCalculator

public abstract class AbstractVCover
extends java.lang.Object


Constructor Summary
AbstractVCover()
          Creates the object
 
Method Summary
static int[] booleans2ints(boolean[] cities)
          Converts the boolean array into array of indexes that are true
abstract  int[] getMinimalVertexCover(JPFMap map)
          Should select minimal number of cities that are necessary to cover all the roads on the map
static int getNumberOfCitiesUsed(boolean[] selectedCities)
          Calculates number of true values in the given array
static int getNumberOfRoadsCovered(boolean[] selectedCities, JPFMap map)
          Calculates number of roads covered by cities defined by given array of boolean values (true = city is selected to cover the roads, false = the city is not selected)
static int getNumberOfRoadsCovered(int[] selectedCities, JPFMap map)
          Calculates number of roads covered by cities from given array
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractVCover

public AbstractVCover()
Creates the object

Method Detail

getMinimalVertexCover

public abstract int[] getMinimalVertexCover(JPFMap map)
Should select minimal number of cities that are necessary to cover all the roads on the map

Returns:
IDs of cities selected

getNumberOfRoadsCovered

public static int getNumberOfRoadsCovered(int[] selectedCities,
                                          JPFMap map)
Calculates number of roads covered by cities from given array

Parameters:
selectedCities - IDs of cities that cover the roads
Returns:
number of roads covered

getNumberOfRoadsCovered

public static int getNumberOfRoadsCovered(boolean[] selectedCities,
                                          JPFMap map)
Calculates number of roads covered by cities defined by given array of boolean values (true = city is selected to cover the roads, false = the city is not selected)

Parameters:
selectedCities - array of cities that cover the roads (true = city is selected to cover the roads, false = the city is not selected)
Returns:
number of roads covered

getNumberOfCitiesUsed

public static int getNumberOfCitiesUsed(boolean[] selectedCities)
Calculates number of true values in the given array

Parameters:
selectedCities -
Returns:

booleans2ints

public static int[] booleans2ints(boolean[] cities)
Converts the boolean array into array of indexes that are true

Parameters:
cities - the arrey to convert
Returns: