Package org.jgrapht.alg.vertexcover
Class BarYehudaEvenTwoApproxVCImpl<V,E>
- java.lang.Object
-
- org.jgrapht.alg.vertexcover.BarYehudaEvenTwoApproxVCImpl<V,E>
-
- Type Parameters:
V
- the graph vertex typeE
- the graph edge type
- All Implemented Interfaces:
MinimumVertexCoverAlgorithm<V,E>
,MinimumWeightedVertexCoverAlgorithm<V,E>
public class BarYehudaEvenTwoApproxVCImpl<V,E> extends java.lang.Object implements MinimumWeightedVertexCoverAlgorithm<V,E>
Implementation of the 2-opt algorithm for a minimum weighted vertex cover by R. Bar-Yehuda and S. Even. A linear time approximation algorithm for the weighted vertex cover problem. J. of Algorithms 2:198-203, 1981. The solution is guaranteed to be within 2 times the optimum solution. An easier-to-read version of this algorithm can be found here: https://www.cs.umd.edu/class/spring2011/cmsc651/vc.pdf Note: this class supports pseudo-graphs Runtime: O(|E|) This is a fast algorithm, guaranteed to give a 2-approximation. A solution of higher quality (same approximation ratio) at the expensive of a higher runtime can be obtained usingBarYehudaEvenTwoApproxVCImpl
. TODO: Remove the UndirectedSubgraph dependency! Querying vertex degrees on these graphs is actually slow! This does affect the runtime complexity. Better would be to just work on a clone of the original graph!
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.jgrapht.alg.interfaces.MinimumVertexCoverAlgorithm
MinimumVertexCoverAlgorithm.VertexCover<V>, MinimumVertexCoverAlgorithm.VertexCoverImpl<V>
-
-
Constructor Summary
Constructors Constructor Description BarYehudaEvenTwoApproxVCImpl()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description MinimumVertexCoverAlgorithm.VertexCover<V>
getVertexCover(UndirectedGraph<V,E> graph, java.util.Map<V,java.lang.Double> vertexWeightMap)
Computes a vertex cover; the weight of each vertex is provided in the in thevertexWeightMap
.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.jgrapht.alg.interfaces.MinimumWeightedVertexCoverAlgorithm
getVertexCover
-
-
-
-
Method Detail
-
getVertexCover
public MinimumVertexCoverAlgorithm.VertexCover<V> getVertexCover(UndirectedGraph<V,E> graph, java.util.Map<V,java.lang.Double> vertexWeightMap)
Description copied from interface:MinimumWeightedVertexCoverAlgorithm
Computes a vertex cover; the weight of each vertex is provided in the in thevertexWeightMap
.- Specified by:
getVertexCover
in interfaceMinimumWeightedVertexCoverAlgorithm<V,E>
- Parameters:
graph
- the input graphvertexWeightMap
- map containing non-negative weights for each vertex- Returns:
- a vertex cover
-
-