Let G = ( V ( G ) , E ( G ) ) be a connected graph. An ordered set W &sub / V ( G ) is a resolving set for G if every vertex of G is uniquely determined by its vector of distances to the vertices in W. The metric dimension of G is the minimum cardinality of a resolving set. In this paper, we characterize the graphs of metric dimension n &minus / 3 by constructing a special distance matrix, called metric matrix. The metric matrix makes it so a class of graph and its twin graph are bijective and the class of graph is obtained from its twin graph, so it provides a basis for the extension of graphs with respect to metric dimension. Further, the metric matrix gives a new idea of the characterization of extremal graphs based on metric dimension.