コード例 #1
0
        protected static void ComputeWithoutRoot_Throws_Test <TGraph>(
            [NotNull] IMutableVertexSet <int> graph,
            [NotNull, InstantHandle] Func <RootedSearchAlgorithmBase <int, TGraph> > createAlgorithm)
            where TGraph : IImplicitVertexSet <int>
        {
            RootedSearchAlgorithmBase <int, TGraph> algorithm = createAlgorithm();

            Assert.Throws <InvalidOperationException>(algorithm.Compute);

            // Source (and target) vertex set but not to a vertex in the graph
            const int vertex1 = 1;

            algorithm = createAlgorithm();
            algorithm.SetRootVertex(vertex1);
            algorithm.SetTargetVertex(vertex1);
            Assert.Throws <VertexNotFoundException>(algorithm.Compute);

            const int vertex2 = 2;

            graph.AddVertex(vertex1);
            algorithm = createAlgorithm();
            algorithm.SetRootVertex(vertex1);
            algorithm.SetTargetVertex(vertex2);
            Assert.Throws <VertexNotFoundException>(algorithm.Compute);
        }