public void testGetOriginalObjectInstancesOfTheEdges() { List <Edge> originalEdges = new List <Edge> { edgeX1, edgeY1 }; List <Edge> equalEdgesButOtherInstances = new List <Edge> { edgeX2, edgeY2 }; AreEqual(originalEdges[0], equalEdgesButOtherInstances[0]); AreEqual(originalEdges[1], equalEdgesButOtherInstances[1]); // Note that the above were equal but they are NOT the same instances as you can see here: IsFalse(originalEdges[0] == equalEdgesButOtherInstances[0]); IsFalse(originalEdges[1] == equalEdgesButOtherInstances[1]); EdgeMapper <Edge, Vertex, Weight> edgeMapper = EdgeMapper <Edge, Vertex, Weight> .CreateEdgeMapper <Edge, Vertex, Weight>(originalEdges); IList <Edge> originalObjectInstancesOfTheEdges = edgeMapper.GetOriginalObjectInstancesOfTheEdges(equalEdgesButOtherInstances); // Note that the input parameter above vas the list which did NOT have the same instances as the original // list (i.e. the list passed into the constructor of EdgeMapper) but the returned list should have the same // instances, and they should be mapped through the id of the edge AreSame(originalEdges[0], originalObjectInstancesOfTheEdges[0]); AreSame(originalEdges[1], originalObjectInstancesOfTheEdges[1]); }
/// <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); }
public void testGetOriginalEdgeInstance() { IList <Edge> originalEdges = new List <Edge> { edgeX1, edgeY1 }; EdgeMapper <Edge, Vertex, Weight> edgeMapper = EdgeMapper <Edge, Vertex, Weight> .CreateEdgeMapper <Edge, Vertex, Weight>(originalEdges); // the same edge instance should be retrieve when we below pass in the string ids for the vertices of the edge AreSame(edgeX1, edgeMapper.GetOriginalEdgeInstance(edgeX1.StartVertex.VertexId, edgeX1.EndVertex.VertexId)); AreSame(edgeY1, edgeMapper.GetOriginalEdgeInstance(edgeY1.StartVertex.VertexId, edgeY1.EndVertex.VertexId)); }