public void IsoNonSingletonBucketsNonIso() { GraphBuilder gh1 = new GraphBuilder(); GraphBuilder gh2 = new GraphBuilder(); Vertex root1 = gh1.InitGraph("Root", "label"); Vertex root2 = gh2.InitGraph("Root", "label"); Vertex[] g1nodes = new Vertex[2]; Vertex[] g2nodes = new Vertex[2]; g1nodes[0] = gh1.AddVertex("NodeType1", "a"); g1nodes[1] = gh1.AddVertex("NodeType1", "a"); g2nodes[1] = gh2.AddVertex("NodeType1", "a"); g2nodes[0] = gh2.AddVertex("NodeType1", "b"); gh1.AddRelationalTransition(root1, g1nodes[0], "l0"); gh1.AddRelationalTransition(root1, g1nodes[1], "l0"); gh2.AddRelationalTransition(root2, g2nodes[1], "l0"); gh2.AddRelationalTransition(root2, g2nodes[0], "l0"); RootedLabeledDirectedGraph g1 = gh1.GetGraph(); RootedLabeledDirectedGraph g2 = gh2.GetGraph(); Map <Vertex, Vertex> iso1 = GraphIsomorphism.ComputeIsomorphism1(g1, g2); Map <Vertex, Vertex> iso2 = GraphIsomorphism.ComputeIsomorphism2(g1, g2); Map <Vertex, Vertex> isoU = GraphIsomorphism.ComputeIsomorphismUllmann(g1, g2); Assert.IsNull(iso1); Assert.IsNull(iso2); Assert.IsNull(isoU); }
public void IsoBacktrack1() { GraphBuilder gh1 = new GraphBuilder(); GraphBuilder gh2 = new GraphBuilder(); Vertex root1 = gh1.InitGraph("Root", "label"); Vertex root2 = gh2.InitGraph("Root", "label"); Vertex[] g1nodes = new Vertex[5]; Vertex[] g2nodes = new Vertex[5]; //G1 nodes g1nodes[0] = gh1.AddVertex("Set", "0"); g1nodes[1] = gh1.AddVertex("Map", "0"); g1nodes[2] = gh1.AddVertex("NodeType1", "a"); g1nodes[3] = gh1.AddVertex("NodeType1", "a"); g1nodes[4] = gh1.AddVertex("NodeType1", "a"); //G2 nodes g2nodes[0] = gh2.AddVertex("Set", "0"); g2nodes[1] = gh2.AddVertex("Map", "0"); g2nodes[2] = gh2.AddVertex("NodeType1", "a"); g2nodes[3] = gh2.AddVertex("NodeType1", "a"); g2nodes[4] = gh2.AddVertex("NodeType1", "a"); //G1 transitions gh1.AddFunctionalTransition(root1, g1nodes[0], "l0"); gh1.AddFunctionalTransition(root1, g1nodes[1], "l1"); gh1.AddFunctionalTransition(g1nodes[1], g1nodes[2], "key"); gh1.AddFunctionalTransition(g1nodes[1], g1nodes[3], "value"); gh1.AddRelationalTransition(g1nodes[0], g1nodes[2], "in"); gh1.AddRelationalTransition(g1nodes[0], g1nodes[3], "in"); gh1.AddRelationalTransition(g1nodes[0], g1nodes[4], "in"); //G2 transitions gh2.AddFunctionalTransition(root2, g2nodes[0], "l0"); gh2.AddFunctionalTransition(root2, g2nodes[1], "l1"); gh2.AddFunctionalTransition(g2nodes[1], g2nodes[4], "key"); gh2.AddFunctionalTransition(g2nodes[1], g2nodes[2], "value"); gh2.AddRelationalTransition(g2nodes[0], g2nodes[2], "in"); gh2.AddRelationalTransition(g2nodes[0], g2nodes[3], "in"); gh2.AddRelationalTransition(g2nodes[0], g2nodes[4], "in"); RootedLabeledDirectedGraph g1 = gh1.GetGraph(); RootedLabeledDirectedGraph g2 = gh2.GetGraph(); Map <Vertex, Vertex> iso1 = GraphIsomorphism.ComputeIsomorphism1(g1, g2); Map <Vertex, Vertex> iso2 = GraphIsomorphism.ComputeIsomorphism2(g1, g2); Map <Vertex, Vertex> isoU = GraphIsomorphism.ComputeIsomorphismUllmann(g1, g2); Assert.AreEqual(iso1.Count, iso2.Count); Assert.AreEqual(iso1.Count, isoU.Count); Assert.AreEqual(6, iso2.Count); }
public void IsoBacktrack6() { GraphBuilder gh1 = new GraphBuilder(); GraphBuilder gh2 = new GraphBuilder(); Vertex root1 = gh1.InitGraph("Root", "label"); Vertex root2 = gh2.InitGraph("Root", "label"); Vertex[] g1nodes = new Vertex[12]; Vertex[] g2nodes = new Vertex[12]; //G1 nodes g1nodes[0] = gh1.AddVertex("Side", "a"); g1nodes[1] = gh1.AddVertex("Side", "a"); g1nodes[2] = gh1.AddVertex("Side", "a"); g1nodes[3] = gh1.AddVertex("Side", "a"); g1nodes[4] = gh1.AddVertex("Color", "b"); g1nodes[5] = gh1.AddVertex("Map", "map"); g1nodes[6] = gh1.AddVertex("Map", "map"); g1nodes[7] = gh1.AddVertex("Map", "map"); g1nodes[8] = gh1.AddVertex("Map", "map"); g1nodes[9] = gh1.AddVertex("Map", "map"); g1nodes[10] = gh1.AddVertex("Set", "set"); //G1 transitions gh1.AddRelationalTransition(root1, g1nodes[5], "r0"); gh1.AddRelationalTransition(root1, g1nodes[6], "r0"); gh1.AddRelationalTransition(root1, g1nodes[7], "r0"); gh1.AddRelationalTransition(root1, g1nodes[8], "r1"); gh1.AddRelationalTransition(root1, g1nodes[9], "r1"); gh1.AddFunctionalTransition(root1, g1nodes[10], "f1"); gh1.AddFunctionalTransition(g1nodes[5], g1nodes[3], "key"); gh1.AddFunctionalTransition(g1nodes[5], g1nodes[4], "value"); gh1.AddFunctionalTransition(g1nodes[6], g1nodes[0], "key"); gh1.AddFunctionalTransition(g1nodes[6], g1nodes[1], "value"); gh1.AddFunctionalTransition(g1nodes[7], g1nodes[3], "key"); gh1.AddFunctionalTransition(g1nodes[7], g1nodes[2], "value"); gh1.AddFunctionalTransition(g1nodes[8], g1nodes[2], "key"); gh1.AddFunctionalTransition(g1nodes[8], g1nodes[1], "value"); gh1.AddFunctionalTransition(g1nodes[9], g1nodes[3], "key"); gh1.AddFunctionalTransition(g1nodes[9], g1nodes[0], "value"); gh1.AddRelationalTransition(g1nodes[10], g1nodes[6], "in"); gh1.AddRelationalTransition(g1nodes[10], g1nodes[7], "in"); gh1.AddRelationalTransition(g1nodes[10], g1nodes[8], "in"); gh1.AddRelationalTransition(g1nodes[10], g1nodes[9], "in"); //G2 nodes g2nodes[0] = gh2.AddVertex("Side", "a"); g2nodes[1] = gh2.AddVertex("Side", "a"); g2nodes[2] = gh2.AddVertex("Side", "a"); g2nodes[3] = gh2.AddVertex("Side", "a"); g2nodes[4] = gh2.AddVertex("Color", "b"); g2nodes[5] = gh2.AddVertex("Map", "map"); g2nodes[6] = gh2.AddVertex("Map", "map"); g2nodes[7] = gh2.AddVertex("Map", "map"); g2nodes[8] = gh2.AddVertex("Map", "map"); g2nodes[9] = gh2.AddVertex("Map", "map"); g2nodes[10] = gh2.AddVertex("Set", "set"); //G2 transitions gh2.AddRelationalTransition(root1, g2nodes[8], "r0"); gh2.AddRelationalTransition(root1, g2nodes[6], "r0"); gh2.AddRelationalTransition(root1, g2nodes[7], "r0"); gh2.AddRelationalTransition(root1, g2nodes[5], "r1"); gh2.AddRelationalTransition(root1, g2nodes[9], "r1"); gh2.AddFunctionalTransition(root1, g2nodes[10], "f1"); gh2.AddFunctionalTransition(g2nodes[5], g2nodes[2], "key"); gh2.AddFunctionalTransition(g2nodes[5], g2nodes[0], "value"); gh2.AddFunctionalTransition(g2nodes[6], g2nodes[1], "key"); gh2.AddFunctionalTransition(g2nodes[6], g2nodes[0], "value"); gh2.AddFunctionalTransition(g2nodes[7], g2nodes[3], "key"); gh2.AddFunctionalTransition(g2nodes[7], g2nodes[2], "value"); gh2.AddFunctionalTransition(g2nodes[8], g2nodes[3], "key"); gh2.AddFunctionalTransition(g2nodes[8], g2nodes[4], "value"); gh2.AddFunctionalTransition(g2nodes[9], g2nodes[3], "key"); gh2.AddFunctionalTransition(g2nodes[9], g2nodes[1], "value"); gh2.AddRelationalTransition(g2nodes[10], g2nodes[6], "in"); gh2.AddRelationalTransition(g2nodes[10], g2nodes[7], "in"); gh2.AddRelationalTransition(g2nodes[10], g2nodes[5], "in"); gh2.AddRelationalTransition(g2nodes[10], g2nodes[9], "in"); RootedLabeledDirectedGraph g1 = gh1.GetGraph(); RootedLabeledDirectedGraph g2 = gh2.GetGraph(); Map <Vertex, Vertex> iso1 = GraphIsomorphism.ComputeIsomorphism1(g1, g2); Map <Vertex, Vertex> iso2 = GraphIsomorphism.ComputeIsomorphism2(g1, g2); Map <Vertex, Vertex> isoU = GraphIsomorphism.ComputeIsomorphismUllmann(g1, g2); if (iso1 == null && iso2 == null && isoU == null) { throw new Exception("None of the algorithms found the graphs isomorphic"); } Assert.AreEqual(iso1.Count, iso2.Count); Assert.AreEqual(iso1.Count, isoU.Count); Assert.AreEqual(12, iso2.Count); }
public void IsoSingletonBuckets2() { GraphBuilder gh1 = new GraphBuilder(); GraphBuilder gh2 = new GraphBuilder(); Vertex root1 = gh1.InitGraph("Root", "label"); Vertex root2 = gh2.InitGraph("Root", "label"); Vertex[] g1nodes = new Vertex[2]; Vertex[] g2nodes = new Vertex[2]; g1nodes[0] = gh1.AddVertex("NodeType1", "a"); g1nodes[1] = gh1.AddVertex("NodeType1", "b"); g2nodes[1] = gh2.AddVertex("NodeType1", "a"); g2nodes[0] = gh2.AddVertex("NodeType1", "b"); gh1.AddRelationalTransition(root1, g1nodes[0], "l0"); gh1.AddRelationalTransition(root1, g1nodes[1], "l0"); gh2.AddRelationalTransition(root2, g2nodes[1], "l0"); gh2.AddRelationalTransition(root2, g2nodes[0], "l0"); RootedLabeledDirectedGraph g1 = gh1.GetGraph(); RootedLabeledDirectedGraph g2 = gh2.GetGraph(); Map<Vertex, Vertex> iso1 = GraphIsomorphism.ComputeIsomorphism1(g1, g2); Map<Vertex, Vertex> iso2 = GraphIsomorphism.ComputeIsomorphism2(g1, g2); Map<Vertex, Vertex> isoU = GraphIsomorphism.ComputeIsomorphismUllmann(g1, g2); Assert.AreEqual(iso1.Count, iso2.Count); Assert.AreEqual(iso1.Count, isoU.Count); Assert.AreEqual(3, iso2.Count); }
public void IsoBacktrack6() { GraphBuilder gh1 = new GraphBuilder(); GraphBuilder gh2 = new GraphBuilder(); Vertex root1 = gh1.InitGraph("Root", "label"); Vertex root2 = gh2.InitGraph("Root", "label"); Vertex[] g1nodes = new Vertex[12]; Vertex[] g2nodes = new Vertex[12]; //G1 nodes g1nodes[0] = gh1.AddVertex("Side", "a"); g1nodes[1] = gh1.AddVertex("Side", "a"); g1nodes[2] = gh1.AddVertex("Side", "a"); g1nodes[3] = gh1.AddVertex("Side", "a"); g1nodes[4] = gh1.AddVertex("Color", "b"); g1nodes[5] = gh1.AddVertex("Map", "map"); g1nodes[6] = gh1.AddVertex("Map", "map"); g1nodes[7] = gh1.AddVertex("Map", "map"); g1nodes[8] = gh1.AddVertex("Map", "map"); g1nodes[9] = gh1.AddVertex("Map", "map"); g1nodes[10] = gh1.AddVertex("Set", "set"); //G1 transitions gh1.AddRelationalTransition(root1, g1nodes[5], "r0"); gh1.AddRelationalTransition(root1, g1nodes[6], "r0"); gh1.AddRelationalTransition(root1, g1nodes[7], "r0"); gh1.AddRelationalTransition(root1, g1nodes[8], "r1"); gh1.AddRelationalTransition(root1, g1nodes[9], "r1"); gh1.AddFunctionalTransition(root1, g1nodes[10], "f1"); gh1.AddFunctionalTransition(g1nodes[5], g1nodes[3], "key"); gh1.AddFunctionalTransition(g1nodes[5], g1nodes[4], "value"); gh1.AddFunctionalTransition(g1nodes[6], g1nodes[0], "key"); gh1.AddFunctionalTransition(g1nodes[6], g1nodes[1], "value"); gh1.AddFunctionalTransition(g1nodes[7], g1nodes[3], "key"); gh1.AddFunctionalTransition(g1nodes[7], g1nodes[2], "value"); gh1.AddFunctionalTransition(g1nodes[8], g1nodes[2], "key"); gh1.AddFunctionalTransition(g1nodes[8], g1nodes[1], "value"); gh1.AddFunctionalTransition(g1nodes[9], g1nodes[3], "key"); gh1.AddFunctionalTransition(g1nodes[9], g1nodes[0], "value"); gh1.AddRelationalTransition(g1nodes[10], g1nodes[6], "in"); gh1.AddRelationalTransition(g1nodes[10], g1nodes[7], "in"); gh1.AddRelationalTransition(g1nodes[10], g1nodes[8], "in"); gh1.AddRelationalTransition(g1nodes[10], g1nodes[9], "in"); //G2 nodes g2nodes[0] = gh2.AddVertex("Side", "a"); g2nodes[1] = gh2.AddVertex("Side", "a"); g2nodes[2] = gh2.AddVertex("Side", "a"); g2nodes[3] = gh2.AddVertex("Side", "a"); g2nodes[4] = gh2.AddVertex("Color", "b"); g2nodes[5] = gh2.AddVertex("Map", "map"); g2nodes[6] = gh2.AddVertex("Map", "map"); g2nodes[7] = gh2.AddVertex("Map", "map"); g2nodes[8] = gh2.AddVertex("Map", "map"); g2nodes[9] = gh2.AddVertex("Map", "map"); g2nodes[10] = gh2.AddVertex("Set", "set"); //G2 transitions gh2.AddRelationalTransition(root1, g2nodes[8], "r0"); gh2.AddRelationalTransition(root1, g2nodes[6], "r0"); gh2.AddRelationalTransition(root1, g2nodes[7], "r0"); gh2.AddRelationalTransition(root1, g2nodes[5], "r1"); gh2.AddRelationalTransition(root1, g2nodes[9], "r1"); gh2.AddFunctionalTransition(root1, g2nodes[10], "f1"); gh2.AddFunctionalTransition(g2nodes[5], g2nodes[2], "key"); gh2.AddFunctionalTransition(g2nodes[5], g2nodes[0], "value"); gh2.AddFunctionalTransition(g2nodes[6], g2nodes[1], "key"); gh2.AddFunctionalTransition(g2nodes[6], g2nodes[0], "value"); gh2.AddFunctionalTransition(g2nodes[7], g2nodes[3], "key"); gh2.AddFunctionalTransition(g2nodes[7], g2nodes[2], "value"); gh2.AddFunctionalTransition(g2nodes[8], g2nodes[3], "key"); gh2.AddFunctionalTransition(g2nodes[8], g2nodes[4], "value"); gh2.AddFunctionalTransition(g2nodes[9], g2nodes[3], "key"); gh2.AddFunctionalTransition(g2nodes[9], g2nodes[1], "value"); gh2.AddRelationalTransition(g2nodes[10], g2nodes[6], "in"); gh2.AddRelationalTransition(g2nodes[10], g2nodes[7], "in"); gh2.AddRelationalTransition(g2nodes[10], g2nodes[5], "in"); gh2.AddRelationalTransition(g2nodes[10], g2nodes[9], "in"); RootedLabeledDirectedGraph g1 = gh1.GetGraph(); RootedLabeledDirectedGraph g2 = gh2.GetGraph(); Map<Vertex, Vertex> iso1 = GraphIsomorphism.ComputeIsomorphism1(g1, g2); Map<Vertex, Vertex> iso2 = GraphIsomorphism.ComputeIsomorphism2(g1, g2); Map<Vertex, Vertex> isoU = GraphIsomorphism.ComputeIsomorphismUllmann(g1, g2); if (iso1 == null && iso2 == null && isoU == null) throw new Exception("None of the algorithms found the graphs isomorphic"); Assert.AreEqual(iso1.Count, iso2.Count); Assert.AreEqual(iso1.Count, isoU.Count); Assert.AreEqual(12, iso2.Count); }
public void IsoBacktrack3() { GraphBuilder gh1 = new GraphBuilder(); GraphBuilder gh2 = new GraphBuilder(); Vertex root1 = gh1.InitGraph("Root", "label"); Vertex root2 = gh2.InitGraph("Root", "label"); Vertex[] g1nodes = new Vertex[9]; Vertex[] g2nodes = new Vertex[9]; //G1 nodes g1nodes[0] = gh1.AddVertex("Set", "0"); g1nodes[1] = gh1.AddVertex("Map", "0"); g1nodes[2] = gh1.AddVertex("NodeType1", "a"); g1nodes[3] = gh1.AddVertex("NodeType1", "a"); g1nodes[4] = gh1.AddVertex("NodeType1", "a"); g1nodes[5] = gh1.AddVertex("NodeType1", "a"); g1nodes[6] = gh1.AddVertex("Map", "0"); g1nodes[7] = gh1.AddVertex("Set", "1"); g1nodes[8] = gh1.AddVertex("Set", "2"); //G2 nodes g2nodes[0] = gh2.AddVertex("Set", "0"); g2nodes[1] = gh2.AddVertex("Map", "0"); g2nodes[2] = gh2.AddVertex("NodeType1", "a"); g2nodes[3] = gh2.AddVertex("NodeType1", "a"); g2nodes[4] = gh2.AddVertex("NodeType1", "a"); g2nodes[5] = gh2.AddVertex("NodeType1", "a"); g2nodes[6] = gh2.AddVertex("Map", "0"); g2nodes[7] = gh2.AddVertex("Set", "1"); g2nodes[8] = gh2.AddVertex("Set", "2"); //G1 transitions gh1.AddFunctionalTransition(root1, g1nodes[0], "l0"); gh1.AddRelationalTransition(root1, g1nodes[1], "l1"); gh1.AddRelationalTransition(root1, g1nodes[6], "l1"); gh1.AddFunctionalTransition(g1nodes[1], g1nodes[2], "key"); gh1.AddFunctionalTransition(g1nodes[1], g1nodes[3], "value"); gh1.AddFunctionalTransition(g1nodes[6], g1nodes[2], "key"); gh1.AddFunctionalTransition(g1nodes[6], g1nodes[3], "value"); gh1.AddRelationalTransition(g1nodes[0], g1nodes[7], "in"); gh1.AddRelationalTransition(g1nodes[0], g1nodes[8], "in"); gh1.AddRelationalTransition(g1nodes[7], g1nodes[4], "in"); gh1.AddRelationalTransition(g1nodes[7], g1nodes[5], "in"); gh1.AddRelationalTransition(g1nodes[8], g1nodes[2], "in"); gh1.AddRelationalTransition(g1nodes[8], g1nodes[3], "in"); //G2 transitions gh2.AddFunctionalTransition(root2, g2nodes[0], "l0"); gh2.AddRelationalTransition(root2, g2nodes[1], "l1"); gh2.AddRelationalTransition(root2, g2nodes[6], "l1"); gh2.AddFunctionalTransition(g2nodes[1], g2nodes[4], "key"); gh2.AddFunctionalTransition(g2nodes[1], g2nodes[2], "value"); gh2.AddFunctionalTransition(g2nodes[6], g2nodes[4], "key"); gh2.AddFunctionalTransition(g2nodes[6], g2nodes[2], "value"); gh2.AddRelationalTransition(g2nodes[0], g2nodes[8], "in"); gh2.AddRelationalTransition(g2nodes[0], g2nodes[7], "in"); gh2.AddRelationalTransition(g2nodes[8], g2nodes[4], "in"); gh2.AddRelationalTransition(g2nodes[8], g2nodes[2], "in"); gh2.AddRelationalTransition(g2nodes[7], g2nodes[5], "in"); gh2.AddRelationalTransition(g2nodes[7], g2nodes[3], "in"); RootedLabeledDirectedGraph g1 = gh1.GetGraph(); RootedLabeledDirectedGraph g2 = gh2.GetGraph(); Map<Vertex, Vertex> iso1 = GraphIsomorphism.ComputeIsomorphism1(g1, g2); Map<Vertex, Vertex> iso2 = GraphIsomorphism.ComputeIsomorphism2(g1, g2); Map<Vertex, Vertex> isoU = GraphIsomorphism.ComputeIsomorphismUllmann(g1, g2); Assert.AreEqual(iso1.Count, iso2.Count); Assert.AreEqual(iso1.Count, isoU.Count); Assert.AreEqual(10, iso2.Count); }