Docsity

Graphs, Lecture Notes - Computer Science, Study notes of Discrete Structures and Graph Theory

Partial preview of the text

Download Graphs, Lecture Notes - Computer Science and more Study notes Discrete Structures and Graph Theory in PDF only on Docsity!

Graphs

Zeph Grunschlag

Agenda – Graphs

Graph basics and definitions  Vertices/nodes, edges, adjacency, incidence  Degree, in-degree, out-degree  Degree, in-degree, out-degree  Subgraphs, unions, isomorphism  Adjacency matrices Types of Graphs  Trees  Undirected graphs  Simple graphs, Multigraphs, Pseudographs  Digraphs, Directed multigraph  Bipartite  Complete graphs, cycles, wheels, cubes, complete bipartite

Graphs – Intuitive Notion

A graph is a bunch of vertices (or nodes) represented by circles which are connected by edges, represented by line segments. Mathematically, graphs are binary-relations on their vertex set (except for multigraphs). In Data Structures one often starts with trees and generalizes to graphs. In this course, opposite approach: We start with graphs and restrict to get trees.

Trees

A very important type of graph in CS is

called a tree:

Real

Tree

Trees

A very important type of graph in CS is

called a tree:

Real

Tree transformation

Trees

A very important type of graph in CS is

called a tree:

Real Abstract

Tree transformation Tree

Simple Graphs

Vertices are labeled to associate with particular computers

Each edge can be viewed as the set of its two endpoints

1 2

3 4

{1,2}

{3,4}

{1,3} {2,3} {2,4}

{1,4}

Simple Graphs

DEF: A simple graph G = (V,E )

consists of a non-empty set V of

vertices (or nodes ) and a set E

(possibly empty) of edges where each

edge is a subset of V with cardinality 2

(an unordered pair).

Q: For a set V with n elements, how

many possible edges there?

Simple Graphs

A: The number of subsets in the set of

possible edges. There are n Ā· (n -1) / 2

possible edges, therefore the number of

graphs on V is 2^ n(n -1)/

Multigraphs

If computers are connected via internet instead of directly, there may be several routes to choose from for each connection. Depending on traffic, one route could be better than another. Makes sense to allow multiple edges, but still no self-loops:

Multigraphs

DEF: A multigraph G = (V,E,f ) consists

of a non-empty set V of vertices (or

nodes ), a set E (possibly empty) of

edges and a function f with domain E

and codomain the set of pairs in V.

Pseudographs

If self-loops are allowed we get a pseudograph:

Now edges may be associated with a single vertex, when the edge is a loop

e 1  {1,2}, e 2  {1,2}, e 3  {1,3},

e 4  {2,3}, e 5  {2}, e 6  {2}, e 7  {4}

1 2

3 4

e 1

e 3

e 2

e 4 e^5

e 6

e 7

Undirected Graphs

Terminology

Vertices are adjacent if they are the

endpoints of the same edge.

Q: Which vertices are adjacent to 1? How about adjacent to 2, 3, and 4?

1 2

3 4

e 1

e 3

e 2

e 4 e 5

e 6

Undirected Graphs

Terminology

A: 1 is adjacent to 2 and 3

2 is adjacent to 1 and 3 3 is adjacent to 1 and 2 4 is not adjacent to any vertex

1 2

3 4

e 1

e 3

e 2

e 4 e 5

e 6