CISC 4080 — Computer Algorithms Spring, 2017 Note Spring/2017 1 What is graph? A graph is a set of vertices (or nodes) V , and a set of edges E between pairs of
- vertices. Graph represents some kind of binary relation among a set. If the relation is symmetric, then
the graph is undirected, meaing that edges have no direction. If the relation is not symmetric, then the graph is directed, and edges are represented as ordered pairs and drawn with an arraw on the line. So a directed graph G can be represented by G = (V, E), where V = {v1, v2, ..., vn}, E = {(vi, vj)|vi is connected to vj}. An undirected graph G can be represented by G = (V, E), where V = {v1, v2, ..., vn}, E = {{vi, vj}|vi is connected to vj and vice versa.} Exercise 1. Which can be represented as undirected graph, directed graph?
- Vertices: email addresses, edges: one address sendings email to another address
- vertices: cities and towns, edges: roads connecting cities and towns
- vertices: countries, edges: sharing a border
- vertices: courses, edges: one class is prerequisite of the other
- vertices: classes, edges: two classes are offered at same time block
- vertices: classes, edges: two claees are taught by same instructor
- vertices: Web sites, edges: a web site has a hyperlink to another site
- Game tree/graph where each vertex represents a game/puzzle configuration, and each edge rep-
resents that a single movecan take the game from one configuration to another
- and so on and on ...
Exercise 2: Can you draw the game tree/graph of tic-tac-toe game? Note that this graph can be generated by a program.