Graph Draw Notes
Graph Draw Notes
1 Introduction
Our research focuses on the use of spectral graph drawing techniques (see [5] and [3]) and other
mathematical tools to create a two-dimensional (2D) representation of the graph of a sparse matrix.
The actual graph drawing then amounts to displaying a particular arrangement of the vertices and
edges of a given graph in two dimensions. We use a spectral layout that provides coordinates using
the second and third eigenvectors of the associated graph Laplacian. To compute the eigenvectors
and eigenvalues, we implement a subspace correction method proposed in [4] and further analyzed
in [1].
• Exploration of data: Displaying nodes and ties in various layouts and attributing color, size
and other properties to nodes allows for the better visualization and analysis of data.
• Analysis of sociograms: Digraphs that diagram the structures and patterns of group interac-
tions facilitate the study of choices or preferences within a group.
With the quick and recent expansion of social networking, graph drawing is gaining a great deal of
attention. Some of the currently available graph-drawing software includes the following:
• Wolfram Alpha: This online service can connect to Facebook and make charts of friend
connections and relationships.
1
• LTAS Technologies, Inc.: Among many other applications, this web identity search tool for
Facebook finds the degree of separation between any two Facebook users and displays it in a
graph.
• V is the set of vertices: a set of discrete objects (but usually isomorphic to {1, . . . , n}).
We will consider two different types of graphs: undirected graphs and directed graphs. In an
undirected graph for an edge (c, m), we always have (c, m) = (m, c), while in a directed graph
(c, m) 6= (m, c). In addition, multigraphs allow multiple edges between vertices and loop graphs
contain an edge that connects a vertex to itself. If the graph is weighted, one may associate a
weight with every edge of a graph. Finally, a simple graph is an undirected graph that contains no
loops or parallel edges. We will focus on weighted and unweighted simple graphs.
• degree of a vertex: the number of edges incident to the vertex (gives an idea of how directly
connected it is)
• connectedness: A graph is connected if for any two vertices v1 , v2 ∈ V there exists a path from
v1 to v2 ; a path being a sequence of vertices v1 = w1 , w2 . . . , wk = v2 such that (wj−1 , wj ) ∈ E,
for all j = 2, . . . , k.
• partition of a graph: splitting V in two disjoint subsets, namely, V = V1 ∪V2 with V1 ∩V2 = ∅.
A graph is connected if for every partition there exists an edge connecting the two sets of
vertices.
• Adjacency matrix A ∈ IRn×n , n = |V |, where Aij equals the number of edges between vertex
i and vertex j
2
Homework Show that for a simple undirected graph, Lij = −1 for i 6= j, and Lii = d(i) (the
degree of vertex i).
Using the inner product, with every matrix, such as L, we associate a bilinear form:
n X
X n
(Lu, v) = Lij uj vi , for all u ∈ IRn , v ∈ IRn .
i=1 j=1
The sum on the left side of the above identity is over all j ∈ {1, . . . , n} such that j 6= i.
Homework Given that L1 = 0, show that the above bilinear form can be written as:
n n
1 XX
(Lu, v) = (−Lij )(ui − uj )(vi − vj ).
2
i=1 j=1
Further show that if all Lij ≤ 0, then (Lu, u) ≥ 0 for all u ∈ IRn . Such an L is called symmetric
positive semidefinite.
σ(L) = {λ1 , λ2 , . . . , λn }, λ1 ≤ λ2 ≤ . . . , ≤ λn .
(Lv, v) (Lv, v)
λ1 = minn , λn = maxn .
v∈IR (v, v) v∈IR (v, v)
As we checked in the Homework, (Lv, v) ≥ 0 and (L1, 1) = 0. We conclude that λ1 = 0 and
the corresponding eigenvector is 1. For a connected, undirected graph with positive edge weights
it can be shown that 0 is a simple eigenvalue, namely, 0 = λ1 < λ2 ≤ λ2 . . . ≤ λn .
Furthermore, it can be shown that if (λ2 , v2 ) and (λ2 , v3 ) are the eigenvalue and eigenvector
pairs of L, then
(Lv, v) (Lv, v)
λ2 = min , λ3 = min , (2)
v∈V2 (v, v) v∈V3 (v, v)
3
where V1 is the subspace of vectors orthogonal to 1, and V2 is the subspace of vectors orthogonal
to both 1 and v2 . More precisely,
V1 = v ∈ IRn , (v, 1) = 0 ,
Homework Show this by proving the min-max principle (you will find this in [2]).
The spectral layout graph drawing uses v2 and v3 as coordinates of the vertices to display the
graph in two dimensions. In other words, the vertex i will have coordinates (v1,i , v2,i ) ⊂ IR2 , and
an edge is drawn between i and j if (i, j) ∈ E.
Thus, to utilize a spectral layout drawing, the problem is to find (λ2 , v2 ) and (λ3 , v3 ) which
solve
Lv2 = λ2 v2 , Lv3 = λ3 v3 , (v2 , 1) = (v3 , 1) = 0, (v2 , v3 ) = 0.
(Lv, v)
This is equivalent to minimizing the Rayleigh quotient, written as λ = min .
(x,1)=0 (v, v)
We would like to emphasize that instead of the scalar product given in (1), in all of the Rayleigh
quotients we use (Dv, v) instead of (v, v). In such a case we will be solving the so-called generalized
eigenvalue problem
Indeed, it is easy to verify that all considerations below are valid with this scalar product.
is indeed a dot product between v and w. For n = 2, (two dimensions) draw the unit sphere, or the
tips of all vectors v ∈ IR2 satisfying (Dv, v) = 1 if: (a) d(1) = d(2) = 1; (b) d(1) = 1 and d(2) = 10.
IRn = W1 + W2 + · · · + Wnc .
The algorithm visits each subspace and improves the current eigenvalue approximation from
each of these subspaces. To explain this in more detail, let y be a given approximation to the
eigenvector v2 , with (y, 1) = 0. We want to improve the approximation y by finding y1 ∈ W1 such
that
(L(y + z), (y + z))
y1 = arg min . (4)
z∈W1 (y + z, y + z)
4
The notation arg min means that y1 is the argument z which minimizes the right side of the equation
above. We now show how we can find y1 by solving a (ni + 1) × (ni + 1) problem. We first compute
the numerator on the right hand side of (4):
z = P1 dz
|{z} |{z} |{z}
IRn n
IRn×n1 IR 1
Thus, minimizing with respect to z ∈ W1 is the same as finding dz ∈ IRn1 . We then have
(Ly, y) + 2(Ly, z) + (Lz, z)
µ = min
z∈W1 (y, y) + 2(y, z) + (z, z)
(Ly, y) + 2(Ly, P1 dz ) + (LP1 dz , P1 dz )
= e minn
dz ∈IR 1 (y, y) + 2(y, P1 dz ) + (P1 dz , P1 dz )
(Ly, y) + 2(P1T Ly, dz ) + (P1T LP1 dz , dz )
= minnz .
dz ∈IR (y, y) + 2(P1T y, dz ) + (P1T P1 dz , dz )
Introducing the matrix
T
T Ty
P 1
P 1 P 1 P1
Ie1 = T P1 y = T ,
y y P1 y T y
and the vector
d
dz = 1
e (n1 + 1),
1
it is straightforward to check the following identities:
5
Consequently, we have that
(L
e 1 dez , dez )
µ = min .
dez (Ie1 dez , dez )
Hence, the minimizer of the above Rayleigh quotient, de1 , is a generalized eigenvector of the gener-
alized eigenvalue problem
L
e 1 de1 = µIe1 de1 . (5)
So to find y1 , we need to solve the (n1 + 1) × (n1 + 1) eigenvalue problem (5).
{1, . . . , n} = ∪nk=1
c
Ωk , Ωk ∩ Ωj = ∅, whenever k 6= j.
Next, we formalize the subspace correction algorithm as follows. In our computations, we use a
modification that can simultaneously compute nλ eigenvalues. In the tests we have done, we always
set nλ = 3. The number of eigenvalues we find on each subspace is nm = (nλ + 2), because the first
nλ eigenvalues of the subspace problem are more accurately computed.
We find the three smallest eigenvalues of Lv = λDv (0 = λ1 , λ2 , and λ3 ). Here, D is the degree
matrix of the graph, L = D − A is the Laplacian matrix of the graph, and Y is the approximation
of the eigenvectors, which we orthogonalize and normalize. We obtain the eigenvalues of the graph,
and we use the corresponding eigenvectors to draw a representation of the graph. We also consider
subspaces Wi = Range(Pi ) subordinate to the partitioning provided by the clusters Ωi . More
precisely, let
Ωi = {j1 , . . . , jni } ⊂ {1, . . . , n}.
Then Pi ∈ IRn×ni is defined as
1, k = `
(Pi )j` ,k
0, otherwise.
The algorithm below takes an initial guess Y ∈ IRn×nλ and, as output, provides a new and
improved approximation.
6
Algorithm 2: Schwartz-based method
Y ∈ IRn×nλ is the current approximation to the first nλ eigenvectors
for i = 1 : nc do
set Pei = [Pi , Y ]
compute L e i = PeT LPei
i
compute Iei = PeiT DPei
let (λk , uk ), k = 1, . . . , nλ , 0 = λ1 ≤ . . . ≤ λnλ be the eigenvector, eigenvalue pair of the
eigenvalue problem L e k uk = λk Iei uk
Set Y = Pei [u1 , . . . , unλ ] (Y is now the new approximation to the eigenvectors)
Figure 1: The red drawing depicts the clusters, the black graph depicts the coarse graph and blue
graph is our regular graph drawing.
However, if we attempt to solve in this subspace in the same way as we did before, it will not work;
Y contains column 1, and we also have, as we mentioned earlier, P 1nc = 1n . Note that
Lx = λDx (6)
is well defined if D is invertible. If D is not invertible, D has a non-trivial null space and the
eigenvalue problem (6) does not make sense in general. If D is invertible, then clearly any solution
to (6) is a solution to the eigenvalue problem D−1 Lx = λx, and everything is well defined.
7
These observations are summarized as follows:
1 ∗ ∗ 1 1
1 ∗ ∗ 1 1
Pe = [P, Y ], Y = . . .. , P . = . .
.. .. . .. ..
1 ∗ ∗ 1 1
We thus immediately conclude that Pe is not full rank, and, therefore, PeT DPe is singular, and the
eigenvalue problem on this subspace is not well posed (this is only due to the matrices we use). In
order to eliminate this redundancy, we use the two columns of Y only when we do the coarse grid
correction. In short, we only use the last two columns of Y to form Pe. More precisely, we have,
Another remark we would like to make here is that instead of the P which we described above,
we also use in the algorithm the so-called “smoothed aggregation” P , which is defined as
P ← (I − D−1 L)P.
The results in the next section are obtained using this P for the coarse grid correction.
5 Numerical tests
In our tests, we used several adjacency matrices from The University of Florida Sparse Matrix
Collection http://www.cise.ufl.edu/research/sparse/matrices/.
8
Iterations Iterations
Figure Graph Name (no coarse grid) (coarse grid) Vertices Edges
2 grid1 dual 127 7 224 420
3 delaunay n13 |> 200 | 5 8192 24547
4 barth5 |> 200 | 5 15606 45878
5 big dual |> 200 | 5 30269 44929
6 Alemdar 194 7 6240 18168
7 fe 4elt2 |> 200 | 5 11143 32818
Table 1: Comparison of a single level method (without coarse grid correction) and two level method
(with coarse grid correction).
We ran our subspace correction algorithm both with and without the coarse grid correction.
A comparison of the number of iterations can be seen in Table 1, and the corresponding graph
drawings obtained using the two-level method (with coarse grid correction) are shown in Figures 2-
4.
9
References
[1] Tony F. Chan and Ilya Sharapov, Subspace correction multi-level methods for elliptic eigenvalue
problems, Numer. Linear Algebra Appl. 9 (2002), no. 1, 1–20. MR 1874780 (2002k:65180)
[2] Paul R. Halmos, Finite-dimensional vector spaces, second ed., Springer-Verlag, New York, 1974,
Undergraduate Texts in Mathematics. MR 0409503 (53 #13258)
[3] David Harel and Yehuda Koren, A fast multi-scale method for drawing large graphs, J. Graph
Algorithms Appl. 6 (2002), no. 3, 179–202 (electronic), 2000 Symposium on Graph Drawing
(Williamsburg, VA). MR 1993519 (2004f:68118)
[4] M. S. Kaschiev, An iterative method for minimization of the Rayleigh-Ritz functional, Com-
putational processes and systems, No. 6 (Russian), “Nauka”, Moscow, 1988, pp. 160–170. MR
982053 (90f:65054)
[5] Yehuda Koren, On spectral graph drawing, Computing and combinatorics, Lecture Notes in
Comput. Sci., vol. 2697, Springer, Berlin, 2003, pp. 496–508. MR 2063526
10