260 likes | 430 Views
Graphs and Matrix Storage Structures. EEE 574 Dr. Dan Tylavsky. In order to perform calculations on electric power networks we’ll need to have a way of representing them. The mathematical equivalent of a network is a graph. Some definitions:
E N D
Graphs and Matrix Storage Structures EEE 574 Dr. Dan Tylavsky
In order to perform calculations on electric power networks we’ll need to have a way of representing them. • The mathematical equivalent of a network is a graph. • 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).
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.
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.
Pointing to end of each row means our last pointer points to last element in Node(k). 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.
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.) 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(….) To list all nodes attached to a given node use the Fortran code:
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.
• Let’s store the same information using a linked list: (Note: Sets are not disjoint.) 3 1 -1 -6 11 12 12 13 • To add a branch between 1 and 3: 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.
• To eliminate a branch between 2 and 4. -3 9 • 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.
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.
There is a correspondence between graph storage and sparse matrices. • Recall the rules for constructing the nodal admittance matrix: • Let yij be the branch admittance between nodes i and j. • Let node 0 be the ground or reference node (not shown on our diagrams).
• Note that the nodal admittance matrix is symmetric, that is yij=yji. • Let’s look a means for storing symmetric matrices.
Symmetric matrix storage using an adjacency structure. • Let’s first construct adjacency structure for storing the graph, • Then adjust the structure to accommodate the matrix. • Then include an array corresponding to the values in the matrix.
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:
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.
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.
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.
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
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.
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.
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.
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.
1 2 3 4 1 2 3 4 • Apply BRR(C)O/U to the following matrix.
Let’s look at some other storage schemes: • Knuth’s Storage: