### Question:
KuhnMunkresMinimalWeightBipartitePerfectMatching implements MatchingAlgorithm<V, E> { @Override public Matching<V, E> getMatching() { if (partition1.size() != partition2.size()) { throw new IllegalArgumentException( "Graph supplied isn't complete bipartite with equally sized partitions!"); } if (!GraphTests.isBipartitePartition(graph, partition1, partition2)) { throw new IllegalArgumentException("Invalid bipartite partition provided"); } int partition = partition1.size(); int edges = graph.edgeSet().size(); if (edges != (partition * partition)) { throw new IllegalArgumentException( "Graph supplied isn't complete bipartite with equally sized partitions!"); } if (!GraphTests.isSimple(graph)) { throw new IllegalArgumentException("Only simple graphs supported"); } List<? extends V> firstPartition = new ArrayList<>(partition1); List<? extends V> secondPartition = new ArrayList<>(partition2); int[] matching; if (graph.vertexSet().isEmpty()) { matching = new int[] {}; } else { matching = new KuhnMunkresMatrixImplementation<>(graph, firstPartition, secondPartition) .buildMatching(); } Set<E> edgeSet = new HashSet<>(); double weight = 0d; for (int i = 0; i < matching.length; ++i) { E e = graph.getEdge(firstPartition.get(i), secondPartition.get(matching[i])); weight += graph.getEdgeWeight(e); edgeSet.add(e); } return new MatchingImpl<>(graph, edgeSet, weight); } KuhnMunkresMinimalWeightBipartitePerfectMatching(
        Graph<V, E> graph, Set<? extends V> partition1, Set<? extends V> partition2); @Override Matching<V, E> getMatching();  }### Answer:
@Test public void testForEmptyGraph() { Graph<V, WeightedEdge> graph = new SimpleWeightedGraph<>(WeightedEdge.class); Set<? extends V> emptyList = Collections.emptySet(); MatchingAlgorithm<V, WeightedEdge> alg = new KuhnMunkresMinimalWeightBipartitePerfectMatching<>(graph, emptyList, emptyList); Assert.assertTrue(alg.getMatching().getEdges().isEmpty()); }