public DependencyMatrix GetDependencyMatrix(string projectStartsWith, string packageStartsWith) { var dependencyMatrix = new DependencyMatrix(); var packages = _context.Packages.AsQueryable(); if (!string.IsNullOrEmpty(packageStartsWith)) { packages = packages.Where(s => s.Name.StartsWith(packageStartsWith)); } foreach (var package in packages) { var projects = package.Projects.AsQueryable(); if (!string.IsNullOrEmpty(projectStartsWith)) { // Here we need StringComparison.InvariantCultureIgnoreCase because this goes against in-memory collection and // not SQL which is case-sensitive by default. projects = projects.Where(s => s.Name.StartsWith(projectStartsWith, StringComparison.InvariantCultureIgnoreCase)); } foreach (var project in projects) // This requires MARS MultipleActiveResultSets=True in connection string { dependencyMatrix.AddDependency($"{package.Name} {package.Version}", project.Name); } } dependencyMatrix.Sort(); return(dependencyMatrix); }
public ProjectNetwork(IEnumerable <Activity> activities) { _map = new Dictionary <string, Activity>(); _matrix = new DependencyMatrix(); AddRange(activities); }
public void MakeHardDependencyMatrixFromSuccessorMatrix() { // Arrange ImportedEventLog elog = CSVImport.MakeDataFrame(hardCsv); elog.SetActivity("act"); elog.SetCaseId("id"); WorkflowLog wlog = new WorkflowLog(elog); SuccessorMatrix successorMatrix = new SuccessorMatrix(wlog); //Act DependencyMatrix dependencyMatrix = new DependencyMatrix(successorMatrix); //Assert Assert.AreEqual(successorMatrix.Activities.Count, dependencyMatrix.L1LDependencyMatrix.Length); //Each dependency is in range <-1, 1> foreach (var dependency in dependencyMatrix.DirectDependencyMatrix) { Assert.IsTrue(dependency >= -1 && dependency <= 1); } Assert.IsTrue(dependencyMatrix.L1LDependencyMatrix[0] > 0.9 && dependencyMatrix.L1LDependencyMatrix[0] < 1); //Check L2L dependency on BCB and CBC Assert.IsTrue(dependencyMatrix.L2LDependencyMatrix[1, 2] > 0.9 && dependencyMatrix.L2LDependencyMatrix[1, 2] < 1); Assert.IsTrue(dependencyMatrix.L2LDependencyMatrix[2, 1] > 0.9 && dependencyMatrix.L2LDependencyMatrix[2, 1] < 1); }
public void MakeDependencyMatrixFromSuccessorMatrix() { // Arrange ImportedEventLog elog = CSVImport.MakeDataFrame(heuristicCsv); elog.SetActivity("act"); elog.SetCaseId("id"); WorkflowLog wlog = new WorkflowLog(elog); SuccessorMatrix successorMatrix = new SuccessorMatrix(wlog); // Act DependencyMatrix dependencyMatrix = new DependencyMatrix(successorMatrix); // Assert Assert.AreEqual(successorMatrix.Activities.Count, dependencyMatrix.L1LDependencyMatrix.Length); for (int i = 0; i < 4; i++) { Assert.IsTrue(dependencyMatrix.L1LDependencyMatrix[i] == 0); } //1 self loop with dependency 0.8 Assert.IsTrue(dependencyMatrix.L1LDependencyMatrix[4] == 0.8); foreach (var dependency in dependencyMatrix.L2LDependencyMatrix) { Assert.IsTrue(dependency == 0); } //Each dependency is in range <-1, 1> foreach (var dependency in dependencyMatrix.DirectDependencyMatrix) { Assert.IsTrue(dependency >= -1 && dependency <= 1); } }
public void DependencyMatrix_Basic() { // a b c // d x // e x // f x var dm = new DependencyMatrix(); dm.AddDependency("d", "a"); dm.AddDependency("e", "c"); dm.AddDependency("f", "b"); dm.Sort(); CollectionAssert.AreEqual(dm.Rows.Select(s => s.Value), new string[] { "d", "e", "f" }); CollectionAssert.AreEqual(dm.Columns.Select(s => s.Value), new string[] { "a", "b", "c" }); Assert.IsTrue(dm.Matrix[dm.Rows[0].Id, dm.Columns[0].Id]); Assert.IsFalse(dm.Matrix[dm.Rows[0].Id, dm.Columns[1].Id]); Assert.IsFalse(dm.Matrix[dm.Rows[0].Id, dm.Columns[2].Id]); Assert.IsFalse(dm.Matrix[dm.Rows[1].Id, dm.Columns[0].Id]); Assert.IsFalse(dm.Matrix[dm.Rows[1].Id, dm.Columns[1].Id]); Assert.IsTrue(dm.Matrix[dm.Rows[1].Id, dm.Columns[2].Id]); Assert.IsFalse(dm.Matrix[dm.Rows[2].Id, dm.Columns[0].Id]); Assert.IsTrue(dm.Matrix[dm.Rows[2].Id, dm.Columns[1].Id]); Assert.IsFalse(dm.Matrix[dm.Rows[2].Id, dm.Columns[2].Id]); }
void AddChildrenToMatrix(DependencyMatrix matrix, IEnumerable<NodeBase> nodes) { foreach (var node in nodes) { matrix.AddColumn(node); matrix.AddRow(node); if (node.Children != null) AddChildrenToMatrix(matrix, node.Children); } }
public DependentApplicationsModelImpact GetDependentApplicationsImpact(DependencyMatrix dm) { return(new DependentApplicationsModelImpact() { SID = dm.SID, AppID = dm.AppID, DependentAppID = dm.DependentAppID, Stream = dm.Stream, ImpactStatment = dm.ImpactStatment, depApps = dm.DependentApp }); }
public static void FindAllLeafChildAux(int parentNodeId, DependencyMatrix dependencyMatrix, List <int> listOfLeafChild) { List <int> childListOfTheParent = dependencyMatrix.GetToChildDependencyList(parentNodeId); childListOfTheParent.ForEach(child => { if (dependencyMatrix.GetToChildDependencyList(child).Count() == 0) { listOfLeafChild.Add(child); } else { FindAllLeafChildAux(child, dependencyMatrix, listOfLeafChild); } }); }
public void Update(IEnumerable<NodeBase> nodes) { Extensions.FillTree(topTree, nodes); Extensions.FillTree(leftTree, nodes); var leftCol = leftTree.Items.SourceCollection as INotifyCollectionChanged; leftCol.CollectionChanged += BuildLeftINodeList; var topCol = topTree.Items.SourceCollection as INotifyCollectionChanged; topCol.CollectionChanged += BuildTopINodeList; var matrix = new DependencyMatrix(); if (nodes != null) AddChildrenToMatrix(matrix, nodes); this.matrix.Matrix = matrix; BuildLeftINodeList(null, null); BuildTopINodeList(null, null); }
private void FillMatrix() { var matrix = new DependencyMatrix(); foreach (var ns in metricsReader.MainModule.Namespaces) { matrix.HeaderRows.Add(new MatrixCell <INode>(ns)); foreach (var type in ns.Types) { matrix.HeaderRows.Add(new MatrixCell <INode>(type)); } matrix.HeaderColumns.Add(new MatrixCell <INode>(ns)); foreach (var type in ns.Types) { matrix.HeaderColumns.Add(new MatrixCell <INode>(type)); } } matrixControl.Matrix = matrix; matrixControl.DrawMatrix(); matrixControl.DrawTree(metricsReader.MainModule); }
private void FillMatrix() { var matrix = new DependencyMatrix(); foreach (var ns in metricsReader.Assembly.Namespaces) { matrix.AddRow(ns); foreach (var type in ns.Types) { matrix.AddRow(type); foreach (var field in type.Fields) { matrix.AddRow(field); } foreach (var method in type.Methods) { matrix.AddRow(method); } } matrix.AddColumn(ns); foreach (var type in ns.Types) { matrix.AddColumn(type); foreach (var field in type.Fields) { matrix.AddColumn(field); } foreach (var method in type.Methods) { matrix.AddColumn(method); } } } matrixControl.Matrix = matrix; matrixControl.DrawTree(metricsReader.Assembly); }
private void FillMatrix() { var matrix = new DependencyMatrix(); foreach (var ns in metricsReader.Assembly.Namespaces) { matrix.AddRow(ns); foreach (var type in ns.Types) { matrix.AddRow(type); foreach (var field in type.Fields) matrix.AddRow(field); foreach (var method in type.Methods) matrix.AddRow(method); } matrix.AddColumn(ns); foreach (var type in ns.Types) { matrix.AddColumn(type); foreach (var field in type.Fields) matrix.AddColumn(field); foreach (var method in type.Methods) matrix.AddColumn(method); } } matrixControl.Matrix = matrix; matrixControl.DrawTree(metricsReader.Assembly); }
private void FillMatrix() { var matrix = new DependencyMatrix(); foreach (var ns in metricsReader.MainModule.Namespaces) { matrix.HeaderRows.Add(new MatrixCell<INode>(ns)); foreach (var type in ns.Types) { matrix.HeaderRows.Add(new MatrixCell<INode>(type)); } matrix.HeaderColumns.Add(new MatrixCell<INode>(ns)); foreach (var type in ns.Types) { matrix.HeaderColumns.Add(new MatrixCell<INode>(type)); } } matrixControl.Matrix = matrix; matrixControl.DrawMatrix(); matrixControl.DrawTree(metricsReader.MainModule); }
public void DependencyMatrix_Empty() { var dm = new DependencyMatrix(); CollectionAssert.IsEmpty(dm.Matrix); }