コード例 #1
0
ファイル: dist_matrix_test.go プロジェクト: soniakeys/cluster
func ExampleDistanceMatrix_TriangleInequality() {
	d1 := cluster.DistanceMatrix{
		{0, 13, 21, 22}, // true
		{13, 0, 12, 13},
		{21, 12, 0, 13},
		{22, 13, 13, 0},
	}
	d2 := cluster.DistanceMatrix{
		{0, 13, 21, math.NaN()}, // true
		{13, 0, 12, 13},
		{21, 12, 0, 13},
		{22, 13, 13, 0},
	}
	d3 := cluster.DistanceMatrix{}
	d4 := cluster.DistanceMatrix{
		{0, 4, 6, 1}, // false
		{4, 0, 3, 2},
		{6, 3, 0, 5},
		{1, 2, 5, 0},
	}
	fmt.Println(d1.TriangleInequality())
	fmt.Println(d2.TriangleInequality())
	fmt.Println(d3.TriangleInequality())
	fmt.Println(d4.TriangleInequality())
	// Output:
	// true 0 0 0
	// true 0 0 0
	// true 0 0 0
	// false 1 3 0
}