private IList <EdgeYanQi> CreateListOfVerticesWhileAlsoPopulatingIdMapper(MapperForIntegerIdsAndGeneralStringIds idMapper) { IList <E> edges = this.GetGraph().Edges; IList <EdgeYanQi> vertices = new List <EdgeYanQi>(); foreach (E edge in edges) { int integerIdForStartVertex = idMapper.CreateOrRetrieveIntegerId(edge.StartVertex.VertexId); int integerIdForEndVertex = idMapper.CreateOrRetrieveIntegerId(edge.EndVertex.VertexId); vertices.Add(new EdgeYanQi(integerIdForStartVertex, integerIdForEndVertex, edge.EdgeWeight.WeightValue)); } return(vertices); }
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; }