0% found this document useful (0 votes)
19 views13 pages

COM555 Theory of Computation: Graphs

This document provides information about graphs, including: 1) It defines directed and undirected graphs formally using sets of vertices and edges. 2) It explains the differences between directed and undirected graphs, such as edge order and representation. 3) Key graph theory concepts are defined, including paths, cycles, subgraphs, degrees, and properties like being connected vs disconnected. 4) Examples are given to illustrate graph definitions and properties.

Uploaded by

Kurdeen Khairy
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
19 views13 pages

COM555 Theory of Computation: Graphs

This document provides information about graphs, including: 1) It defines directed and undirected graphs formally using sets of vertices and edges. 2) It explains the differences between directed and undirected graphs, such as edge order and representation. 3) Key graph theory concepts are defined, including paths, cycles, subgraphs, degrees, and properties like being connected vs disconnected. 4) Examples are given to illustrate graph definitions and properties.

Uploaded by

Kurdeen Khairy
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 13

COM555

Theory of Computation
Lecture 3
Graphs

Assoc Prof Dr Melike Sah Direkoglu


[email protected]
Graphs
• Undirected graphs are used to represent
information and relationship between them.
1 1 2 All nodes
have
3 4 degree 3

All nodes 3 4
5 2 have
degree 2

• Number of edges at a particular node is the


degree of that node.
Formal Definition of Undirected Graphs

• In a undirected graph, G, G=(V,E), where V is


the set of nodes (or Vertices) of G, E is the set
of edges of G.
• In an undirected graph, the order of edges are
not important thus we represent edges with
sets.
Formal Definition of Undirected Graphs

3 4

5 2

• G=(V,E)=({1,2,3,4,5},{ {1,2}, {2,3}, {3,4}, {4,5},


{5,1} })
• In an undirected graph, pairs {i,j} and {j,i}
represents the same edge; such as {1,5} and
{5,1} are the same
Formal Definition of Undirected Graphs

1 2

3 4

• G=(V,E)=({1,2,3,4},{ {1,2}, {2,3}, {3,4},


{4,1}, {1,3}, {2,4} })
Formal Definition of Directed Graphs
1 2
6 3
5 4

• In a directed graph, G, G=(V,E), where V is the


set of nodes (or Vertices) of G, E is the set of
edges.
• In an directed graph, the order of edges are
important thus we represent an edge from i to
j as a pair (i,j).
Formal Definition of Directed Graphs
1 2
6 3
5 4

• G=(V,E)=({1,2,3,4,5,6},{ (1,2), (1,5), (2,1), (2,4),


(5,4), (5,6), (6,1), (6,3) })
• In an directed graph, the order of edges are
important, thus edge (6,3) and (3,6) are
different.
Outdegree/Indegree of Directed Graphs

• In a directed graph, the number of arrows


pointing from a particular node is the
outdegree and number of arrows pointing to a
particular node is the indegree of that node.

1 2 What is indegree of
node 1? Two
What is outdegree of
6 3 node 3? Zero
What is outdegree of
node 5? Two
5 4 What is indegree of
node 6? One
SubGraphs
• Subgraph G is a subgraph of H if the nodes of
G are a subset of the nodes of H, and edges of
G are the edges of H on the corresponding
nodes. H=({1,2,3,4,5},{(1,4),(1,5),
1 (2,1),(2,3),(3,1), (3,4),(5,2),
3 (5,4)})
2 G=({1,2,3,4},{(1,4),(2,1),
4 (3,1),(3,4)})
5
Path
• A path in a graph is a sequence of nodes
connected by edges.
– A path between the nodes 2-3-4
– Or a path between the nodes 1-5-2
1
3
2
4
5
Cycle
• A path is a cycle if it starts and ends in the
same node.
• A simple cycle contains at least three nodes
and repeats only the first and the last nodes.
1 1
3 3
2 2
4 4
5 5
Cycle 1-5-2-1 Cycle 2-1-3-4-5-2
Connected Graphs
• A graph is connected if every two nodes have
a path between them

1 1
3 3
2 2
4 4
5 5
Connected graph Disconnected graph
Trees
• A graph is a tree if it is connected and has no
simple cycles.
1

2 5 3

7 4 6
8 9 Connected and no
simple cycles

You might also like