public void OutEdges_Throws() { var graph1 = new AdjacencyGraph <EquatableTestVertex, Edge <EquatableTestVertex> >(); var filteredGraph1 = new FilteredImplicitGraph < EquatableTestVertex, Edge <EquatableTestVertex>, AdjacencyGraph <EquatableTestVertex, Edge <EquatableTestVertex> > >( graph1, _ => true, _ => true); OutEdges_NullThrows_Test(filteredGraph1); OutEdges_Throws_Test(filteredGraph1); var graph2 = new AdjacencyGraph <int, Edge <int> >(); var filteredGraph2 = new FilteredImplicitGraph <int, Edge <int>, AdjacencyGraph <int, Edge <int> > >( graph2, vertex => vertex < 4, _ => true); graph2.AddVertexRange(new[] { 1, 2, 3, 4, 5 }); // ReSharper disable ReturnValueOfPureMethodIsNotUsed Assert.Throws <VertexNotFoundException>(() => filteredGraph2.OutEdges(4)); Assert.Throws <VertexNotFoundException>(() => filteredGraph2.OutEdges(5)); // ReSharper restore ReturnValueOfPureMethodIsNotUsed }
public void ContainsVertex_Throws() { var filteredGraph = new FilteredImplicitGraph <TestVertex, Edge <TestVertex>, AdjacencyGraph <TestVertex, Edge <TestVertex> > >( new AdjacencyGraph <TestVertex, Edge <TestVertex> >(), _ => true, _ => true); ContainsVertex_Throws_Test(filteredGraph); }
public void OutEdge_Throws() { var graph1 = new AdjacencyGraph <int, Edge <int> >(); OutEdge_Throws_Test( graph1, (vertexPredicate, edgePredicate) => new FilteredImplicitGraph <int, Edge <int>, AdjacencyGraph <int, Edge <int> > >( graph1, vertexPredicate, edgePredicate)); var graph2 = new AdjacencyGraph <TestVertex, Edge <TestVertex> >(); var filteredGraph2 = new FilteredImplicitGraph <TestVertex, Edge <TestVertex>, AdjacencyGraph <TestVertex, Edge <TestVertex> > >( graph2, _ => true, _ => true); OutEdge_NullThrows_Test(filteredGraph2); }
public void Construction() { VertexPredicate <int> vertexPredicate = _ => true; EdgePredicate <int, Edge <int> > edgePredicate = _ => true; var graph = new AdjacencyGraph <int, Edge <int> >(); var filteredGraph = new FilteredImplicitGraph <int, Edge <int>, AdjacencyGraph <int, Edge <int> > >( graph, vertexPredicate, edgePredicate); AssertGraphProperties(filteredGraph, graph); graph = new AdjacencyGraph <int, Edge <int> >(false); filteredGraph = new FilteredImplicitGraph <int, Edge <int>, AdjacencyGraph <int, Edge <int> > >( graph, vertexPredicate, edgePredicate); AssertGraphProperties(filteredGraph, graph, false); #region Local function void AssertGraphProperties <TVertex, TEdge, TGraph>( FilteredImplicitGraph <TVertex, TEdge, TGraph> g, TGraph expectedGraph, bool parallelEdges = true) where TEdge : IEdge <TVertex> where TGraph : IImplicitGraph <TVertex, TEdge> { Assert.AreSame(expectedGraph, g.BaseGraph); Assert.IsTrue(g.IsDirected); Assert.AreEqual(parallelEdges, g.AllowParallelEdges); Assert.AreSame(vertexPredicate, g.VertexPredicate); Assert.AreSame(edgePredicate, g.EdgePredicate); } #endregion }