Package de.timefinder.algo.graph

Examples of de.timefinder.algo.graph.WeightedGraph.addEdge()


        int ALL_NODES = NO_X + NO_Y;
        for (int x = 0; x < NO_X; x++) {
            int tmpY = 0;
            for (int y = NO_X; y < ALL_NODES; y++, tmpY++) {
                if (costMatrix[tmpY][x] < floatMax) {
                    graph.addEdge(x, y, costMatrix[tmpY][x]);
                } else {
                    // we would not need this line, if we would have a better graph.getOneNodeWithAnEdge()
                    // see within the while(true) loop
                    graph.addEdge(x, y, floatMax);
                }
View Full Code Here


                if (costMatrix[tmpY][x] < floatMax) {
                    graph.addEdge(x, y, costMatrix[tmpY][x]);
                } else {
                    // we would not need this line, if we would have a better graph.getOneNodeWithAnEdge()
                    // see within the while(true) loop
                    graph.addEdge(x, y, floatMax);
                }
            }
        }

        // x is somewhat missleading, because the x and y nodes swap
View Full Code Here

    @Test
    public void testAddEdge() {
        System.out.println("addEdge");

        WeightedGraph graph = new WeightedGraph(10);
        graph.addEdge(3, 4, 7f);
        graph.addEdge(3, 4, 8f);
        graph.addEdge(2, 4, 9f);

        assertEquals(2, graph.getNoOfEdges());
        assertTrue(graph.getNeighbors(4).containsValue(8f));
View Full Code Here

    public void testAddEdge() {
        System.out.println("addEdge");

        WeightedGraph graph = new WeightedGraph(10);
        graph.addEdge(3, 4, 7f);
        graph.addEdge(3, 4, 8f);
        graph.addEdge(2, 4, 9f);

        assertEquals(2, graph.getNoOfEdges());
        assertTrue(graph.getNeighbors(4).containsValue(8f));
View Full Code Here

        System.out.println("addEdge");

        WeightedGraph graph = new WeightedGraph(10);
        graph.addEdge(3, 4, 7f);
        graph.addEdge(3, 4, 8f);
        graph.addEdge(2, 4, 9f);

        assertEquals(2, graph.getNoOfEdges());
        assertTrue(graph.getNeighbors(4).containsValue(8f));

        boolean ret = graph.removeEdge(3, 4);
View Full Code Here

    @Test
    public void testGetNeighbors() {
        System.out.println("getNeighbors");

        WeightedGraph graph = new WeightedGraph(10);
        graph.addEdge(3, 4, 7f);
        graph.addEdge(3, 4, 7f);
        graph.addEdge(2, 4, 7f);

        assertEquals(1, graph.getNeighbors(2).size());
        assertEquals(2, graph.getNeighbors(4).size());
View Full Code Here

    public void testGetNeighbors() {
        System.out.println("getNeighbors");

        WeightedGraph graph = new WeightedGraph(10);
        graph.addEdge(3, 4, 7f);
        graph.addEdge(3, 4, 7f);
        graph.addEdge(2, 4, 7f);

        assertEquals(1, graph.getNeighbors(2).size());
        assertEquals(2, graph.getNeighbors(4).size());
    }
View Full Code Here

        System.out.println("getNeighbors");

        WeightedGraph graph = new WeightedGraph(10);
        graph.addEdge(3, 4, 7f);
        graph.addEdge(3, 4, 7f);
        graph.addEdge(2, 4, 7f);

        assertEquals(1, graph.getNeighbors(2).size());
        assertEquals(2, graph.getNeighbors(4).size());
    }
View Full Code Here

     */
    @Test
    public void testGetOneNodeWithAnEdge() {
        System.out.println("getOneNodeWithAnEdge");
        WeightedGraph graph = new WeightedGraph(10);
        graph.addEdge(3, 4, 7f);
        graph.addEdge(3, 4, 7f);
        graph.addEdge(2, 4, 7f);

        assertTrue(graph.getOneNodeWithAnEdge() != -1);

View Full Code Here

    @Test
    public void testGetOneNodeWithAnEdge() {
        System.out.println("getOneNodeWithAnEdge");
        WeightedGraph graph = new WeightedGraph(10);
        graph.addEdge(3, 4, 7f);
        graph.addEdge(3, 4, 7f);
        graph.addEdge(2, 4, 7f);

        assertTrue(graph.getOneNodeWithAnEdge() != -1);

        graph.removeEdge(3, 4);
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.