示例#1
0
        public void ContainsVertex_Throws()
        {
            var filteredGraph = new FilteredEdgeListGraph <TestVertex, Edge <TestVertex>, AdjacencyGraph <TestVertex, Edge <TestVertex> > >(
                new AdjacencyGraph <TestVertex, Edge <TestVertex> >(),
                _ => true,
                _ => true);

            ContainsVertex_Throws_Test(filteredGraph);
        }
 public void SetUp()
 {
     this.dataSource     = new NullableAndNonNullableRelationDataSet();
     this.graph          = DataGraph.Create(dataSource);
     this.edgePredictate = new DataTableSortAlgorithm.NonNullableDataRelationEdgePredicate();
     this.fgraph         = new FilteredEdgeListGraph(this.graph,
                                                     this.edgePredictate
                                                     );
 }
示例#3
0
        public void Construction()
        {
            VertexPredicate <int>            vertexPredicate = _ => true;
            EdgePredicate <int, Edge <int> > edgePredicate   = _ => true;

            var graph1         = new AdjacencyGraph <int, Edge <int> >();
            var filteredGraph1 = new FilteredEdgeListGraph <int, Edge <int>, AdjacencyGraph <int, Edge <int> > >(
                graph1,
                vertexPredicate,
                edgePredicate);

            AssertGraphProperties(filteredGraph1, graph1);

            graph1         = new AdjacencyGraph <int, Edge <int> >(false);
            filteredGraph1 = new FilteredEdgeListGraph <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 FilteredEdgeListGraph <int, Edge <int>, UndirectedGraph <int, Edge <int> > >(
                graph2,
                vertexPredicate,
                edgePredicate);

            AssertGraphProperties(filteredGraph2, graph2, false);

            graph2         = new UndirectedGraph <int, Edge <int> >(false);
            filteredGraph2 = new FilteredEdgeListGraph <int, Edge <int>, UndirectedGraph <int, Edge <int> > >(
                graph2,
                vertexPredicate,
                edgePredicate);
            AssertGraphProperties(filteredGraph2, graph2, false, false);

            #region Local function

            void AssertGraphProperties <TVertex, TEdge, TGraph>(
                FilteredEdgeListGraph <TVertex, TEdge, TGraph> g,
                TGraph expectedGraph,
                bool isDirected    = true,
                bool parallelEdges = true)
                where TEdge : IEdge <TVertex>
                where TGraph : IEdgeListGraph <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);
                AssertEmptyGraph(g);
            }

            #endregion
        }