public void OnlyItemsInListTest() { var items = new Set <IGraphEntity> (); var data = new EntityBinaryTreeFactory(); data.Count = 1; data.Populate(); var graph = new FilteredGraph <IGraphEntity, IGraphEdge> (data.Graph); graph.ItemFilter = delegate(IGraphEntity item) { return(items.Contains(item)); }; graph.EdgeFilter = delegate(IGraphEdge edge) { return (items.Contains(edge.Root) && items.Contains(edge.Leaf)); }; items.Add(data.Nodes[1]); items.Add(data.Nodes[2]); this.ReportDetail(GraphTestUtils.ReportGraph <IGraphEntity, IGraphEdge> (graph, "Filtered Graph")); }
public void BasicGraphTest() { var test = new StringGraphTest(); var graph = new FilteredGraph <string, Edge <string> >(test.Graph); graph.ItemFilter = delegate(string s) { return(true); }; graph.EdgeFilter = delegate(Edge <string> s) { return(true); }; test.Graph = graph; test.AllTests(); }
public void Construction() { VertexPredicate <int> vertexPredicate = _ => true; EdgePredicate <int, Edge <int> > edgePredicate = _ => true; var graph1 = new AdjacencyGraph <int, Edge <int> >(); var filteredGraph1 = new FilteredGraph <int, Edge <int>, AdjacencyGraph <int, Edge <int> > >( graph1, vertexPredicate, edgePredicate); AssertGraphProperties(filteredGraph1, graph1); graph1 = new AdjacencyGraph <int, Edge <int> >(false); filteredGraph1 = new FilteredGraph <int, Edge <int>, AdjacencyGraph <int, Edge <int> > >( graph1, vertexPredicate, edgePredicate); AssertGraphProperties(filteredGraph1, graph1, parallelEdges: false); var graph2 = new UndirectedGraph <int, Edge <int> >(); var filteredGraph2 = new FilteredGraph <int, Edge <int>, UndirectedGraph <int, Edge <int> > >( graph2, vertexPredicate, edgePredicate); AssertGraphProperties(filteredGraph2, graph2, false); graph2 = new UndirectedGraph <int, Edge <int> >(false); filteredGraph2 = new FilteredGraph <int, Edge <int>, UndirectedGraph <int, Edge <int> > >( graph2, vertexPredicate, edgePredicate); AssertGraphProperties(filteredGraph2, graph2, false, false); #region Local function void AssertGraphProperties <TVertex, TEdge, TGraph>( FilteredGraph <TVertex, TEdge, TGraph> g, TGraph expectedGraph, bool isDirected = true, bool parallelEdges = true) where TEdge : IEdge <TVertex> where TGraph : IGraph <TVertex, TEdge> { Assert.AreSame(expectedGraph, g.BaseGraph); Assert.AreEqual(isDirected, g.IsDirected); Assert.AreEqual(parallelEdges, g.AllowParallelEdges); Assert.AreSame(vertexPredicate, g.VertexPredicate); Assert.AreSame(edgePredicate, g.EdgePredicate); } #endregion }