Package org.openjgraph.model.adjacencymatrix

Examples of org.openjgraph.model.adjacencymatrix.AdjacencyMatrixGraph


    /**
     * Test of getVertex method, of class AdjacencyMatrixEdge.
     */
    public void testGetVertex() {
        try {
            AdjacencyMatrixGraph graph = new AdjacencyMatrixGraph();
            graph.addVertex("A");
            graph.addVertex("B");
            graph.addVertex("C");
            graph.addVertex("D");
            graph.addEdge("A", "B", 5);
            graph.addEdge("A", "C", 4);
            graph.addEdge("B", "C", 10);

            Set<Edge> edgeSet = graph.getEdge("A");
            assertEquals(2,edgeSet.size());
            assertTrue(edgeSet.contains(new AdjacencyMatrixEdge(graph,"A", "B")));
            assertTrue(edgeSet.contains(new AdjacencyMatrixEdge(graph,"A", "C")));
            assertFalse(edgeSet.contains(new AdjacencyMatrixEdge(graph,"B", "C")));
           
View Full Code Here


    /**
     * Test of getValue method, of class AdjacencyMatrixEdge.
     */
    public void testGetValue() {
        try {
            AdjacencyMatrixGraph graph = new AdjacencyMatrixGraph();
            graph.addVertex("A");
            graph.addVertex("B");
            graph.addVertex("C");
            graph.addEdge("A", "B", 5);
            graph.addEdge("A", "C", 4);
            graph.addEdge("B", "C", 10);

            assertEquals(5, graph.getEdgeValue("A", "B"));
            assertEquals(4, graph.getEdgeValue("A", "C"));
            assertEquals(10, graph.getEdgeValue("B", "C"));

        } catch (VertexNotFoundException ex) {
            assertFalse(true);
        }

View Full Code Here

    /**
     * Test of toString method, of class AdjacencyMatrixEdge.
     */
    public void testToString() {
        try {
            AdjacencyMatrixGraph graph = new AdjacencyMatrixGraph();
            graph.addVertex("A");
            graph.addVertex("B");
            graph.addVertex("C");
            graph.addEdge("A", "B");
            graph.addEdge("A", "C", 4);
            AdjacencyMatrixEdge e1 = new AdjacencyMatrixEdge(graph, "A", "B");
            AdjacencyMatrixEdge e2 = new AdjacencyMatrixEdge(graph, "A", "C");
            assertEquals("A -[1]- B", e1.toString());
            assertEquals("A -[4]- C", e2.toString());

View Full Code Here

    /**
     * Test of equals method, of class AdjacencyMatrixEdge.
     */
    public void testEquals() {
            AdjacencyMatrixGraph graph1 = new AdjacencyMatrixGraph();
         //   AdjacencyMatrixGraph graph2 = new AdjacencyMatrixDirectedGraph();

            AdjacencyMatrixEdge e1 = new AdjacencyMatrixEdge(graph1, "A", "B");
            AdjacencyMatrixEdge e2 = new AdjacencyMatrixEdge(graph1, "A", "B");
            AdjacencyMatrixEdge e3 = new AdjacencyMatrixEdge(graph1, "B", "A");
View Full Code Here

    /**
     * Test of hashCode method, of class AdjacencyMatrixEdge.
     */
    public void testHashCode() {
           AdjacencyMatrixGraph graph1 = new AdjacencyMatrixGraph();
         //   AdjacencyMatrixGraph graph2 = new AdjacencyMatrixDirectedGraph();

            AdjacencyMatrixEdge e1 = new AdjacencyMatrixEdge(graph1, "A", "B");
            AdjacencyMatrixEdge e2 = new AdjacencyMatrixEdge(graph1, "A", "B");
            AdjacencyMatrixEdge e3 = new AdjacencyMatrixEdge(graph1, "B", "A");
View Full Code Here

    /**
     * Test of getEdges method, of class AdjacencyMatrixVertex.
     */
    public void testGetEdges1() {
        try {
            AdjacencyMatrixGraph graph = new AdjacencyMatrixGraph();
            AdjacencyMatrixVertex v1 = new AdjacencyMatrixVertex(graph, "A");
            AdjacencyMatrixVertex v2 = new AdjacencyMatrixVertex(graph, "B");
            AdjacencyMatrixVertex v3 = new AdjacencyMatrixVertex(graph, "C");
            AdjacencyMatrixVertex v4 = new AdjacencyMatrixVertex(graph, "D");
            graph.addVertex("A");
            graph.addVertex("B");
            graph.addVertex("C");
            graph.addVertex("D");
            graph.addEdge("A", "B");
            graph.addEdge("A", "C");

            Set<Edge> edgeSet = v1.getEdges();
            assertEquals(2, edgeSet.size());

            boolean containsV2 = false;
View Full Code Here

    /**
     * Test of getId method, of class AdjacencyMatrixVertex.
     */
    public void testGetId() {
        AdjacencyMatrixGraph graph = new AdjacencyMatrixGraph();
        AdjacencyMatrixVertex vertex = new AdjacencyMatrixVertex(graph, "id");

        assertEquals("id", vertex.getId());
    }
View Full Code Here

    /**
     * Test of toString method, of class AdjacencyMatrixVertex.
     */
    public void testToString() {
        AdjacencyMatrixGraph graph = new AdjacencyMatrixGraph();
        AdjacencyMatrixVertex vertex = new AdjacencyMatrixVertex(graph, "id");

        assertEquals("id", vertex.toString());
    }
View Full Code Here

    /**
     * Test of equals method, of class AdjacencyMatrixVertex.
     */
    public void testEquals() {
        AdjacencyMatrixGraph graph = new AdjacencyMatrixGraph();
        AdjacencyMatrixVertex v1 = new AdjacencyMatrixVertex(graph, "id");
        AdjacencyMatrixVertex v2 = new AdjacencyMatrixVertex(graph, "id");
        AdjacencyMatrixVertex v3 = new AdjacencyMatrixVertex(graph, "id2");
        AdjacencyMatrixVertex v4 = new AdjacencyMatrixVertex(graph, null);
        AdjacencyMatrixVertex v5 = new AdjacencyMatrixVertex(graph, null);
View Full Code Here

    /**
     * Test of hashCode method, of class AdjacencyMatrixVertex.
     */
    public void testHashCode() {

        AdjacencyMatrixGraph graph = new AdjacencyMatrixGraph();
        AdjacencyMatrixVertex v1 = new AdjacencyMatrixVertex(graph, "id");
        AdjacencyMatrixVertex v2 = new AdjacencyMatrixVertex(graph, "id");
        AdjacencyMatrixVertex v3 = new AdjacencyMatrixVertex(graph, "id2");
        AdjacencyMatrixVertex v4 = new AdjacencyMatrixVertex(graph, null);
        AdjacencyMatrixVertex v5 = new AdjacencyMatrixVertex(graph, null);
View Full Code Here

TOP

Related Classes of org.openjgraph.model.adjacencymatrix.AdjacencyMatrixGraph

Copyright © 2018 www.massapicom. 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.