/*
* This file is part of the TimeFinder project.
* Visit http://www.timefinder.de for more information.
* Copyright 2008 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package de.timefinder.algo.graph;
import de.timefinder.algo.graph.Matching;
import org.junit.Test;
import static org.junit.Assert.*;
/**
*
* @author Peter Karich, peat_hal 'at' users 'dot' sourceforge 'dot' net
*/
public class MatchingTest {
/**
* Test of addEdge method, of class Matching.
*/
@Test
public void testAddEdge() {
System.out.println("addEdge");
Matching instance = new Matching();
instance.addEdge(3, 4, 5.6f);
instance.addEdge(3, 4, 7f);
instance.addEdge(0, 5, 5.6f);
assertEquals(2, instance.getEdges().size());
assertEquals(11.2f, instance.getTotalSum(), 0.01f);
}
/**
* Test of addEdge method, of class Matching.
*/
@Test
public void testToBipartiteArray() {
System.out.println("toBipartiteArray");
Matching instance = new Matching();
instance.addEdge(0, 4 + 2, 5.6f);
instance.addEdge(1, 4 + 3, 5.6f);
instance.addEdge(3, 4 + 1, 5.6f);
int[][] result = instance.toBipartiteArrayModY(4);
assertEquals(2, result[0][0]);
assertEquals(3, result[1][0]);
assertEquals(null, result[2]);
assertEquals(1, result[3][0]);
}
}