/// <summary> /// Method to save the DGML graph to the given fileName. /// </summary> /// <param name="fileName">Name of the dgml file whose path we want to determine.</param> /// <param name="graph">The <see cref="GraphCreator"/> to save in the specified file path.</param> private void SaveGraph(string fileName, GraphCreator graph) { if (this.Options.GraphPath == null) { return; } string relativePath = this.Options.GraphPath; string currentDirectory = Directory.GetCurrentDirectory(); string outputDirectory = Path.GetFullPath(Path.Combine(currentDirectory, relativePath)); if (!Directory.Exists(outputDirectory)) { string missingMessage = string.Format( CultureInfo.CurrentCulture, Strings.MissingRelativePath, relativePath); this.Options.ErrorWriter.WriteLine(missingMessage); outputDirectory = currentDirectory; } string outputPath = Path.GetFullPath(Path.Combine(outputDirectory, fileName)); graph.SaveGraph(outputPath); string savedMessage = string.Format( CultureInfo.CurrentCulture, Strings.SavedGraphMessage, fileName); this.Options.Writer.WriteLine(savedMessage); }
void Start() { TogglePanel(0); ship = FindObjectOfType <ShipMovement>(); graphCreator = FindObjectOfType <GraphCreator>(); }
/// <summary> /// Initiates the Aras export and .dot graph creation and export. /// </summary> /// <remarks> /// Only gets called if the command line arguments were parsed successfully. /// </remarks> /// <param name="options">The <see cref="ArgOptions"/> the program was started with.</param> private static void RunOptionsAndPerformLogic(ArgOptions options) { var arasExport = PerformArasExport(options); var graphCreator = new GraphCreator(arasExport); graphCreator.CreateGraph(options.RelsAsClasses); graphCreator.ExportGraph(options.FilePath ?? @"C:\temp\temp.dot"); }
public void SetUp() { var routeValue = new RouteValue(FROM, TO, VALUE); routes = new List <RouteValue> { routeValue }; graphCreator = new GraphCreator(); }
public static void SolveCurrentDocument() { var doc = Instances.ActiveCanvas?.Document; if (doc is null) { return; } _graph = new GraphCreator(doc); }
private static (List <string> route, long totalTime) FindShortestRoute(string start, string destination) { var(graph, stationMap) = GraphCreator.CreateGraphFromFile(); var startIndex = stationMap[start]; var endIndex = stationMap[destination]; var(distances, parents) = Dijkstras.Calculate(graph, startIndex, stationMap.Count); var path = Dijkstras.GetPath(endIndex, parents); var route = path?.Select(i => stationMap.Single(d => d.Value == i).Key).ToList(); return(route, distances[stationMap[destination]]);
internal void CalculateScores() { FirstFuncNodesAndEdges = GraphCreator.CompileCode(FirstFunctionCode); SecondFuncNodesAndEdges = GraphCreator.CompileCode(SecondFunctionCode); PairingFirstToSecond = GraphSimilarityCalc.GetDistance(FirstFuncNodesAndEdges.Nodes, SecondFuncNodesAndEdges.Nodes); PairingSecondToFirst = GraphSimilarityCalc.GetDistance(SecondFuncNodesAndEdges.Nodes, FirstFuncNodesAndEdges.Nodes); ScoreFirstContainedInSecond = Math.Round(PairingFirstToSecond.TotalScore / PairingFirstToSecond.SourceSelfPairings.TotalScore, 2); ScoreSecondContainedInFirst = Math.Round(PairingSecondToFirst.TotalScore / PairingSecondToFirst.SourceSelfPairings.TotalScore, 2); ScoreTwoWay = (PairingFirstToSecond.TotalScore + PairingSecondToFirst.TotalScore) / (PairingSecondToFirst.SourceSelfPairings.TotalScore + PairingFirstToSecond.SourceSelfPairings.TotalScore); ScoreTwoWay = Math.Round(ScoreTwoWay.Value, 2); }
public void PDFCreatorTest() { Matrix matrix = new Matrix(new int[, ] { { 0, 1, 2, 3 }, { 1, 0, 1, 2 }, { 2, 1, 0, 4 }, { 3, 2, 4, 0 } }); (this.graph, this.edgeCost) = GraphCreator.Create(matrix); TryFunc <int, IEnumerable <Edge <int> > > tryGetPath = graph.ShortestPathsDijkstra(this.edgeCost, 0); PdfGenerator.Generate(DotGenerator <int, Edge <int> > .GetDotCode(this.graph, tryGetPath), "test"); Assert.IsTrue(File.Exists("test.pdf")); File.Delete("test.pdf"); }
/// <summary> /// Method to display all the rejections present in the input files. /// If the graph argument was passed in the input arguments, a DGML graph representing /// all the rejection issues is saved in a file called All.dgml. /// </summary> /// <remarks> /// Based on how the levels are assigned, the root causes for the errors in the /// application can easily be accessed by looking at the rejection issues present at /// the highest level. /// </remarks> private void ListAllRejections() { this.Options.Writer.WriteLine(Strings.AllRejectionsMessage); for (int level = this.MaxLevels; level > 0; level--) { this.ListErrorsinLevel(level); } bool saveGraph = this.Options.GraphPath != null && this.Options.GraphPath.Length > 0; if (saveGraph) { GraphCreator creator = new GraphCreator(this.RejectionGraph); string fileName = "AllErrors.dgml"; this.SaveGraph(fileName, creator); } }
public GoalGraph(GraphSearchData gsData, State state, Level level) { foreach (var box in state.GetBoxes(level)) { AddNode(new GoalNode(new EntityNodeInfo(box, EntityType.BOX))); } foreach (var agent in state.GetAgents(level)) { AddNode(new GoalNode(new EntityNodeInfo(agent, EntityType.AGENT))); } foreach (var goal in level.Goals) { AddNode(new GoalNode(new EntityNodeInfo(goal.Ent, goal.EntType))); } GraphCreator.CreateGraphIgnoreEntityType(gsData, this, level, EntityType.MOVEABLE); }
[STAThread] // needed to show open folder dialogue static void Main(string[] args) { string[] files = args; ThreadPoolManager poolManager = new ThreadPoolManager(); poolManager.ConFigurePoolByNumberOfCPUs(); if (files.Length == 0) { files = getFiles(); } foreach (string s in files) { IThreadPoolWorker pg = new GraphCreator(s); poolManager.AddWorker(pg); } poolManager.Wait(); System.Environment.Exit(0); }
private void btnDrawRandomGraphFromProbability_Click(object sender, RoutedEventArgs e) { draw.ClearAll(); if (intUpDownRandomPoints2.Value != null && doubleUpDownProbability.Value != null) { draw.CurrentGraph = GraphCreator.CreateRandomGraphProbability((int)intUpDownRandomPoints2.Value, (double)doubleUpDownProbability.Value); } else { MessageBox.Show("Niepoprawna ilość wierchołków!", "Błąd!"); return; } draw.NodeRadius = (int)sliderNodeRadius.Value; draw.Radius = (int)sliderRadius.Value; draw.DrawMainCircle(); draw.Draw(); }
public void T() { var dir = @"D:\workde\BOA.BusinessModules\Dev\BOA.Card.CreditCardOperation\UI\BOA.UI.Card.CreditCardOperation\bin\Debug\"; var resolver = new DefaultAssemblyResolver(); resolver.AddSearchDirectory(dir); var dllPath = dir + "BOA.UI.Card.CreditCardOperation.dll"; var api = new GraphCreator(); var assemblyDefinition = AssemblyDefinition.ReadAssembly(dllPath, new ReaderParameters { AssemblyResolver = resolver }); var typeDefinition = assemblyDefinition.FindType(type => type.FullName == "BOA.UI.Card.CreditCardOperation.LimitChangeForm.Model"); api.CreateGraph(typeDefinition); }
private void btnRandomizeGraph_Click(object sender, RoutedEventArgs e) { if (intUpDownNumberOfChanges.Value != null && draw.CurrentGraph.Nodes.Count > 0) { draw.ClearAll(); if (!GraphCreator.RandomizeGraph(draw.CurrentGraph, (int)intUpDownNumberOfChanges.Value)) { MessageBox.Show("Nie można randomizować grafu!"); } draw.NodeRadius = (int)sliderNodeRadius.Value; draw.Radius = (int)sliderRadius.Value; draw.DrawMainCircle(); draw.Draw(); } else { MessageBox.Show("Niepoprawna ilość zmian, bądź graf!"); } }
static void Main(string[] args) { GraphCreator [] graphs = new GraphCreator[1]; Menu(); Console.Write("\nChose one option: "); int option = Int32.Parse(Console.ReadLine()); switch (option) { case 1: graphs[0] = new UndirectedGraph(); break; case 2: graphs[0] = new DirectedGraph(); break; } Console.WriteLine(graphs[0].GetType().Name + " was successfully generated!"); }
internal BoxConflictGraph(GraphSearchData gsData, State state, Level level, HashSet <Entity> removedEntities) { CreatedFromThisState = state; foreach (var box in state.GetBoxes(level)) { if (removedEntities.Contains(box)) { continue; } AddNode(new BoxConflictNode(new EntityNodeInfo(box, EntityType.BOX))); } foreach (var agent in state.GetAgents(level)) { if (removedEntities.Contains(agent)) { continue; } AddNode(new BoxConflictNode(new EntityNodeInfo(agent, EntityType.AGENT))); } GraphCreator.CreateGraphIgnoreEntityType(gsData, this, level, EntityType.GOAL); }
public HomeController() { networker = new GraphCreator(); }
/// <summary> /// Method to the get the information about the rejection information that caused a /// particular import failure, rather than for the entire system. /// If graph was specified in the input arguments then a DGML graph tracing the rejection /// chain assocaited with the current path alone is saved to a file called [partName].dgml. /// </summary> /// <param name = "partName"> The name of the part which we want to analyze.</param> /// <remarks> /// Once again, the root causes can easily be accessed by looking at the rejection /// issues at the highest levels of the output. /// </remarks> private void ListReject(string partName) { string individualRejection = string.Format( CultureInfo.CurrentCulture, Strings.IndividualRejectionMessage, partName); this.Options.Writer.WriteLine(individualRejection); // Deal with the case that there are no rejection issues with the given part if (!this.RejectionGraph.ContainsKey(partName)) { string noRejection = string.Format( CultureInfo.CurrentCulture, Strings.NoRejectionMessage, partName); this.Options.ErrorWriter.WriteLine(noRejection); return; } // Store just the nodes that are involved in the current rejection chain to use when generating the graph Dictionary <string, PartNode> relevantNodes = new Dictionary <string, PartNode>(); bool saveGraph = this.Options.GraphPath != null && this.Options.GraphPath.Length > 0; // Perform Breadth First Search (BFS) with the node associated with partName as the root. // When performing BFS, only the child nodes are considered since we want to the root to be // the end point of the rejection chain(s). // BFS was chosen over DFS because of the fact that we process level by level when performing // the travesal and thus easier to communicate the causes and pathway to the end user Queue <PartNode> currentLevelNodes = new Queue <PartNode>(); currentLevelNodes.Enqueue(this.RejectionGraph[partName]); while (currentLevelNodes.Count() > 0) { int currentLevel = currentLevelNodes.Peek().Level; string errorLevel = string.Format( CultureInfo.CurrentCulture, Strings.ErrorsLevelMessage, currentLevel); this.Options.Writer.WriteLine(errorLevel); // Iterate through all the nodes in the current level int numNodes = currentLevelNodes.Count(); List <string> errorMessages = new List <string>(numNodes); for (int index = 0; index < numNodes; index++) { // Process the current node by displaying its import issue and adding it to the graph PartNode current = currentLevelNodes.Dequeue(); if (saveGraph) { relevantNodes.Add(current.Name, current); } errorMessages.Add(this.GetNodeDetail(current)); // Add the "children" of the current node to the queue for future processing if (current.ImportRejects.Count() > 0) { foreach (var childEdge in current.ImportRejects) { currentLevelNodes.Enqueue(childEdge.Target); } } } this.WriteLines(errorMessages); if (!this.Options.Verbose) { this.Options.Writer.WriteLine(); } } // Save the output graph if the user request it if (saveGraph) { GraphCreator nodeGraph = new GraphCreator(relevantNodes); // Replacing '.' with '_' in the fileName to ensure that the '.' is associated with the file extension string fileName = partName.Replace(".", "_") + ".dgml"; this.SaveGraph(fileName, nodeGraph); } }
public void ReLayoutGraph() { graph = GraphCreator.Create(Directory); NotifyPropertyChanged("Graph"); }
public MainWindow() { InitializeComponent(); InitializeColorPickers(); draw = new DrawGraph(mainCanvas, GraphCreator.CreateFullGraph()); }
static int Main(string[] args) { if (args.Length == 1 && (args[0] == "-h" || args[0] == "--help" || args[0] == "/?")) { DisplayHelp(); return(0); } else { try { ParseArguments(args); } catch (Exception e) { Console.WriteLine(e.Message); DisplayHelp(); return(1); } } isVariantEdge = args[1] == "edge"; backupDirectory = FindBackupDirectory(); // input parameters: codePath = args[2]; string solPath = args[3]; string testProjPath = args[4]; string testDllPath = args[5]; string target = "--target dotnet"; string targetargs = $"--targetargs \"test {testProjPath} --no-build\""; string coveragePath = backupDirectory + @"\coverage.json"; string output = $"--output {coveragePath}"; string coverletCommand = String.Join(" ", new string[] { "coverlet", testDllPath, target, targetargs, output }); string buildCommand = String.Join(" ", new string[] { "dotnet", "build", solPath }); StaticCodeAnalysis codeAnalysis = new StaticCodeAnalysis(codePath); GraphCreator graphCreator = new GraphCreator(codeAnalysis); DirectedGraph graph; string coverageTargets; bool hasCoverageTargets; if (isVariantEdge) { graph = graphCreator.CreateYoYoGraph(); coverageTargets = "invocations"; hasCoverageTargets = graph.GetNodesOfType(Type.INVOCATION).Any(); } else // is variant 'type' { graph = graphCreator.CreateInheritanceGraph(); coverageTargets = "methods"; hasCoverageTargets = graph.GetNodesOfType(Type.METHOD).Any(); } // if the source code doesn't contain coverage targets then output 100% coverage and return if (!hasCoverageTargets) { Console.WriteLine(Environment.NewLine + $"The given source code does not contain any {coverageTargets}" + Environment.NewLine); OutputResult(1); return(0); } BackupFile(codePath); try { // manipulate the source code file to be able to gather information needed if (isVariantEdge) { graphCreator.PreCorrectLineNumbers(graph as YoYoGraph); // YoYo graphs contain line numbers which have to be corrected before code gets inserted } SyntaxRewriter rewriter = new SyntaxRewriter(codeAnalysis, graph); SyntaxNode newRoot = rewriter.Visit(codeAnalysis.GetRoot()); File.WriteAllText(codePath, newRoot.GetText().ToString(), Encoding.Default); Console.WriteLine(Environment.NewLine + $"Instrumented file '{codePath}'"); // re-build the solution RunCMDCommand(buildCommand, "Re-building solution ...", "build succeeded", "build failed"); // start coverlet RunCMDCommand(coverletCommand, "Starting coverlet ...", "coverlet calculation succeeded", "coverlet calculation failed"); // read the generated json file & calculate the coverage Console.WriteLine(Environment.NewLine + "Calculating coverage result ..."); Coverage coverage = new Coverage(coveragePath, codePath, graph); double result = coverage.Calculate(); OutputResultAndGraph(result, graph); } catch (Exception e) { Console.WriteLine(e.Message); return(1); } finally { RestoreFile(codePath); } return(0); }