Sparse Matrices: Storage and Representation, Study notes of Data Structures and Algorithms

The concept of sparse matrices, their structured and unstructured forms, and various methods for representing and storing them. Structured sparse matrices include diagonal, tridiagonal, and lower triangular matrices. Unstructured sparse matrices, such as airline flight and web page matrices, require more complex storage solutions due to their irregular structure. Single linear list, array linear list, chain representation, and orthogonal list representation, along with their memory requirements and runtime performance.

Typology: Study notes

Pre 2010

Uploaded on 09/17/2009

koofers-user-53q
koofers-user-53q 🇺🇸

10 documents

1 / 6

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Sparse Matrices
sparse … many elements are zero
dense … few elements are zero
Example Of Sparse Matrices
diagonal
tridiagonal
lower triangular (?)
These are structured sparse matrices.
May be mapped into a 1D array so that a
mapping function can be used to locate an
element.
Unstructured Sparse Matrices
Airline flight matrix.
airports are numbered 1 through n
flight(i,j) = list of nonstop flights from airport i
to airport j
n = 1000 (say)
n x n array of list references => 4 million bytes
total number of flights = 20,000 (say)
need at most 20,000 list references => at most
80,000 bytes
Unstructured Sparse Matrices
Web page matrix.
web pages are numbered 1 through n
web(i,j) = number of links from page i to page j
Web analysis.
authority page … page that has many links to it
hub page … links to many authority pages
pf3
pf4
pf5

Partial preview of the text

Download Sparse Matrices: Storage and Representation and more Study notes Data Structures and Algorithms in PDF only on Docsity!

Sparse Matrices

sparse … many elements are zero dense … few elements are zero

Example Of Sparse Matrices

diagonal tridiagonal lower triangular (?)

These are structured sparse matrices. May be mapped into a 1D array so that a mapping function can be used to locate an element.

Unstructured Sparse Matrices

Airline flight matrix. ƒ airports are numbered 1 through n ƒ flight(i,j) = list of nonstop flights from airport i to airport j ƒ n = 1000 (say) ƒ n x n array of list references => 4 million bytes ƒ total number of flights = 20,000 (say) ƒ need at most 20,000 list references => at most 80,000 bytes

Unstructured Sparse Matrices

Web page matrix. web pages are numbered 1 through n web(i,j) = number of links from page i to page j

Web analysis. authority page … page that has many links to it hub page … links to many authority pages

Web Page Matrix

ƒ n = 2 billion (and growing by 1 million a day) ƒ n x n array of ints => 16 * 10^18 bytes (16 * 10^9 GB) ƒ each page links to 10 (say) other pages on average ƒ on average there are 10 nonzero entries per row ƒ space needed for nonzero elements is approximately 20 billion x 4 bytes = 80 billion bytes (80 GB)

Representation Of Unstructured

Sparse Matrices

Single linear list in row-major order. scan the nonzero elements of the sparse matrix in row- major order each nonzero element is represented by a triple (row, column, value) the list of triples may be an array list or a linked list (chain)

Single Linear List Example

list = row 1 1 2 2 4 4 column 3 5 3 4 2 3 value 3 4 5 7 2 6

Array Linear List Representation

row 1 1 2 2 4 4 list = column 3 5 3 4 2 3 value 3 4 5 7 2 6

element 0 1 2 3 4 5 row 1 1 2 2 4 4 column 3 5 3 4 2 3 value 3 4 5 7 2 6

Array Of Row Chains

row[]

3 3

null 5 4

3 5

null 4 7

2 2

null 3 6

null

Orthogonal List Representation Both row and column lists.

Node structure. row col down next

value

Row Lists

0 2 6 0 0 (^) null

(^1 3 3 1 5 )

(^2 3 5 2 4 )

(^4 2 2 4 3 )

n

n

n

Column Lists

(^1 3 3 1 5 )

(^2 3 5 2 4 )

(^4 2 2 4 3 )

n

n n

Orthogonal Lists

0 2 6 0 0 (^) null

row[]

(^1 3 3 1 5 )

(^2 3 5 2 4 )

(^4 2 2 4 3 )

n n

n

n nn

Variations

May use circular lists instead of chains.

Approximate Memory Requirements

500 x 500 matrix with 1994 nonzero elements

2D array 500 x 500 x 4 = 1million bytes Single Array List 3 x 1994 x 4 = 23,928 bytes One Chain Per Row 23928 + 500 x 4 = 25,

Runtime Performance

Matrix Transpose 500 x 500 matrix with 1994 nonzero elements

2D array 210 ms Single Array List 6 ms One Chain Per Row 12 ms