Beispiel #1
0
 private void assertNotNulls(EdgeGenerics <Vertex, Weight> edge)
 {
     IsNotNull(edge);
     IsNotNull(edge.StartVertex);
     IsNotNull(edge.EndVertex);
     IsNotNull(edge.EdgeWeight);
 }
Beispiel #2
0
        public void testFromMultiLineStringToListOfEdgesGenerics()
        {
            //	    <graphDefinition>
            //	    A B 5
            //	    A C 6
            //	    B C 7
            //	    B D 8
            //	    C D 9
            //	    </graphDefinition>
            const String multiLinedString = "A B 5\r\n" +
                                            "A C 6\r\n" +
                                            "B C 7\r\n" +
                                            "B D 8\r\n" +
                                            "C D 9";
            IList <Edge> edges = edgeParser.FromMultiLinedStringToListOfEdges(multiLinedString);

            IsNotNull(edges);
            AreEqual(5, edges.Count);
            EdgeGenerics <Vertex, Weight> firstEdge = edges[0];
            EdgeGenerics <Vertex, Weight> lastEdge  = edges[4];

            assertNotNulls(firstEdge);
            assertNotNulls(lastEdge);

            AreEqual("A", firstEdge.StartVertex.VertexId);
            AreEqual("B", firstEdge.EndVertex.VertexId);
            AreEqual(5, firstEdge.EdgeWeight.WeightValue, SMALL_DELTA_VALUE_FOR_WEIGHT_COMPARISONS);

            AreEqual("C", lastEdge.StartVertex.VertexId);
            AreEqual("D", lastEdge.EndVertex.VertexId);
            AreEqual(9, lastEdge.EdgeWeight.WeightValue, SMALL_DELTA_VALUE_FOR_WEIGHT_COMPARISONS);
        }
        public void testContainsEdge()
        {
            List <EdgeGenerics <Vertex, Weight> > edges = new List <EdgeGenerics <Vertex, Weight> >();

            edges.Add(edge1);
            edges.Add(edge2);
            // refactor the above three rows (duplicated)

            GraphGenerics <EdgeGenerics <Vertex, Weight>, Vertex, Weight> graph = createGraphGenerics(edges);

            IsTrue(graph.ContainsEdge(edge1));
            IsTrue(graph.ContainsEdge(edge2));

            EdgeGenerics <Vertex, Weight> edgeNotInTheGraph = createEdgeGenerics(CreateVertex("XYZ"), CreateVertex("QWERTY"), CreateWeight(987));

            IsFalse(graph.ContainsEdge(edgeNotInTheGraph));
        }
 public void setUp()
 {
     edge1 = createEdgeGenerics(CreateVertex("A"), CreateVertex("B"), CreateWeight(123));
     edge2 = createEdgeGenerics(CreateVertex("B"), CreateVertex("C"), CreateWeight(456));
 }
Beispiel #5
0
        public E CreateEdge(V startVertex, V endVertex, W weight)
        {
            EdgeGenerics <V, W> edge = EdgeGenericsImpl <V, W> .CreateEdgeGenerics(startVertex, endVertex, weight);

            return((E)edge);
        }