Presentation is loading. Please wait.

Presentation is loading. Please wait.

Graphs and Matrix Storage Structures EEE 574 Dr. Dan Tylavsky.

Similar presentations


Presentation on theme: "Graphs and Matrix Storage Structures EEE 574 Dr. Dan Tylavsky."— Presentation transcript:

1 Graphs and Matrix Storage Structures EEE 574 Dr. Dan Tylavsky

2 Graphs & Matrix Storage Structures © Copyright 1999 Daniel Tylavsky 4 In order to perform calculations on electric power networks we’ll need to have a way of representing them. 4 The mathematical equivalent of a network is a graph. 4 Some definitions: –Graph - G(U,E) consists of a set, U, of vertices (nodes) and a set, E, of edges (branches). –Edge (branch) - is uniquely determined by a pair of distinct vertices, (u,v).

3 Graphs & Matrix Storage Structures © Copyright 1999 Daniel Tylavsky 4 More definitions: –Digraph - a graph in which each edge, characterized by an ordered pair of vertices, (u,v), has an orientation from u to v. –Undirected graph - A graph in which edges have no orientation. (We’ll use this for our networks.) –Adjacency - A vertex, u, is adjacent to a vertex, v, if an edge (u,v) exists.

4 Graphs & Matrix Storage Structures © Copyright 1999 Daniel Tylavsky 4 More definitions: –Adjacency Data Structure of a Graph - For each graph vertex, the list of adjacent vertices is store in compact form. All compact forms are stored in one array.

5 Graphs & Matrix Storage Structures © Copyright 1999 Daniel Tylavsky     Node -List of Adjacent Nodes ERP - End of Row Pointer Advantages 1) Storage space is reasonable. 2) Easy to retrieve data values (individual and strings) 3)Coding is simple Disadvantages 1) Not easy to modify. 2) Meaning of data not easily obtained. 3) Edges stored twice. Pointing to end of each row means our last pointer points to last element in Node(k).

6 Graphs & Matrix Storage Structures © Copyright 1999 Daniel Tylavsky To find the number of connections to each node, say node j: # Conx Node j = ERP(j)-ERP(j-1) For node 1: # Conx Node 1 = ERP(1)-ERP(0) (Explains why we must start our arrays at position 0.) To list all nodes attached to a given node use the Fortran code: Integer NODE(0:MXBR), ERP(0:MXBS) Nod=? Ibeg=ERP(Nod-1)+1 Iend=ERP(Nod) Write(6,10) (List(I), I=Ibeg,Iend) 10 Format(….)

7 Graphs & Matrix Storage Structures © Copyright 1999 Daniel Tylavsky –How do we add a branch between 1 and 3 into this data structure? –Shift node values to make space to add node 3 to bus 1 list and node 1 to bus 3 list. –Add node 3 to bus 1 list and node 1 to bus 3 list. –Update End of Row Pointers. –Because of difficulties with adding (or deleting) we use the adjacency structure for static data storage.

8 Graphs & Matrix Storage Structures © Copyright 1999 Daniel Tylavsky –Let’s store the same information using a linked list: (Note: Sets are not disjoint.)     –To add a branch between 1 and 3: 3 11 12 -6 1 12 13 Pointer to available linked list storage. –Linked list structure is much easier to modify but requires more memory. –We use it when data changes dynamically.

9 Graphs & Matrix Storage Structures © Copyright 1999 Daniel Tylavsky –To eliminate a branch between 2 and 4. –Enter linked list for node 2, find node 4. Eliminate link.     Pointer to available linked list storage. –Linked list structure is much easier to modify but requires more memory. -3 9

10 Graphs & Matrix Storage Structures © Copyright 1999 Daniel Tylavsky     Teams: Modify the existing data structure to account for the removal of the branch (1,2) and addition of a node connected by a branch to node 3. 

11 Graphs & Matrix Storage Structures © Copyright 1999 Daniel Tylavsky 4 There is a correspondence between graph storage and sparse matrices. 4 Recall the rules for constructing the nodal admittance matrix: –Let y ij be the branch admittance between nodes i and j. –Let node 0 be the ground or reference node (not shown on our diagrams).

