public void TestEdgeContraction() { //NativeMethods.AllocConsole(); RootGraph root = Utils.CreateUniqueTestGraph(); Node tail = root.GetOrAddNode("x"); Node head = root.GetOrAddNode("xx"); Node other = root.GetOrAddNode("xxx"); Edge contracted = root.GetOrAddEdge(tail, head, "tocontract"); Edge parallel = root.GetOrAddEdge(tail, head, "parallel"); Edge counterparallel = root.GetOrAddEdge(head, tail, "counterparallel"); Edge tailout = root.GetOrAddEdge(tail, other, "tailout"); Edge headout = root.GetOrAddEdge(head, other, "headout"); Edge tailin = root.GetOrAddEdge(other, tail, "tailin"); Edge headin = root.GetOrAddEdge(other, head, "headin"); foreach (Node n in root.Nodes()) { n.SafeSetAttribute("label", n.GetName(), "no"); n.SafeSetAttribute("fontname", "Arial", "Arial"); foreach (Edge e in n.EdgesOut()) { e.SafeSetAttribute("label", e.GetName(), "no"); e.SafeSetAttribute("fontname", "Arial", "Arial"); } } Assert.AreEqual(5, tail.TotalDegree()); Assert.AreEqual(5, head.TotalDegree()); Assert.AreEqual(3, root.Nodes().Count()); Node contraction = root.Contract(contracted, "contraction result"); foreach (Node n in root.Nodes()) { n.SafeSetAttribute("label", n.GetName(), "no"); n.SafeSetAttribute("fontname", "Arial", "Arial"); foreach (Edge e in n.EdgesOut()) { e.SafeSetAttribute("label", e.GetName(), "no"); e.SafeSetAttribute("fontname", "Arial", "Arial"); } } //Console.Read(); Assert.AreEqual(2, root.Nodes().Count()); Assert.AreEqual(2, contraction.InDegree()); Assert.AreEqual(2, contraction.OutDegree()); Assert.AreEqual(2, other.InDegree()); Assert.AreEqual(2, other.OutDegree()); }