Example #1
0
        /// <summary>
        /// Main method (Entry point)
        /// </summary>
        /// <param name="args"></param>
        static void Main(string[] args)
        {
            Console.Write("\n\t\t\t  Demonstrating Parser");
            Console.Write("\n\t =========================================================\n");
            ReqOneTwo();
            ReqThree();
            Console.WriteLine("Following files are being evaluated:\t");
            Dictionary <string, List <Elem> > dicTables = new Dictionary <string, List <Elem> >();
            ResultSet oResult = new ResultSet();

            Console.Write("\n\n\t\t  Displaying Type Tables ");
            Console.Write("\n\t\t ==========================\n");
            TAnal objTAnalysis = new TAnal();

            dicTables = objTAnalysis.DoTypeAnalysis(GetFilesFromArg(args[0]));
            oResult.WriteTypeAnalysisResult(dicTables);
            Display.ShowTypeTables(dicTables);
            Console.Write("\n\t\t  Displaying Dependencies ");
            Console.Write("\n\t\t =========================\n");
            Dependencies objDependencies = new Dependencies();
            Dictionary <string, HashSet <string> > dicDependencies = new Dictionary <string, HashSet <string> >();

            dicDependencies = objDependencies.DoAnalysis(dicTables);
            oResult.WriteDepAnalysisResult(dicDependencies);
            Display.ShowDependencies(dicDependencies);
            Console.Write("\n\t\t  Displaying Strong Components ");
            Console.Write("\n\t\t ===============================\n");
            Scc objScc = new Scc();
            HashSet <List <string> > lstScc = objScc.GetSCC(dicDependencies);

            oResult.WriteSCCResult(lstScc);
            Display.ShowSCC(lstScc);
            Console.Write("\n\n");
            //Console.ReadLine();
        }
Example #2
0
        static void Main(string[] args)
        {
            Dictionary <int, IList <int> > g = new Dictionary <int, IList <int> >
            {
                { 1, new [] { 4, 2, 3, } },
                { 2, new [] { 3 } },
                { 3, new [] { 1 } },
                { 4, new [] { 5 } },
                { 5, new [] { 4, 6 } },
                { 6, new [] { 4, } },
            };

            Scc <int> scc = new Scc <int>();

            scc.Find(g.Keys, v => g[v], (sccKey, sccVerticies, vs) => Console.WriteLine($"{sccKey}: {string.Join(", ", sccVerticies)}"));

            Dfs <int>         dfs        = new Dfs <int>();
            IEnumerable <int> traversed1 = dfs.Traverse2(g.Keys, v => g[v]);

            Console.WriteLine($"DFS 1: {string.Join(", ", traversed1)}");

            IEnumerable <int> traversed2 = dfs.Traverse2(g.Keys, v => g[v]);

            Console.WriteLine($"DFS 2: {string.Join(", ", traversed2)}");

            Console.Read();
        }
 public void ComputeScc()
 {
     var scc = new Scc<int>();
     foreach (var i in scc.Compute(Graph).Take(5))
     {
         Console.WriteLine(i);
     }
 }
        /// <summary>
        /// Refreshes this instance.
        /// </summary>
        public void Refresh()
        {
            ISccProjectInfo projectInfo;

            if (_project.IsSolution)
            {
                SvnItem rootItem = SolutionSettings.ProjectRootSvnItem;

                SetValues(
                    Scc.IsSolutionManaged,
                    "Solution: " + Path.GetFileNameWithoutExtension(SolutionSettings.SolutionFilename),
                    SafeRepositoryRoot(rootItem),
                    SafeRepositoryPath(rootItem),
                    GetStatus(rootItem, null, SolutionSettings.SolutionFilename),
                    (rootItem != null)
                        ? EmptyToDot(SvnItem.MakeRelative(rootItem.FullPath, SvnTools.GetNormalizedDirectoryName(SolutionSettings.SolutionFilename)))
                        : "",
                    (rootItem != null)
                        ? rootItem.FullPath
                        : ""
                    );
            }
            else if (null != (projectInfo = ProjectMap.GetProjectInfo(_project)) &&
                     null != (projectInfo.ProjectDirectory) &&
                     null != (projectInfo.SccBaseDirectory))
            {
                SvnItem dirItem = Cache[projectInfo.SccBaseDirectory];

                SetValues(
                    Scc.IsProjectManaged(_project),
                    projectInfo.UniqueProjectName,
                    SafeRepositoryRoot(dirItem),
                    SafeRepositoryPath(dirItem),
                    GetStatus(dirItem, projectInfo, projectInfo.ProjectFile),
                    EmptyToDot(SvnItem.MakeRelative(projectInfo.SccBaseDirectory, projectInfo.ProjectDirectory)),
                    projectInfo.SccBaseDirectory
                    );
            }
            else
            {
                // Should have been filtered before; probably a buggy project that changed while the dialog was open
                SetValues(
                    false,
                    "-?-",
                    "-?-",
                    "-?-",
                    "-?-",
                    "-?-",
                    "-?-"
                    );
            }
        }
        private void InitializeGrid()
        {
            ThreadHelper.ThrowIfNotOnUIThread();

            bindingGrid.Rows.Clear();

            if (Context == null)
            {
                return;
            }

            if (string.IsNullOrEmpty(SolutionSettings.SolutionFilename))
            {
                return;
            }

            // TODO: Optimize to one time init and then just refresh
            if (SvnItem.IsValidPath(SolutionSettings.SolutionFilename))
            {
                bindingGrid.Rows.Add(new ChangeSourceControlRow(Context, SccProject.Solution));
            }
            foreach (SccProject project in ProjectMapper.GetAllSccProjects())
            {
                if (project.IsSolution)
                {
                    continue;
                }

                ISccProjectInfo projectInfo = ProjectMapper.GetProjectInfo(project);

                if (projectInfo == null || string.IsNullOrEmpty(projectInfo.ProjectDirectory))
                {
                    continue;
                }

                if (!projectInfo.IsSccBindable && !Scc.IsProjectManaged(project))
                {
                    continue;
                }

                bindingGrid.Rows.Add(new ChangeSourceControlRow(Context, project));
            }
            // /TODO

            RefreshGrid();
        }
        private string GetStatus(SvnItem dirItem, ISccProjectInfo projectInfo, string file)
        {
            if (dirItem == null || !dirItem.Exists || !dirItem.IsVersioned)
            {
                return("<not found>");
            }

            if (projectInfo == null)
            {
                if (Scc.IsSolutionManaged)
                {
                    return("Connected"); // Solution itself + Connected
                }
                else
                {
                    return("Not Connected");
                }
            }

            if (dirItem.IsBelowPath(SolutionSettings.ProjectRootSvnItem) &&
                dirItem.WorkingCopy == SolutionSettings.ProjectRootSvnItem.WorkingCopy)
            {
                // In master working copy
                if (Scc.IsSolutionManaged && Scc.IsProjectManaged(_project))
                {
                    return("Connected");
                }
                else
                {
                    return("Valid"); // In master working copy
                }
            }
            else if (Scc.IsSolutionManaged && Scc.IsProjectManaged(_project))
            {
                return("Connected"); // Required information in solution
            }
            else
            {
                return("Detached"); // Separate working copy
            }
        }
