Lecture 01 Graphs
Lecture 01 Graphs
Graphs
Extremely useful tool in modeling problems
Consist of:
Vertices
Vertices can be
Edges D considered “sites”
E
or locations.
C
A Edges represent
F connections.
B
Vertex
Edge
Graph & BFS / Slide 3
Application
Air flight system
Definition
A graph G=(V, E) consists a set of vertices, V, and a set of edges, E.
Each edge is a pair of (v, w), where v, w belongs to V
If the pair is unordered, the graph is undirected; otherwise it is directed
{a,b} {a,c}
{b,d} {c,d}
{b,e} {c,f}
{e,f}
An undirected graph
Graph & BFS / Slide 5
Terminology
1. If v1 and v2 are connected, they are said to be
adjacent vertices
v1 and v2 are endpoints of the edge {v1, v2}
Graph Variations
Variations:
A connected graph has a path from every vertex
to every other
In an undirected graph:
Edge (u,v) = edge (v,u)
No self-loops
In a directed graph:
Edge (u,v) goes from vertex u to vertex v, notated uv
Graph & BFS / Slide 7
Graph Variations
More variations:
A weighted graph associates weights with
either the edges or the vertices
E.g., a road map: edges might be weighted w/ distance