1. Computer Science Division: CS304
Course CS304, Part:
“ALGORITHMIC COMBINATORICS 2 ”
( 3rd
Year Students )
Prepared by:
Dr. Ahmed AshryAhmed AshryAhmed Ashryhttp://www.researchgate.net/profile/Ahmed_Abdel-Fattah
Lecture #1
Dr. Ahmed Ashry “Algorithmic Combinatorics 2 ” for 3rd Year Students — Lecture #1 1 (of 25)
2. Computer Science Division: CS304
Course Description:
Algorithmic Combinatorics 2 consists of 2 subjects:
1 an introductory course on “graph theory” to make the students
familiar with graphs and basic theorems that give well-known,
important characterizations of famous graph types.
(Needed in many courses such as DS, DB, compilers design, parallel algorithms, etc.)
2 “constructive algorithmic combinaorics”, in which we study those
“algorithms” for listing fundamental objects in combinatorics.
(Theoretical study should have been given in 301Comp).
Course Material/References:
1 Text: Chapters 10 and 11 of Rosen, K. (2012) [Rosen, 2012]:
Discrete Mathematics and Its Applications (7th edition). McGraw-Hill.
2 Text: [Tucker, 2012, Bender and Williamson, 2013]
3 Lecture slides, practice assignments, and other supplementary material:
Disseminated over the internet.
Dr. Ahmed Ashry “Algorithmic Combinatorics 2 ” for 3rd Year Students — Lecture #1 2 (of 25)
3. Computer Science Division: CS304
Organizational Remarks1
1Image source: http://plus.google.com/+GawishElwarka/posts
Dr. Ahmed Ashry “Algorithmic Combinatorics 2 ” for 3rd Year Students — Lecture #1 3 (of 25)
4. Computer Science Division: CS304
Assessment: “Algorithmic Combinatorics 2” is worth 50% of CS304
Oral Examination (4% of CS304) [≡ 5 Marks]
Class Work (a.k.a. “Mid-term”) (16% of CS304) [≡ 20 Marks]
Final Examination (30% of CS304) [≡ 37.5 Marks]
Total (50% of CS304) [≡ 62.5 Marks]
Class Work is the new “Mid-Term”:
You will end up writing THREE computer programs!You will end up writing THREE computer programs!You will end up writing THREE computer programs!You will end up writing THREE computer programs!You will end up writing THREE computer programs!You will end up writing THREE computer programs!You will end up writing THREE computer programs!You will end up writing THREE computer programs!You will end up writing THREE computer programs!You will end up writing THREE computer programs!You will end up writing THREE computer programs!You will end up writing THREE computer programs!You will end up writing THREE computer programs!You will end up writing THREE computer programs!You will end up writing THREE computer programs!You will end up writing THREE computer programs!You will end up writing THREE computer programs!
1 Form teams of 2 to 4 students.
2 Select as many programs from the list in [Rosen, 2012, Pages 742 and 808].
Deadlines & Constraints:
Fri., 19-Feb.-2016 (between 10:00pm and 10:59pm CLT) Team formations &
program selections/assignments. Each 10 minutes of earlier
suggestions decrease 0.5 mark of your expected total.
Fri., 01-April-2016 (11:59pm CLT) Delivery of codes. Each 180 minutes of later
submissions decrease 0.5 mark of your expected total.
As usual, you can still earn bonus marks from HWs (6% max.) [≡ 7.5 Marks]
Dr. Ahmed Ashry “Algorithmic Combinatorics 2 ” for 3rd Year Students — Lecture #1 4 (of 25)
5. Computer Science Division: CS304
Codes of Honor
I, Ahmed Ashry, pledge my honor that I will:
1 Present the course material as correctly and completely as possible.
2 Answer all questions to the best of my knowledge.
3 Assess students fairly.
4 Treat everyone with respect.
5 Be there for everyone with academic support and experience
sharing.
6 Be always on time or apologize in advance, if I physically can.
Dr. Ahmed Ashry “Algorithmic Combinatorics 2 ” for 3rd Year Students — Lecture #1 6 (of 25)
6. Computer Science Division: CS304
Codes of Honor
I, 3rd Year Student: Your Name, pledge my honor that I will:
1 Do my best to learn the material presented in class.
2 Help myself by attempting to solve (additional) homework.
3 Help my fellow students with course material as much as I can.
4 Not receive nor give unauthorized assistance to fellow students in
exams.
5 Treat everyone with respect.
6 Be always on time (or apologize in advance, if I physically can).
Dr. Ahmed Ashry “Algorithmic Combinatorics 2 ” for 3rd Year Students — Lecture #1 6 (of 25)
7. Computer Science Division: CS304
“Graphs”: A Motivational Question
The Problem of Supplying 3 Houses with 3 Utilities.2
2For this and other motivational questions in graph theory, see next lectures.
Dr. Ahmed Ashry “Algorithmic Combinatorics 2 ” for 3rd Year Students — Lecture #1 7 (of 25)
8. Computer Science Division: CS304
“Graphs”: Meet the Concept
Conceptually, a graph consists of “points” and their connecting “links”.
The One Mathematical/Abstract Aspect that is:
indispensable in studying discrete mathematical structures,
linked to a plethora of disciplines in a variety of fundamental fields,
behind the modelling of many, many real-world situations,
used for developing many computer scientific applications,
easily representable and analysable by computers,
both extremely classical and very modern, and
. . . more!
Dr. Ahmed Ashry “Algorithmic Combinatorics 2 ” for 3rd Year Students — Lecture #1 8 (of 25)
9. Computer Science Division: CS304
Basics of Graph Theory:
(Finite) Graphs: a formal definition
1 A graph G is a pair G = ⟨V , E⟩ consisting of:
1 a finite set V ̸= ∅, called the vertex set of G, and
2 a set E of two-element subsets of V called the edge set of G.
2 v ∈ V is called a node (or vertex).
3 e = {u, v} ∈ E is an edge (u ̸= v), with end vertices u and v.
4 For an edge e = {u, v} ∈ E:
the end nodes u and v are incident with the edge e in G.
the end nodes u and v are adjacent in G.
We may use e = uv (short for e = {u, v}) if the context is clear.
5 The notations V (G) and E(G) are used to denote the vertex set
and the edge set of a graph G, respectively.
Graph Drawings:
Depictions (visualisations) of graphs using curves and points (in Rm
).
Dr. Ahmed Ashry “Algorithmic Combinatorics 2 ” for 3rd Year Students — Lecture #1 9 (of 25)
10. Computer Science Division: CS304
Drawings:
Let G = ⟨V , E⟩ be a graph, such that:3
V = {p, q, r, s, t, u}, and
E = {{p, q}, {p, s}, {q, r}, {q, t}, {s, u}}.
Here is one drawing of G:
p
q
r
s
t
u
Here is another (identical):
p
q
r
s
t
u
. . . and there can be many other (isomorphic) drawings for G!
3It is important to note that G can be directly given in the form:
G = ⟨{p, q, r, s, t, u}, {{p, q}, {p, s}, {q, r}, {q, t}, {s, u}}⟩.
Dr. Ahmed Ashry “Algorithmic Combinatorics 2 ” for 3rd Year Students — Lecture #1 10 (of 25)
11. Computer Science Division: CS304
(Concrete) Examples:
Shipping routes: Vertices are shipping hubs
Edges are routes between hubs.
Social networks: Vertices are people
Edges are social connections.
(e.g., e = {u, v} means u is a “friend” of v).
Telecommunications networks: Vertices are computers (on a network)
Edges are network connections between computers.
Disease transmission: Vertices are organisms (that carry the disease)
Edges represent one organism spreading it to another.
Dr. Ahmed Ashry “Algorithmic Combinatorics 2 ” for 3rd Year Students — Lecture #1 11 (of 25)
12. Computer Science Division: CS304
More (and yet More) Basics: Pseudographs
In a Multi-set . . .
elements can occur more than once, and each element has a multiplicity
to give the number of times it appears in the multi-set.
(Multiple) Parallel Edges and Multi-graphs:
Edges that have the same end vertices are parallel.
A graph is called a multi-graph if its edge set is a multi-set.
(i.e., if its edge set has parallel edges connecting the same 2 nodes)
Loops:
A loop is a self-connecting edge.
(That’s, an edge connecting a node to itself in the form {v, v}.)
Loop Graphs:
A loop graph is a graph with at least one loop.
Dr. Ahmed Ashry “Algorithmic Combinatorics 2 ” for 3rd Year Students — Lecture #1 12 (of 25)
13. Computer Science Division: CS304
More (and yet More) Basics:
Example:
A Graph G = ⟨V , E⟩ is called:
Null: if it has no vertices (V = ∅).
Dr. Ahmed Ashry “Algorithmic Combinatorics 2 ” for 3rd Year Students — Lecture #1 13 (of 25)
14. Computer Science Division: CS304
More (and yet More) Basics:
Example:
q
A Graph G = ⟨V , E⟩ is called:
Null: if it has no vertices (V = ∅).
Trivial: if it has only one node (|V | = 1).
Dr. Ahmed Ashry “Algorithmic Combinatorics 2 ” for 3rd Year Students — Lecture #1 13 (of 25)
15. Computer Science Division: CS304
More (and yet More) Basics:
Example:
p
q
r
s
t
u
A Graph G = ⟨V , E⟩ is called:
Null: if it has no vertices (V = ∅).
Trivial: if it has only one node (|V | = 1).
Empty: if it has no edges (E = ∅).
Dr. Ahmed Ashry “Algorithmic Combinatorics 2 ” for 3rd Year Students — Lecture #1 13 (of 25)
16. Computer Science Division: CS304
More (and yet More) Basics:
Example:
p
q
r
s
t
u
A Graph G = ⟨V , E⟩ is called:
Null: if it has no vertices (V = ∅).
Trivial: if it has only one node (|V | = 1).
Empty: if it has no edges (E = ∅).
Simple: if it has NEITHER a parallel edge NOR a loop.
Dr. Ahmed Ashry “Algorithmic Combinatorics 2 ” for 3rd Year Students — Lecture #1 13 (of 25)
17. Computer Science Division: CS304
More (and yet More) Basics:
Example:
p
q
r
s
t
u
A Graph G = ⟨V , E⟩ is called:
Null: if it has no vertices (V = ∅).
Trivial: if it has only one node (|V | = 1).
Empty: if it has no edges (E = ∅).
Simple: if it has NEITHER a parallel edge NOR a loop.
Pseudograph: if it has BOTH parallel edges AND a loop.
Dr. Ahmed Ashry “Algorithmic Combinatorics 2 ” for 3rd Year Students — Lecture #1 13 (of 25)
18. Computer Science Division: CS304
More (and yet More) Basics:
Vertex Degree:
The degree of a vertex counts the number of edges incident with it.
N.B. degG (v) denotes the degree of v ∈ V (G), for G = ⟨V , E⟩.
An isolated vertex v is a vertex with deg(v) = 0.
A pendant vertex v is a vertex with deg(v) = 1.
A loop is counted twice and parallel edges contribute separately.
Example:
p
q
rs
t
u
deg(u) = 1 (us is a pendant edge).
deg(p) = 2 (= deg(r) = deg(s)).
deg(t) = 3 (ACHTUNG!).
deg(q) = 4.
v∈V
deg(v) = 14 = 2 × |E|.
Dr. Ahmed Ashry “Algorithmic Combinatorics 2 ” for 3rd Year Students — Lecture #1 14 (of 25)
19. Computer Science Division: CS304
More (and yet More) Basics:
(p, q)-Graphs:
If G = ⟨V , E⟩ with |V | = p and |E| = q, the G is called a (p, q)-graph.
Order & Size:
The number p is called the order of G, and the number q is called the
size of G.
The symbols p(G) and q(G) denotes the order and the size of G,
respectively.
Regular Graphs:
A graph G is regular of degree n, if all its nodes have the same degree n.
Dr. Ahmed Ashry “Algorithmic Combinatorics 2 ” for 3rd Year Students — Lecture #1 15 (of 25)
20. Computer Science Division: CS304
Representations for Computer Programs
Dr. Ahmed Ashry “Algorithmic Combinatorics 2 ” for 3rd Year Students — Lecture #1 16 (of 25)
21. Computer Science Division: CS304
Graphs and Matrices: Part 0 – “The Adjacency Graph”
Assume that G = ⟨V , E⟩ is a graph with n = |V | vertices.
W.L.O.G., assume further that V (G) can be written as V = {vi }n
i=1.
The adjacency graph of G is the n × n square matrix [aij ]1≤i,j≤n
aij =
1 if {vi , vj } ∈ E(G)
0 if {vi , vj } ̸∈ E(G)
Example:
v1
v2
v3
v4
v5
v6
=⇒
⎡
⎢
⎢
⎢
⎢
⎢
⎢
⎣
0 1 0 1 0 0
1 0 1 0 1 0
0 1 0 0 0 0
1 0 0 0 0 1
0 1 0 0 0 0
0 0 0 1 0 0
⎤
⎥
⎥
⎥
⎥
⎥
⎥
⎦
Dr. Ahmed Ashry “Algorithmic Combinatorics 2 ” for 3rd Year Students — Lecture #1 17 (of 25)
22. Computer Science Division: CS304
Special (Simple) Graphs
Dr. Ahmed Ashry “Algorithmic Combinatorics 2 ” for 3rd Year Students — Lecture #1 18 (of 25)
23. Computer Science Division: CS304
Special Simple Graphs: Cycle Graphs
A simple graph G = ⟨V , E⟩ is a cycle if V can be written as
{v1, v2, · · · , vn}, and E = {{v1, v2} , {v2, v3} , · · · , {vn−1, vn} , {vn, v1}},
where n ≥ 3.
The cycle graph with n ≥ 3 nodes is denoted by Cn.
Examples:
Questions:
1 What is the degree of each vertex in Cn?
2 How many edges are there in Cn?
3 How does Cn’s adjacency matrix look like?
Dr. Ahmed Ashry “Algorithmic Combinatorics 2 ” for 3rd Year Students — Lecture #1 19 (of 25)
24. Computer Science Division: CS304
Special Simple Graphs: Path Graphs
A simple graph G = ⟨V , E⟩ is a path if V can be written as
{v1, v2, · · · , vn}, and E = {{v1, v2} , {v2, v3} , · · · , {vn−1, vn}}, where
n ≥ 2 (it can be drawn so that all vertices and edges lie on a single straight line).
The path graph with n ≥ 2 nodes is denoted by Pn.
Examples: Pn consists of 2 pendant nodes & n − 2 nodes of degree 2 .
Dr. Ahmed Ashry “Algorithmic Combinatorics 2 ” for 3rd Year Students — Lecture #1 20 (of 25)
25. Computer Science Division: CS304
Special Simple Graphs: Complete Graphs
A simple graph G = ⟨V , E⟩ is complete if it contains every possible edge
between all the vertices.
The complete graph with n ≥ 1 nodes is denoted by Kn.
Example:
K5
Questions:
1 What is the degree of each vertex in Kn?
2 How many edges are there in Kn?
3 How does Kn’s adjacency matrix look like?
Dr. Ahmed Ashry “Algorithmic Combinatorics 2 ” for 3rd Year Students — Lecture #1 21 (of 25)
26. Computer Science Division: CS304
Special Simple Graphs: Star Graphs
The star graph of order n is the complete bipartite graph K1,n.
The star graph of order n is denoted by Sn.
Example:
Here are the four star graphs, Si , for 3 ≤ i ≤ 6.
True or False?
Sn has exactly n pendant vertices, for n ≥ 1.
Dr. Ahmed Ashry “Algorithmic Combinatorics 2 ” for 3rd Year Students — Lecture #1 22 (of 25)
27. Computer Science Division: CS304
Special Simple Graphs: Wheels
A wheel on n ≥ 3 vertices is a simple graph with n + 1 vertices
v1, v2, . . . , vn, vn+1, where the first n vertices form the cycle Cn and the
(n + 1)st
vertex is connected by an edge to each of the first n vertices.
The wheel graph on n ≥ 3 nodes has a total of n + 1 nodes and is
denoted by Wn.
Dr. Ahmed Ashry “Algorithmic Combinatorics 2 ” for 3rd Year Students — Lecture #1 23 (of 25)
28. Computer Science Division: CS304
Assignment #1: (deadline: 19-February-2015, 11:59:59pm CLT)
Answer ALL the following:
(a)-Identify 2 Mistakes (according to the current lecture)
State why the following is NOT a well-defined graph G = ⟨E, V ⟩:
nodes: E = {m ∈ N − {0}}. (i.e., the set of all positive integers)
edges: V = {⟨m1, m2⟩ : m1 is odd and m2 is even}.
(i.e., two nodes are adjacent if the first is odd and the second is even)
(b)-Understanding Representations:
Let G = ⟨V , E⟩ be a graph given by the adjacency matrix [aij ]1≤i,j≤5,
where 1 ≤ i, j ≤ 5 and:
aij =
1 if i ̸= j
0 otherwise.
Give V (G), E(G), and a drawing of G.
Dr. Ahmed Ashry “Algorithmic Combinatorics 2 ” for 3rd Year Students — Lecture #1 24 (of 25)
29. Computer Science Division: CS304
References:
Bender, E. A. and Williamson, S. G. (2013).
Foundations of Combinatorics with Applications.
Dover Books on Mathematics. Dover Publications.
Rosen, K. (2012).
Discrete Mathematics and Its Applications (7th edition).
McGraw-Hill Education.
Tucker, A. (2012).
Applied Combinatorics, 6th Edition.
Wiley Global Education.
Dr. Ahmed Ashry “Algorithmic Combinatorics 2 ” for 3rd Year Students — Lecture #1 25 (of 25)