language-icon Old Web
English
Sign In

Distance matrix

In mathematics, computer science and especially graph theory, a distance matrix is a square matrix (two-dimensional array) containing the distances, taken pairwise, between the elements of a set. Depending upon the application involved, the distance being used to define this matrix may or may not be a metric. If there are N elements, this matrix will have size N×N. In graph-theoretic applications the elements are more often referred to as points, nodes or vertices. In mathematics, computer science and especially graph theory, a distance matrix is a square matrix (two-dimensional array) containing the distances, taken pairwise, between the elements of a set. Depending upon the application involved, the distance being used to define this matrix may or may not be a metric. If there are N elements, this matrix will have size N×N. In graph-theoretic applications the elements are more often referred to as points, nodes or vertices. When distance is defined as a metric, as for example in the Euclidean distance matrix, the distance matrix satisfies properties directly related to the defining properties of a metric. That is, if M = (xij) with 1 ≤ i, j ≤ N is a distance matrix for a metric distance, then Another common example of a distance matrix arises in coding theory when in a block code the elements are strings of fixed length over an alphabet and the distance between them is given by the Hamming distance metric. The smallest non-zero entry in the distance matrix measures the error correcting and error detecting capability of the code. In a network, a directed graph with weights assigned to the arcs, the distance between two nodes of the network can be defined as the minimum of the sums of the weights on the shortest paths joining the two nodes. This distance function, while well defined, is not a metric. There need be no restrictions on the weights other than the need to be able to combine and compare them, so negative weights are used in some applications. Since paths are directed, symmetry can not be guaranteed, and if cycles exist the distance matrix may not be hollow. An algebraic formulation of the above can be obtained by using the min-plus algebra. Matrix multiplication in this system is defined as follows: Given two n × n {displaystyle n imes n} matrices A = ( a i j ) {displaystyle A=(a_{ij})} and B = ( b i j ) {displaystyle B=(b_{ij})} , their distance product C = ( c i j ) = A ⋆ B {displaystyle C=(c_{ij})=Astar B} is defined as an n × n {displaystyle n imes n} matrix such that c i j = min k = 1 n { a i k + b k j } {displaystyle c_{ij}=min _{k=1}^{n}{a_{ik}+b_{kj}}} . Note that the off-diagonal elements that are not connected directly will need to be set to infinity or a suitable large value for the min-plus operations to work correctly. A zero in these locations will be incorrectly interpreted as an edge with no distance, cost, etc. If W {displaystyle W} is an n × n {displaystyle n imes n} matrix containing the edge weights of a graph, then W k {displaystyle W^{k}} (using this distance product) gives the distances between vertices using paths of length at most k {displaystyle k} edges, and W n {displaystyle W^{n}} is the distance matrix of the graph. An arbitrary graph G on n vertices can be modeled as a weighted complete graph on n vertices by assigning a weight of one to each edge of the complete graph that corresponds to an edge of G and zero to all other edges. W for this complete graph is the adjacency matrix of G. The distance matrix of G can be computed from W as above, however, Wn calculated by the usual matrix multiplication only encodes the number of paths between any two vertices of length at most n. A distance matrix is necessary for hierarchical clustering. Distance matrices are used in phylogenetic analysis.

[ "Matrix (mathematics)", "Algorithm", "Combinatorics" ]
Parent Topic
Child Topic
    No Parent Topic