Esempio n. 1
0
        public void ComputeCriticalPath(IVertexListGraph <string, Edge <string> > g)
        {
            // is this a dag ?
            bool isDag = AlgoUtility.IsDirectedAcyclicGraph(g);

            var relaxer  = new CriticalDistanceRelaxer();
            var vertices = new List <string>(g.Vertices);

            foreach (string root in vertices)
            {
                if (isDag)
                {
                    Search(g, root, relaxer);
                }
                else
                {
                    try
                    {
                        Search(g, root, relaxer);
                        Assert.Fail("should have found the acyclic graph");
                    }
                    catch (NonAcyclicGraphException)
                    {
                        Console.WriteLine("NonAcyclicGraphException caught (as expected)");
                    }
                }
            }
        }
Esempio n. 2
0
        public void Compute(IVertexListGraph <string, Edge <string> > g)
        {
            // is this a dag ?
            bool isDag = AlgoUtility.IsDirectedAcyclicGraph(g);

            IDistanceRelaxer relaxer  = new ShortestDistanceRelaxer();
            List <string>    vertices = new List <string>(g.Vertices);

            foreach (string root in vertices)
            {
                if (isDag)
                {
                    Search(g, root, relaxer);
                }
                else
                {
                    try
                    {
                        Search(g, root, relaxer);
                    }
                    catch (NonAcyclicGraphException)
                    {
                        Console.WriteLine("NonAcyclicGraphException caught (as expected)");
                    }
                }
            }
        }