1 / 8

Representing Graphs

Representing Graphs. Adjacency Matrix. Suppose we have a graph G with n nodes. The adjacency matrix is the n x n matrix A=[a ij ] with:. a ij = 1 if (i,j) is an edge a ij = 0 if (i,j) is not an edge. Good for dense graphs!. 0 1 1 1. 1 0 1 1. A =. 1 1 0 1. 1 1 1 0. Example.

tan
Download Presentation

Representing Graphs

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Representing Graphs

  2. Adjacency Matrix Suppose we have a graph G with n nodes. The adjacency matrix is the n x n matrix A=[aij] with: aij = 1 if (i,j) is an edge aij = 0 if (i,j) is not an edge Good for dense graphs!

  3. 0 1 1 1 1 0 1 1 A = 1 1 0 1 1 1 1 0 Example

  4. 0 1 1 1 0 1 1 1 3 2 2 2 1 0 1 1 1 0 1 1 2 3 2 2 1 1 0 1 1 1 0 1 2 2 3 2 1 1 1 0 1 1 1 0 2 2 2 3 Counting Paths The number of paths of length k from node i to node j is the entry in position (i,j) in the matrix Ak = A2 =

  5. Adjacency List Suppose we have a graph G with n nodes. The adjacency list is the list that contains all the nodes that each node is adjacent to Good for sparse graphs!

  6. 1 3 2 4 Example 1: 2,3 2: 1,3,4 3: 1,2,4 4: 2,3

  7. Simple graph Vertex = node Edge Degree Weight Neighbours Complete Dual Bipartite Planar Cycle Tree Path Circuit Components Spanning Tree Terms to know

  8. Adjacency Matrix and List • Definition • Useful for counting Here’s What You Need to Know…

More Related