public void EqualsTest() { Vertex v = new Vertex(); Vertex g = new Vertex(); Edge eVV = new Edge(v, v); Edge eVG = new Edge(v, g); Edge eGV = new Edge(g, v); Edge eGG = new Edge(g, g); Assert.IsTrue(eGG.Equals(eGG)); Assert.IsTrue(eGG.Equals(new Edge(g, g))); Assert.IsTrue(eVG.Equals(new Edge(v, g))); Assert.IsTrue(eGG == (new Edge(g, g))); Assert.IsTrue(eVG == (new Edge(v, g))); Assert.IsFalse(eGV.Equals(eVG)); Assert.IsTrue(eVG != eGV); }
//Returns an edge which connects the vertices specified in e //instead of doing a reference comparison public Edge FindEdge(Edge e) { foreach (Edge edge in edges) { if (e.Equals(edge)) { return edge; } } return null; }