public void AdjacentEdges_Throws() { var graph1 = new UndirectedGraph <EquatableTestVertex, Edge <EquatableTestVertex> >(); var filteredGraph1 = new FilteredUndirectedGraph < EquatableTestVertex, Edge <EquatableTestVertex>, UndirectedGraph <EquatableTestVertex, Edge <EquatableTestVertex> > >( graph1, _ => true, _ => true); AdjacentEdges_NullThrows_Test(filteredGraph1); AdjacentEdges_Throws_Test(filteredGraph1); var graph2 = new UndirectedGraph <int, Edge <int> >(); var filteredGraph2 = new FilteredUndirectedGraph <int, Edge <int>, UndirectedGraph <int, Edge <int> > >( graph2, vertex => vertex < 4, _ => true); graph2.AddVertexRange(new[] { 1, 2, 3, 4, 5 }); // ReSharper disable ReturnValueOfPureMethodIsNotUsed Assert.Throws <VertexNotFoundException>(() => filteredGraph2.AdjacentEdges(4)); Assert.Throws <VertexNotFoundException>(() => filteredGraph2.AdjacentEdges(5)); // ReSharper restore ReturnValueOfPureMethodIsNotUsed }
public void TryGetEdge_Throws() { var filteredGraph = new FilteredUndirectedGraph <TestVertex, Edge <TestVertex>, UndirectedGraph <TestVertex, Edge <TestVertex> > >( new UndirectedGraph <TestVertex, Edge <TestVertex> >(), _ => true, _ => true); TryGetEdge_Throws_UndirectedGraph_Test(filteredGraph); }
public void ContainsVertex_Throws() { var filteredGraph = new FilteredUndirectedGraph <TestVertex, Edge <TestVertex>, UndirectedGraph <TestVertex, Edge <TestVertex> > >( new UndirectedGraph <TestVertex, Edge <TestVertex> >(), _ => true, _ => true); ContainsVertex_Throws_Test(filteredGraph); }
public void ContainsEdge_Throws() { var filteredGraph = new FilteredUndirectedGraph <TestVertex, Edge <TestVertex>, UndirectedGraph <TestVertex, Edge <TestVertex> > >( new UndirectedGraph <TestVertex, Edge <TestVertex> >(), _ => true, _ => true); ContainsEdge_NullThrows_Test(filteredGraph); ContainsEdge_SourceTarget_Throws_UndirectedGraph_Test(filteredGraph); }
public void AdjacentEdge_Throws() { var graph1 = new UndirectedGraph <int, Edge <int> >(); AdjacentEdge_Throws_Test( graph1, (vertexPredicate, edgePredicate) => new FilteredUndirectedGraph <int, Edge <int>, UndirectedGraph <int, Edge <int> > >( graph1, vertexPredicate, edgePredicate)); var graph2 = new UndirectedGraph <TestVertex, Edge <TestVertex> >(); var filteredGraph2 = new FilteredUndirectedGraph <TestVertex, Edge <TestVertex>, UndirectedGraph <TestVertex, Edge <TestVertex> > >( graph2, _ => true, _ => true); AdjacentEdge_NullThrows_Test(filteredGraph2); }
public void Construction() { VertexPredicate <int> vertexPredicate = _ => true; EdgePredicate <int, Edge <int> > edgePredicate = _ => true; var graph = new UndirectedGraph <int, Edge <int> >(); var filteredGraph = new FilteredUndirectedGraph <int, Edge <int>, UndirectedGraph <int, Edge <int> > >( graph, vertexPredicate, edgePredicate); AssertGraphProperties(filteredGraph); graph = new UndirectedGraph <int, Edge <int> >(false); filteredGraph = new FilteredUndirectedGraph <int, Edge <int>, UndirectedGraph <int, Edge <int> > >( graph, vertexPredicate, edgePredicate); AssertGraphProperties(filteredGraph, false); #region Local function void AssertGraphProperties <TVertex, TEdge, TGraph>( FilteredUndirectedGraph <TVertex, TEdge, TGraph> g, bool parallelEdges = true) where TEdge : IEdge <TVertex> where TGraph : IUndirectedGraph <TVertex, TEdge> { Assert.AreSame(graph, g.BaseGraph); Assert.IsFalse(g.IsDirected); Assert.AreEqual(parallelEdges, g.AllowParallelEdges); Assert.AreSame(vertexPredicate, g.VertexPredicate); Assert.AreSame(edgePredicate, g.EdgePredicate); Assert.IsNotNull(g.EdgeEqualityComparer); AssertEmptyGraph(g); } #endregion }