Graphs
Graphs
Programming
and
Problem Solving
Graphs
Graphs
Terminology
Definition (undiredted, unweighted):
◦ A Graph G, consists of
◦ a set of vertices, V
◦ a set of edges, E
◦ where each edge is associated with a pair of vertices.
We write: G = (V, E)
A labeled simple graph:
Vertex set V = {1, 2, 3, 4, 5, 6}
Edge set E = {{1,2}, {1,5}, {2,3},
{2,5}, {3,4}, {4,5}, {4,6}}.
Nodes
Edges
Undirected Graphs
Vertex A is adjacent to B,
but B is not adjacent to A.
Southern Illinois University
16
Graphs
Airline Routes
Note the graph with two subgraphs
Each subgraph connected
Entire graph disconnected
Three topological
orders for the
graph