예제 #1
0
 protected PathFinderQuikGraphGenerics(
     GraphGenerics <E, V, W> graph,
     PathFactory <P, E, V, W> pathFactory
     ) : base(graph, pathFactory)
 {
     PopulateGraphAdapteeWithEdges();
 }
        public void testGetVertices()
        {
            IList <EdgeGenerics <Vertex, Weight> > edges = new List <EdgeGenerics <Vertex, Weight> >();

            edges.Add(createEdgeGenerics(CreateVertex("A"), CreateVertex("B"), CreateWeight(1)));
            edges.Add(createEdgeGenerics(CreateVertex("A"), CreateVertex("C"), CreateWeight(2)));
            edges.Add(createEdgeGenerics(CreateVertex("A"), CreateVertex("D"), CreateWeight(3)));
            edges.Add(createEdgeGenerics(CreateVertex("B"), CreateVertex("C"), CreateWeight(4)));
            edges.Add(createEdgeGenerics(CreateVertex("B"), CreateVertex("D"), CreateWeight(5)));
            edges.Add(createEdgeGenerics(CreateVertex("C"), CreateVertex("D"), CreateWeight(6)));

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

            IList <Vertex> vertices = graph.Vertices;

            IList <string> expectedVerticesIds = new List <string> {
                "A", "B", "C", "D"
            };

            AreEqual(expectedVerticesIds.Count, vertices.Count);

            // verify that all vertices in all edges is one of the four above
            foreach (EdgeGenerics <Vertex, Weight> edge in edges)
            {
                // Java version used hamcrest as below:
                //assertThat(expectedVerticesIds, hasItem(edge.getStartVertex().getVertexId()));
                //assertThat(expectedVerticesIds, hasItem(edge.getEndVertex().getVertexId()));
                IsTrue(expectedVerticesIds.Contains(edge.StartVertex.VertexId));
                IsTrue(expectedVerticesIds.Contains(edge.EndVertex.VertexId));
                //Fail("fix the test");
            }
        }
        public override F CreatePathFinder(GraphGenerics <E, V, W> graph)
        {
            PathFinderGenerics <P, E, V, W> pathFinder = new PathFinderBsmockGenerics <P, E, V, W>(graph);

            // TODO: try to get rid of the casting below ( warning: "Type safety: Unchecked cast from PathFinderYanQi<P,E,V,W> to F" )
            return((F)pathFinder);
        }
예제 #4
0
 public PathFinderYanQiGenerics(
     GraphGenerics <E, V, W> graph
     ) :  this(
         graph,
         null
         )
 {
 }
예제 #5
0
 public PathFinderBsmockGenerics(
     GraphGenerics <E, V, W> graph
     ) :  this(
         graph,
         null
         )
 {
 }
        /// <param name="edges">list of edges</param>
        /// <param name="graphEdgesValidationDesired">should be NO (for performance reason) if validation has already been done</param>
        /// <returns>an instance of a PathFinderGenerics implementation</returns>
        public F CreatePathFinder(
            IList <E> edges,
            GraphEdgesValidationDesired graphEdgesValidationDesired
            )
        {
            GraphGenerics <E, V, W> graph = GraphGenericsImpl <E, V, W> .CreateGraphGenerics <E, V, W>(edges, graphEdgesValidationDesired);

            return(CreatePathFinder(graph));    // the overloaded method must be implemented by subclasses
        }
        private W weightProtoypeFactory = default(W);     // null in Java version

        protected PathFinderBase(
            GraphGenerics <E, V, W> graph
            ) :
            this(
                graph,
                null
                )
        {
        }
예제 #8
0
 protected PathFinderBsmockGenerics(
     GraphGenerics <E, V, W> graph,
     PathFactory <P, E, V, W> pathFactory
     ) : base(graph, pathFactory)
 {
     this.yenAlgorithm = new Yen();
     this.graphAdaptee = new edu.ufl.cise.bsmock.graph.Graph();
     PopulateGraphAdapteeWithEdges();
 }
 /// <summary>
 ///
 /// </summary>
 /// <param name="graph">an implementation of the interface GraphGenerics</param>
 /// <param name="pathFactory">an implementation of the interface PathFactory, if null then a default instance will be created</param>
 protected PathFinderBase(
     GraphGenerics <E, V, W> graph,
     PathFactory <P, E, V, W> pathFactory
     )
 {
     this.graph       = graph;
     this.pathFactory = pathFactory != null ? pathFactory : CreateStandardInstanceOfPathFactory();
     // Precondition to method below is that validation is performed i.e.
     // the method below will NOT try to validate,
     edgeMapper = EdgeMapper <E, V, W> .CreateEdgeMapper <E, V, W>(graph.Edges);
 }
예제 #10
0
        protected PathFinderYanQiGenerics(
            GraphGenerics <E, V, W> graph,
            PathFactory <P, E, V, W> pathFactory
            ) : base(graph, pathFactory)
        {
            MapperForIntegerIdsAndGeneralStringIds idMapper = MapperForIntegerIdsAndGeneralStringIds.CreateIdMapper(0);
            IList <EdgeYanQi> vertices = CreateListOfVerticesWhileAlsoPopulatingIdMapper(idMapper);

            // "Adaptee" https://en.wikipedia.org/wiki/Adapter_pattern
            this.graphAdaptee = new GraphPossibleToCreateProgrammatically(
                idMapper.GetNumberOfVertices(),
                vertices
                );
            this.idMapper = idMapper;
        }
        public void testGetAllEdges()
        {
            IList <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);

            IList <EdgeGenerics <Vertex, Weight> > allEdges = graph.Edges;

            AreEqual(2, allEdges.Count);
            AreSame(edge1, allEdges[0]);
            AreSame(edge2, allEdges[1]);
        }
        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 testContainsVertex()
        {
            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.ContainsVertex(edge1.StartVertex));
            IsTrue(graph.ContainsVertex(edge1.EndVertex));
            IsTrue(graph.ContainsVertex(edge2.StartVertex));
            IsTrue(graph.ContainsVertex(edge2.EndVertex));

            Vertex vertex = CreateVertex("QWERTY");

            IsFalse(graph.ContainsVertex(vertex));
        }
 public override PathFinder CreatePathFinder(
     GraphGenerics <Edge, Vertex, Weight> graph
     )
 {
     return(new PathFinderYanQi(graph));
 }
 abstract public F CreatePathFinder(
     GraphGenerics <E, V, W> graph
     );
예제 #16
0
        public override F CreatePathFinder(GraphGenerics <E, V, W> graph)
        {
            PathFinderGenerics <P, E, V, W> pathFinder = new PathFinderQuikGraphGenerics <P, E, V, W>(graph);

            return((F)pathFinder);
        }
예제 #17
0
 public PathFinderBsmock(
     GraphGenerics <Edge, Vertex, Weight> graph
     ) : base(graph, new PathFactoryDefault())
 {
 }