Beispiel #1
0
        public void Compute <TVertex, TEdge>([PexAssumeNotNull] IVertexListGraph <TVertex, TEdge> g)
            where TEdge : IEdge <TVertex>
        {
            // is this a dag ?
            bool isDag = AlgorithmExtensions.IsDirectedAcyclicGraph(g);

            var relaxer  = DistanceRelaxers.ShortestDistance;
            var vertices = new List <TVertex>(g.Vertices);

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