示例#1
0
        public void Size()
        {
            var graph = new UndirectedGraph <char, EdgeData>();

            graph.AddNodes('a', 'b', 'c', 'd', 'e');
            graph.AddEdges(
                ('a', 'b', dummyEdgeData),
                ('a', 'c', dummyEdgeData),
                ('a', 'd', dummyEdgeData),
                ('b', 'c', dummyEdgeData),
                ('b', 'd', dummyEdgeData),
                ('c', 'd', dummyEdgeData),
                ('c', 'e', dummyEdgeData)
                );

            graph.Size.Should().Be(7);
        }
示例#2
0
        public void Clique()
        {
            var graph = new UndirectedGraph <char, EdgeData>();

            graph.AddNodes('a', 'b', 'c', 'd', 'e');
            graph.AddEdges(
                ('a', 'b', dummyEdgeData),
                ('a', 'c', dummyEdgeData),
                ('a', 'd', dummyEdgeData),
                ('b', 'c', dummyEdgeData),
                ('b', 'd', dummyEdgeData),
                ('c', 'd', dummyEdgeData),
                ('c', 'e', dummyEdgeData)
                );

            graph.Clique(new char[] { 'a', 'b', 'c', 'd' }).Should().BeTrue();
            graph.Clique(new char[] { 'a', 'b', 'c', 'd', 'e' }).Should().BeFalse();
        }
示例#3
0
        public void Bipartite()
        {
            var graph = new UndirectedGraph <char, EdgeData>();

            graph.AddNodes('a', 'b', 'c', 'd', 'e');
            graph.AddEdges(
                ('a', 'b', dummyEdgeData),
                ('a', 'c', dummyEdgeData),
                ('b', 'd', dummyEdgeData),
                ('c', 'e', dummyEdgeData)
                );

            graph.Bipartite.Should().BeTrue();

            graph.AddEdge('a', 'e', dummyEdgeData);

            graph.Bipartite.Should().BeFalse();
        }
示例#4
0
        public void Complete()
        {
            var graph = new UndirectedGraph <char, EdgeData>();

            graph.AddNodes('a', 'b', 'c', 'd');
            graph.AddEdges(
                ('a', 'b', dummyEdgeData),
                ('a', 'c', dummyEdgeData),
                ('a', 'd', dummyEdgeData),
                ('b', 'c', dummyEdgeData),
                ('b', 'd', dummyEdgeData),
                ('c', 'd', dummyEdgeData)
                );

            graph.Complete.Should().BeTrue();

            graph.RemoveEdge('b', 'c');

            graph.Complete.Should().BeFalse();
        }
示例#5
0
        public void Degree()
        {
            var graph = new UndirectedGraph <char, EdgeData>();

            graph.AddNodes('a', 'b', 'c', 'd', 'e');
            graph.AddEdges(
                ('a', 'b', dummyEdgeData),
                ('a', 'c', dummyEdgeData),
                ('a', 'd', dummyEdgeData),
                ('b', 'c', dummyEdgeData),
                ('b', 'd', dummyEdgeData),
                ('c', 'd', dummyEdgeData),
                ('c', 'e', dummyEdgeData)
                );

            graph.Degree('a').Should().Be(3);
            graph.Degree('b').Should().Be(3);
            graph.Degree('c').Should().Be(4);
            graph.Degree('d').Should().Be(3);
            graph.Degree('e').Should().Be(1);
        }
示例#6
0
        public void Chordal()
        {
            var graph = new UndirectedGraph <char, EdgeData>();

            graph.AddNodes('a', 'b', 'c', 'd', 'e');
            graph.AddEdges(
                ('a', 'b', dummyEdgeData),
                ('a', 'c', dummyEdgeData),
                ('b', 'c', dummyEdgeData),
                ('b', 'd', dummyEdgeData),
                ('b', 'e', dummyEdgeData),
                ('c', 'd', dummyEdgeData),
                ('d', 'e', dummyEdgeData)
                );

            graph.Chordal.Should().BeTrue();

            graph.AddNode('f');
            graph.AddEdge('a', 'f', dummyEdgeData);

            graph.Chordal.Should().BeFalse();
        }