示例#1
0
        public void TestClusteringCoefficientForVertexInGraphWithAloneVertex()
        {
            var graph = new AdjacencyListGraph(4);

            graph.AddArrow(0, 3);
            graph.AddArrow(0, 1);
            graph.AddArrow(1, 2);
            graph.AddArrow(2, 0);

            ClusteringCoefficient cCoefficient = new ClusteringCoefficient(graph);
            var result = cCoefficient.GetClusteringCoefficientForVertex(3);

            double expectedResult = 0d;

            Assert.That(result, Is.EqualTo(expectedResult));
        }
示例#2
0
        public void SixVerticesGraphClusteringCoefficientForVertex0()
        {
            var graph = new AdjacencyGraph(6)
                        .AddArrow(0, 1)
                        .AddArrow(0, 2)
                        .AddArrow(0, 3)
                        .AddArrow(4, 0)
                        .AddArrow(3, 4)
                        .AddArrow(4, 3)
                        .AddArrow(2, 3)
                        .AddArrow(1, 2)
                        .AddArrow(2, 1)
                        .AddArrow(1, 5)
                        .AddArrow(5, 2)
                        .AddArrow(1, 0);

            ClusteringCoefficient cCoefficient = new ClusteringCoefficient(graph);
            var result = cCoefficient.GetClusteringCoefficientForVertex(0);

            Assert.That(result, Is.EqualTo(0.5));
        }