# lec11 - Lecture 11 Graphs Vertices edges paths cycles...

This preview shows pages 1–7. Sign up to view the full content.

Page 1 of 23 CSE 100, UCSD: LEC 11 Lecture 11 Graphs Vertices, edges, paths, cycles Sparse and dense graphs Representations: adjacency matrices and adjacency lists Implementation notes Reading: Weiss, Chapter 9

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Page 2 of 23 CSE 100, UCSD: LEC 11 Kinds of data structures You are familiar with these kinds of data structures: unstructured structures: sets linear, sequential structures: arrays, linked lists hierarchical structures: trees Now we will look at graphs Graphs consist of a collection of elements, called “nodes” or “vertices” a set of connections, called “edges” or “links” or “arcs”, between pairs of nodes Graphs are in general not hierarchical or sequential: there is no requirement for a distinguished root node or first node, no requirement that nodes have a unique parent or a unique successor, etc.
Page 3 of 23 CSE 100, UCSD: LEC 11 Why graphs? Trees are a generalization of lists (a list is just a special case of a tree). .. Graphs are a generalization of of trees (a tree is just a special case of a graph). .. So, graphs are very general structures and are very useful in many applications the set of machines on the internet, and network lines between them, form a graph the set of statements in a program, and flow of control between them, form a graph the set of web pages in the world, and HREF links between them, form a graph the set of transistors on a chip, and wires between them, form a graph the set of possible base sequences in a DNA gene, and mutations between them, form a graph the set of possible situations that can arise in solving a problem or playing a game, and moves that get you from one situation to another, form a graph et cetera. .. We will look at a formal definition of a graph, some ways of representing graphs, and some important algorithms on graphs

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Page 4 of 23 CSE 100, UCSD: LEC 11 Graphs: some definitions A graph G = (V,E) consists of a set of vertices V and a set of edges E Each edge in E is a pair (v,w) such that v and w are in V. If G is an undirected graph, (v,w) in E means vertices v and w are connected by an edge in G. This (v,w) is an unordered pair If G is a directed graph, (v,w) in E means there is an edge going from vertex v to vertex w in G. This (v,w) is an ordered pair; there may or may not also be an edge (w,v) in E In a weighted graph, each edge also has a “weight” or “cost” c, and an edge in E is a triple (v,w,c) When talking about the size of a problem involving a graph, the number of vertices |V| and the number of edges |E| will be relevant
Page 5 of 23 CSE 100, UCSD: LEC 11 Graphs: an example Here is an unweighted directed graph: V = { } |V| = E = { } |E| = V0 V1 V4 V6 V5 V2 V3

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Page 6 of 23 CSE 100, UCSD: LEC 11 Graphs: more definitions A path in a graph G=(V,E) is a sequence of vertices v 1 , v 2 , . .., v N in V such that (v i , v i+1 ) is in E for all i = 1,. ..,N-1.
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### Page1 / 23

lec11 - Lecture 11 Graphs Vertices edges paths cycles...

This preview shows document pages 1 - 7. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online