CS 280 - Data Structures


Introduction to Graphs

Terminology

Graph

Directed graph (digraph)

Weighted graph

Some Notation

A graph, G, consists of a set of vertices, V, and edges, E where the edges are constructed from pairs of distinct vertices.

G = (V, E)
In an undirected graph, each edge is an unordered pair:
e = {v1, v2}
In a directed graph, each edge is an ordered pair:
e = (v1, v2)
and v1 is the origin (source) and v2 is the terminus (destination). Paths and Connectivity Cycles
Properties of Digraphs

For all nodes x in G, xGx is true:
Reflexive



For all nodes x in G, xGx is false:
Irreflexive



For some nodes x in G (but not all), xGx is true:
Neither reflexive nor irreflexive



For all nodes x and y in G, xGy and yGx is true:
Symmetric



For all nodes x and y in G, xGy and yGx is false:
Antisymmetric



For some nodes x and y in G (but not all), xGy and yGx is true:
Neither symmetric nor antisymmetric



For all nodes x, y, and z in G, if xGy and yGz then xGz:
Transitive



For all nodes x, y, and z in G, if xGy and yGz then not xGz:
Not transitive



Degree

Questions:
  1. How do directed and undirected graphs differ?
  2. What is a path in a graph? What is a cycle in a graph?
  3. What is a simple cycle?
  4. What is the in-degree and out-degree of a vertex in a directed graph?

Adjacency Matrix

A B
Graph A:
123456
1FTTTFF
2TFFFTF
3FFFFTF
4FFFTFF
5FFTFFT
6FFFFFT
 
123456
1056400
20FFFTF
30FFFTF
44FFTFF
50FTFFT
63FFFFT

Adjacency List


Traversals

  1. Describe differences between depth-first search and a bread-first search.
  2. How do stacks and queues relate to the search methods?