Example #7
0
        public void testSCCS()
        {
            OrientedGraph s  = new OrientedGraph();
            OrientedGraph og = oriented();

            for (int i = 1; i < 9; i++)
            {
                s.AddVertex();
            }
            s.AddEdge(1, 2);
            s.AddEdge(2, 3);
            s.AddEdge(3, 1);
            s.AddEdge(2, 4);
            s.AddEdge(2, 5);
            s.AddEdge(5, 6);
            s.AddEdge(6, 7);
            s.AddEdge(7, 5);
            int [] correct = new int[] { 4, 3, 3, 3, 2, 1, 1, 1 };
            int [] res     = Scc.FindSCCS(s);
            Assert.AreEqual(correct, res);
            Assert.AreEqual(new int[] { 7, 6, 5, 4, 3, 2, 1 }, Scc.FindSCCS(og));
        }
        public void ComputeSmall()
        {
            var g = new Graph<int>();

            var v1 = g.GetOrCreateVertex(1);
            var v2 = g.GetOrCreateVertex(2);
            var v3 = g.GetOrCreateVertex(3);
            var v4 = g.GetOrCreateVertex(4);
            var v5 = g.GetOrCreateVertex(5);

            v1.Add(v2);
            v2.Add(v3);
            v3.Add(v1);
            v4.Add(v5);
            v5.Add(v4);

            var scc = new Scc<int>();
            var a = scc.Compute(g).ToArray();
            Assert.AreEqual(2, a.Length);
            Assert.AreEqual(3, a[0]);
            Assert.AreEqual(2, a[1]);
        }
Example #9
0
 public TwoSAT(int n)
 {
     this.n   = n;
     this.scc = new Scc(2 * n);
 }
Example #10
0
 public AnonymousInstruction(Scc parent)
 {
     this.parent = parent;
 }