Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2008

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: How to plot a graph, using a distance matrix

  • To: mathgroup at smc.vnet.net
  • Subject: [mg89035] Re: How to plot a graph, using a distance matrix
  • From: Ray Koopman <koopman at sfu.ca>
  • Date: Sat, 24 May 2008 03:54:01 -0400 (EDT)
  • References: <g15qni$pdj$1@smc.vnet.net>

On May 23, 12:11 am, Eric Heiman <ehei... at mailinator.com> wrote:
> My dilemna is as such:
>
> I have a matrix (it happens to be 21x21, but don't worry about that) which contains distances between points.
> So column 1 has distances from point 1 to every other point, with row 1 being 0 (because the distance to itself is zero).
>
> What I am wondering is how I would be able to get mathematica to plot a graph of these points.
>
> Thanks in advance!

First the algebra:

Let C = (-1/2)(I - uu'/n)B(I - uu'/n), where
B is the matrix of squared distances among the n points,
I is the identity matrix,
u is a column vector whose elements are all 1s,
and ' denotes transposition.

If the points lie in an m-dimensional space
then C will be positive semidefinite, with rank m.
Let F be any factoring of such a C, so that FF' = C.
Then F contains the coordinates of the points.

This is a well-known result in multidimensional scaling.

In Mathematica code, if dis is the matrix of distances, let

{vals,vex} = Eigensystem[-.5 (#-Mean@#&) /@
             Transpose[#-Mean@#& /@ (dis^2)]];

The first m elements of vals should be positive;
the rest should be approximate zeros. Then

f = Transpose[Sqrt[Take[vals,m]]*Take[vex,m]]

will contain the coordinates of the points. However, this assumes
that the eigenvectors are orthonormal, which is usually true, but I
have not been able to find it in the documentation, so caveat user.


  • Prev by Date: Re: Computing n-grams
  • Next by Date: Re: Sluggish performance in Save, bug?
  • Previous by thread: Re: How to plot a graph, using a distance matrix
  • Next by thread: Re: Re: How to plot a graph, using a distance matrix