public bool IsIsomorphy() { Graph <String, String> graph1 = new Graph <string, string>(); Graph <String, String> graph2 = new Graph <string, string>(); // The first nodes is always ID 0 and the rest // follow so we have nodes 0, 1, 2 and 3 var nodesDictionary1 = new Dictionary <string, int>(); var nodesDictionary2 = new Dictionary <string, int>(); int id = 0; foreach (NodeModel node in model1.NodesSource) { graph1.InsertVertex(node.Key); nodesDictionary1.Add(node.Key, id++); } id = 0; foreach (NodeModel node in model2.NodesSource) { graph2.InsertVertex(node.Key); nodesDictionary2.Add(node.Key, id++); } foreach (LinkModel link in model1.LinksSource) { graph1.AddEdge(nodesDictionary1[link.From], nodesDictionary1[link.To], link.Weight); } foreach (LinkModel link in model2.LinksSource) { graph2.AddEdge(nodesDictionary2[link.From], nodesDictionary2[link.To], link.Weight); } var vfs = new VfState <String, String>(graph1, graph2, true, true); FullMapping fIsomorphic = vfs.Match(); if (fIsomorphic == null) { return(false); } return(true); }
public void FullMappingWorks() { DirectMapping mapper = new DirectMapping("Y"); BaseTransformation[] transformations = new BaseTransformation[] { }; SingleMapping singleMapping = new SingleMapping(mapper, transformations); FullMapping fullMapping = new FullMapping(); fullMapping.AddMapping("Z", singleMapping); Dictionary <string, object> inputRow = new Dictionary <string, object>(); inputRow.Add("X", "a"); inputRow.Add("Y", "b"); Dictionary <string, object> expected = new Dictionary <string, object>(); expected.Add("Z", "b"); Dictionary <string, object> actual = fullMapping.GetRow(inputRow); CollectionAssert.AreEqual(expected, actual, "Full mapping didn't work as expected"); }