コード例 #1
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)");
                    }
                }
            }
        }
コード例 #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)");
                    }
                }
            }
        }