public void TestContractingEdges() { var graph = new AmortizedGraph <Char>((oldEdge, newEdge) => oldEdge > newEdge); var a = new CharAmortizedNode('A'); var b = new CharAmortizedNode('B'); graph.AddNode(a); graph.AddNode(b); graph.AddUndirectedEdge(a, b, 10); Assert.AreEqual(10, a.Cost(b)); graph.UpdateUndirectedEdge(a, b, 20); Assert.AreEqual(10, a.Cost(b)); graph.UpdateUndirectedEdge(a, b, 6); Assert.AreEqual(8, a.Cost(b)); }
public void TestEveryEdge() { var graph = new AmortizedGraph <Char>((oldEdge, newEdge) => true); var a = new CharAmortizedNode('A'); var b = new CharAmortizedNode('B'); graph.AddNode(a); graph.AddNode(b); graph.AddUndirectedEdge(a, b, 10); Assert.AreEqual(10, a.Cost(b)); graph.UpdateUndirectedEdge(a, b, 20); Assert.AreEqual(15, a.Cost(b)); graph.UpdateUndirectedEdge(a, b, 6); Assert.AreEqual(12, a.Cost(b)); }