1 / 10

Graph

This article provides an introduction to graph theory, explaining the definitions, examples, and different representations of graphs. It covers topics such as adjacency matrix representation, directed vs. undirected graphs, and breadth-first search (BFS) and depth-first search (DFS) algorithms.

Download Presentation

Graph

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. Graph

  2. A graph is a finite set of nodes with edges between nodes • Formally, a graph G is a structure (V,E) consisting of • a finite set V called the set of nodes, and • a set E that is a subset of VxV. That is, E is a set of pairs of the form (x,y) where x and y are nodes in V

  3. Example • V=set of 6 people: John, Mary, Joe, Helen, Tom, and Paul, of ages 12, 15, 12, 15, 13, and 13, respectively. • E ={(x,y) | if x is younger than y}

  4. Adjacency Matrix Representation • In this representation, each graph of n nodes is represented by an n x n matrix A, that is, a two-dimensional array A • The nodes are (re)-labeled 1,2,…,n • A[i][j] = 1 if (i,j) is an edge • A[i][j] = 0 if (i,j) is not an edge

  5. Example of Linked Representation

  6. Directed vs. Undirected Graphs

  7. Breadth First Search (BFS) • Depth First Search (DFS)

  8. Breadth First Search (BFS) A B C D E G

  9. Depth First Search (DFS) A B C C D D E G E

More Related