Laplacian Experiments/Eigenmatrices

From Worden

Jump to: navigation, search

Visualizing the eigenmatrices of the Laplacianoid operator, in much the same way that we previously made pictures of the eigenvectors of a graph's Laplacian.

For example the first symmetric one:

WorkingWiki messages

Error: Make 'double.star.eigenmatrix.1.1.png' failed. Consult the log file for more information.

and the third symmetric one:

WorkingWiki messages

Error: Make 'double.star.eigenmatrix.3.3.png' failed. Consult the log file for more information.

(Here's the first asymmetric one)

WorkingWiki messages

Error: Make 'double.star.eigenmatrix.1.2.png' failed. Consult the log file for more information.

Here's the picture of all of them - it's a very large image, with all 100 of the graph pictures in rows and columns. The eigenvector pictures are included as row and column headers to help make sense out of them.

  • WorkingWiki messages

    Error: Make 'double.star.all-eigenmatrices.png' failed. Consult the log file for more information.

The relation between eigenmatrices of e and eigenvectors of Le is that if the latter are called vi for i=1,,n, then the former are of the form vivjT for all i,j. Each vi is a vector containing one number for each vertex of the graph, so we draw it as colors on the vertices on a picture of the graph, grey to black for positive numbers and pink to red for negative. Each eigenmatrix, on the other hand, is a matrix of numbers, one for each possible edge of the graph, including loops from a vertex to itself, so we visualize it by coloring the graph's edges in the same color scheme. Large positive or negative numbers (larger than 1) are also drawn with thicker arrows than the rest.

Note: there are other symmetric eigenmatrices, constructed by taking vivjT+vjviT for any i and j. To do: draw them as well.

double.star.eigenmatrices.Rstep
prereq: $(MF)/double.star.graph.R $(MF)/laplacian.functions.R stochastic-laplacianoid.functions.R $(MF)/graph.plotting.functions.R
library(network)
G <- double.star.graph()
e <- as.matrix(G)
Le <- standard.laplacian(e)
Le.eig <- eigen(Le)
#print(Le.eig)
coord <- NULL
for (i in 1:ncol(Le.eig[['vectors']]))
{ coord <- plot.vertex.function(G,
    matrix(sapply(Le.eig[['vectors']][,i],make.edge.color),nrow(e),ncol(e)),
    paste('double.star.eigenvector.',i,'.png',sep=''),coord=coord)
  for (j in 1:ncol(Le.eig[['vectors']]))
  { vi.vj <- Le.eig[['vectors']][,i] %o% Le.eig[['vectors']][,j]
    vi.vj <- (2.0 / max(vi.vj)) * vi.vj
    lambda <- Le.eig[['values']][i] + Le.eig[['values']][j]
    L.vi.vj <- laplacianoid.operation(e, vi.vj)
    if (max(L.vi.vj - lambda * vi.vj) < 0.0001)
    { cat(' an eigenmatrix!\n')
    }
    else
    { cat(' not an eigenmatrix!\n');
      print(vi.vj)
      print(' becomes')
      print(L.vi.vj)
      print(' and not')
      print(lambda * vi.vj)
    }
    if (isSymmetric(vi.vj))
    { cat('eigenmatrix',i,',',j,' is symmetric!\n')
    }
    else
    { cat('eigenmatrix',i,',',j,' is not symmetric!\n')
    }
    coord <- plot.network.png(network(vi.vj, directed=TRUE, loops=TRUE),
      paste('double.star.eigenmatrix',i,j,'png',sep='.'),
      edgecol=matrix(sapply(vi.vj, make.edge.color),nrow(vi.vj),ncol(vi.vj)), 
      edgewid=matrix(sapply(vi.vj, make.edge.width),nrow(vi.vj),ncol(vi.vj)),
      coord=coord)
  }
}

eigenmatrices.mk
%.all-eigenmatrices.png : %.all-eigenmatrices.bash
	convert $*.eigenvector.1.png -threshold -1 $*.placeholder.png
	bash $<
 
%.all-eigenmatrices.bash : %.eigenmatrices.Rout
	perl -e 'print "convert $*.placeholder.png "; for $$i (1..10) { print("$*.eigenvector.$$i.png "); } print "+append $*.column.0.png\n"' > $@
	perl -e 'for $$i (1..10) { print("convert $*.eigenvector.$$i.png "); for $$j (1..10) { print("$*.eigenmatrix.$$i.$$j.png "); } print("+append $*.column.$$i.png\n") }' >> $@
	perl -e 'print "convert "; for $$i (0..10) { print("$*.column.$$i.png ") } print "-append $*.all-eigenmatrices.png\n"' >> $@

Personal tools