public static NodePairings GetDistance(List <InstructionNode> sourceGraph, List <InstructionNode> imageGraph) { List <LabeledVertex> sourceGraphLabeled = GetLabeled(sourceGraph); List <LabeledVertex> imageGraphLabeled = GetLabeled(imageGraph); var retNodes = sourceGraph.Where(x => VertexScorer.OutDataCodes.Contains(x.Instruction.OpCode.Code)); var backRetTree = retNodes.SelectMany(x => BackSearcher.GetBackDataTree(x)).Distinct().Concat(retNodes).ToList(); backRetTree.AddRange(backRetTree.ToList().SelectMany(x => x.BranchProperties.Branches.Select(y => y.OriginatingNode))); var backRetTreeIndexes = backRetTree.Select(x => x.InstructionIndex).ToList(); foreach (var backRetNode in sourceGraphLabeled.Where(x => backRetTreeIndexes.Contains(x.Index))) { backRetNode.IsInReturnBackTree = true; } NodePairings bestMatch = GetPairings(sourceGraphLabeled, imageGraphLabeled); object lockObject = new object(); //TODO change back to 10 Parallel.For(1, 1, (i) => { NodePairings pairing = GetPairings(sourceGraphLabeled, imageGraphLabeled); if (pairing.TotalScore > 1) { throw new Exception(""); } lock (lockObject) { if (pairing.TotalScore > bestMatch.TotalScore) { bestMatch = pairing; } } }); bestMatch.SourceSelfPairings = GetGraphSelfScore(sourceGraphLabeled); bestMatch.ImageSelfPairings = GetGraphSelfScore(imageGraphLabeled); return(bestMatch); }
private void MyView_KeyPress(object sender, KeyPressEventArgs e) { if (e.KeyChar == '/') { ObjectsToHide[HiddenNodesHideIndex].AddRange(myView.Selection); ObjectsToHide[HiddenNodesHideIndex].AddRange(myView.Selection.Where(x => x is GoNode).Cast <GoNode>().SelectMany(x => x.Links).Cast <GoLink>()); } else if (e.KeyChar == '.') { if (myView.Selection.Count > 0) { ObjectsToHide[DataBackTreeHideIndex].Clear(); var backTreeNodes = BackSearcher.GetBackDataTree(GetNodeWrapper(myView.Selection.First(x => x is GoNode) as GoNode).InstructionNode) .Select(x => GetNodeWrapper(x).Node).ToList(); ObjectsToHide[DataBackTreeHideIndex].AddRange(myView.Document.Where(x => (x is GoNode)).Cast <GoNode>().Except(backTreeNodes)); ObjectsToHide[DataBackTreeHideIndex].AddRange(myView.Document.Where(x => x is GoLink && (!backTreeNodes.Contains(((GoLink)x).FromNode) || !backTreeNodes.Contains(((GoLink)x).ToNode)))); } } else if (e.KeyChar == '\\') { if (myView.Selection.Count > 0) { ObjectsToHide[FlowBackTreeHideIndex].Clear(); var forwardFlowNodes = BackSearcher.GetForwardFlowTree(GetNodeWrapper(myView.Selection.First(x => x is GoNode) as GoNode).InstructionNode) .Select(x => GetNodeWrapper(x).Node).ToList(); ObjectsToHide[DataBackTreeHideIndex].AddRange(myView.Document.Where(x => (x is GoNode)).Cast <GoNode>().Except(forwardFlowNodes)); // ObjectsToHide[DataBackTreeHideIndex].AddRange(myView.Document.Where(x => x is GoLink && (!forwardFlowNodes.Contains(((GoLink) x).FromNode) || !forwardFlowNodes.Contains(((GoLink) x).ToNode)))); } } else if (e.KeyChar == '`') { if (myView.Selection.Count > 0) { ObjectsToHide[FlowBackTreeHideIndex].Clear(); var selectedNode = GetNodeWrapper(myView.Selection.First(x => x is GoNode) as GoNode).InstructionNode; var hiddenMethodNodes = myView.Document.Where(x => x is GoNode).Cast <GoNode>().Where(x => GetNodeWrapper(x).InstructionNode.Method == selectedNode.Method); ObjectsToHide[DataBackTreeHideIndex].AddRange(hiddenMethodNodes); ObjectsToHide[DataBackTreeHideIndex].AddRange(myView.Document.Where(x => x is GoLink && (hiddenMethodNodes.Contains(((GoLink)x).FromNode) || hiddenMethodNodes.Contains(((GoLink)x).ToNode)))); } } else if (e.KeyChar == '+') { if (myView.Selection.Count > 0) { ObjectsToHide[DataBackTreeHideIndex].Clear(); var backTreeNodes = BackSearcher.GetBackFlowTree(GetNodeWrapper(myView.Selection.First(x => x is GoNode) as GoNode).InstructionNode) .Select(x => GetNodeWrapper(x).Node).ToList(); ObjectsToHide[DataBackTreeHideIndex].AddRange(myView.Document.Where(x => (x is GoNode)).Cast <GoNode>().Except(backTreeNodes)); ObjectsToHide[DataBackTreeHideIndex].AddRange(myView.Document.Where(x => x is GoLink && (!backTreeNodes.Contains(((GoLink)x).FromNode) || !backTreeNodes.Contains(((GoLink)x).ToNode)))); } } else if (e.KeyChar == '*') { ObjectsToHide.ForEach(x => ObjectsToHide[x.Key].Clear()); } else if (e.KeyChar == '=') { var selectedNode = myView.Selection.Where(x => x is GoTextNode).Cast <GoTextNode>().FirstOrDefault(); if (selectedNode == null) { return; } DrawCloser(selectedNode, selectedNode, dataLinksLayer, 2); } else if (e.KeyChar == '-') { var selectedNode = myView.Selection.Where(x => x is GoTextNode).Cast <GoTextNode>().FirstOrDefault(); if (selectedNode == null) { return; } DrawCloser(selectedNode, selectedNode, flowRoutesLinksLayer, 2); } ReShow(); }