12 Graphs & Matrix Storage Structures © Copyright 1999 Daniel Tylavsky     –Note that the nodal admittance matrix is symmetric, that is y ij =y ji. –Let’s look a means for storing symmetric matrices.

13 Graphs & Matrix Storage Structures © Copyright 1999 Daniel Tylavsky Symmetric matrix storage using an adjacency structure.     –Then adjust the structure to accommodate the matrix. –Then include an array corresponding to the values in the matrix. –Let’s first construct adjacency structure for storing the graph,

14 Graphs & Matrix Storage Structures © Copyright 1999 Daniel Tylavsky –This adjacency structure is known as: Row-Wise Representation (Complete) Unordered (RR(C)U) –It is unordered because the node #’s with non-zero’s in each row are listed in neither ascending nor descending order. –An RR(C)O (Ordered) form is:

15 Graphs & Matrix Storage Structures © Copyright 1999 Daniel Tylavsky 4 Symmetric matrix storage using an adjacency structure (cont’d). –CR(C)O Column-wise representation (complete) ordered. (Same as RR(C)O for symmetric matrices) –CR(C)U (Unordered) - Same as RR(C)U for symmetric matrices.

16 Graphs & Matrix Storage Structures © Copyright 1999 Daniel Tylavsky 4 Symmetric matrix storage using an adjacency structure (cont’d). –If the matrices are symmetric, we need only store the upper half of the matrix: RR(DU)O/U Row-wise rep. (diagonal & upper) ordered /unordered. Same as CR(DL)O/U Column-wise rep. (diagonal & lower) ordered /unordered.

17 Graphs & Matrix Storage Structures © Copyright 1999 Daniel Tylavsky 4 Symmetric matrix storage using an adjacency structure (cont’d). –A more minimal storage technique: RR(U)O/U Row-wise rep. (upper) ordered /unordered. –It is convenient (esp. in positive definite matrices) to store the diagonal separately.

18 Graphs & Matrix Storage Structures © Copyright 1999 Daniel Tylavsky Teams: Compare RR(DU)X and RR(U)X storage schemes applied to the same matrix as shown below. Which requires less storage space? Where does the savings come from? RR(DU)O RR(U)O

19 Graphs & Matrix Storage Structures © Copyright 1999 Daniel Tylavsky 4 Symmetric matrix storage using a linked list structure. –Any of the forgoing storage techniques can be implemented with a linked list structure. –Consider RR(DU)O using a linked list sturcture. Here we have used as the last link of each row, the negative of the row index. This allows you to search Y then identify the row and column index of the element found.

20 Graphs & Matrix Storage Structures © Copyright 1999 Daniel Tylavsky 4 Incidence symmetric matrix storage using an adjacency structure (cont’d). –Incidence symmetric matrix - A matrix whose sparsity pattern is symmetric, but whose numerical content is not symmetric. –L-D-U RO/U - Lower-Diagonal-Upper Representation Ordered/Unordered. (This is an adaptation of the RR(U)x scheme for incidence symmetric matrices.

21 Graphs & Matrix Storage Structures © Copyright 1999 Daniel Tylavsky –Apply L-D-U RU to the following matrix. –YU is stored by rows. –YL is stored by columns. –Indx contains col. indices for YU, row indices for YL.

22 Graphs & Matrix Storage Structures © Copyright 1999 Daniel Tylavsky 4 Incidence symmetric matrix storage using an adjacency structure (cont’d). –When using a Newton-Raphson Method we get matrices that have a block-incidence symmetric form. –BRR(C)O/U Block- Row-Wise Representation (Complete) Ordered/Unordered.

23 Graphs & Matrix Storage Structures © Copyright 1999 Daniel Tylavsky –Apply BRR(C)O/U to the following matrix. 1234 1 2 3 4

24 The End

25 Graphs & Matrix Storage Structures © Copyright 1999 Daniel Tylavsky –Let’s look at some other storage schemes: –Knuth’s Storage:


Download ppt "Graphs and Matrix Storage Structures EEE 574 Dr. Dan Tylavsky."

Similar presentations


Ads by Google