0% found this document useful (0 votes)
8 views50 pages

Logic, Proofs, Sequences, Graphs, Trees-1

The document discusses propositions, logical operators, and their applications in logic and mathematics. It covers the definitions of atomic and compound propositions, truth tables, logical equivalences, conditionals, predicates, quantifiers, and rules of inference. Additionally, it explains common sets and various proof techniques used in mathematical reasoning.

Uploaded by

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

Logic, Proofs, Sequences, Graphs, Trees-1

The document discusses propositions, logical operators, and their applications in logic and mathematics. It covers the definitions of atomic and compound propositions, truth tables, logical equivalences, conditionals, predicates, quantifiers, and rules of inference. Additionally, it explains common sets and various proof techniques used in mathematical reasoning.

Uploaded by

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

Propositions & Logic

Proposition is a declarative sentence (that is, one that declares a fact) that is either true
or false, but not both.

Examples of propositions
can be true
Britain is a part of Europe
22 = 4
can be false - still a valid proposition
Earth is the nearest planet to the sun
22 = 10
not-propositions
x + 2 = 10 is not a proposition because it depends on x
“Please give me some water” is not a proposition because it is not a declarative
sentence - it is a request
“This statement is false” is a paradox - it is neither true, nor false
“I always tell lies” is a paradox - it is neither true, nor false
“What is the color of the sky” is a question, not a declarative sentence

Atomic propositions are propositions that can not be further divided into different
propositions.
example: p : India is a country

Compound propositions are propositions that are formed by combining one or more
atomic propositions using connectives.
example: q : India is a country, and it is a part of Asia
Logical Operators / Connectives

Truth Table The truth table shows the output for each possible truth value of inputs.

For k variables, the truth table will have 2k rows (since each variable has 2 possibilities -
T / F)

Connectives are the operators that are used to combine one or more propositions.

Negation / Not (¬)

Example

p : It is snowing today
¬p : It is not snowing today

q : x is less than 10 (that is, x < 10)


¬q : x is more than 10, or x is equal to 10 (that is, x ≥ 10)

Truth Table

p ¬p

F T

T F
Conjunction / And (∧)

Similar to multiplication (⋅)

Example

p : It is snowing today
q : John is carrying an umbrella
p ∧ q : It is snowing today, and John is carrying an umbrella

Truth Table

p q p∧q

F F F

F T F

T F F

T T T
Disjunction / Or (∨)

Similar to addition (+)

Example

p : I’m watching a movie


q : I’m eating
p ∧ q : I’m watching a movie or I’m eating (note - both together is possible for
OR)

Truth Table

p q p∨q

F F F

F T T

T F T

T T T
Logical Equivalences (≡)

p∧T ≡p p⋅1=p Identity

p∨F ≡p p+0=p (no effect)

p∨T ≡T p+1=1 Domination

p∧F ≡F p⋅0=0

p∨p≡p p+p=p Idempotence

p∧p≡p p⋅p=p (repetition doesn’t matter)

¬(¬p) ≡ p p=p Double Negation

p∨q ≡q∨p p+q =q+p Commutative

p∧q ≡q∧p p⋅q =q∧p (can shuffle things if same operator)

(p ∨ q) ∨ r ≡ p ∨ (q ∨ r) (p + q) + r = p + (q + r) Associative
​ ​ ​ ​

(p ∧ q) ∧ r ≡ p ∧ (q ∧ r) (p ⋅ q) ⋅ r = p ⋅ (q ⋅ r)

p ∨ (q ∧ r) ≡ (p ∨ q) ∧ (p ∨ r) p + qr = (p + q) ⋅ (q + r) Distributive

p ∧ (q ∨ r) ≡ (p ∧ q) ∨ (p ∧ r) p ⋅ (q + r) = pq + pr

¬(p ∧ q) ≡ ¬p ∨ ¬q p⋅q =p+q


​ ​ ​ De-Morgan’s

¬(p ∨ q) ≡ ¬p ∧ ¬q p+q =p⋅q ​ ​ ​ (break the line, change the sign)

p ∨ (p ∧ q) ≡ p p + pq = p Absorption

p ∧ (p ∨ q) ≡ p p ⋅ (p + q) = p

p ∨ ¬p ≡ T p+p=1 ​ Negation

p ∧ ¬p ≡ F p⋅p=0 ​
premise conclusion
Conditionals ( p ​ → q )

p implies q q if p

if p, then q q whenever p

p is sufficient for q q unless ¬p

p only if q q is necessary for p

q follows from p

q provided that p

Tautology always true

Contradiction always false

Contingency sometimes true, sometimes false

p→q implication

¬q → ¬p contrapositive

(p → q) ≡ (¬q → ¬p) implication ≡ contrapositive

​ ​ ​

q→p converse

¬p → ¬q inverse

(q → p) ≡ (¬p → ¬q) converse ≡ inverse


Conditional Equivalences (≡)

p→q ≡ ¬p ∨ q implication to connectives

p→q ≡ ¬q → ¬p implication ≡ contrapositive

q→p ≡ ¬p → ¬q converse ≡ inverse

(p → q) ∧ (p → r) ≡ p → (q ∧ r)

(p → q) ∨ (p → r) ≡ p → (q ∨ r)
​ ​ ​ ​ ​

(p → q) ∧ (q → r) ≡ (p ∨ q) → r

(p → q) ∨ (q → r) ≡ (p ∧ q) → r

p ⟺ q ≡ (p → q) ∧ (q → p) bi-implication

p ⟺ q ≡ (p ∧ q) ∨ (¬p ∧ ¬r) (if and only if)

p ⟺ q ≡ pq + pˉqˉ
​ ​ (equivalent)
Predicates & Quantifiers

Predicate: a proposition about some object(s)


P (x) : x < 10
P (a, b, c) : a2 + b2 = c2
P (x) : x is a student
Domain/Universe of Discourse: all possible values of the variable(s) under
consideration
U = all integers
U = all students
U = everything
Quantifiers: convert predicates into propositions about the universe

Universal Quantifier - ForAll (∀)

∀x : P (x) means that P (x) is true for all values of x ∈ U

Prove: must show that it is true for all values


Disprove: find 1 counterexample

Examples:

All students are hard-working


U = all students
∀x : hardworking(x)
U = everthing
∀x : student(x) → hardworking(x)
All that glitters is not gold
U = everything
¬(∀x : Glitter(x) → Gold(x))

To combine multiple facts, we always use implication (→) with forall (∀)
Existential Quantifier - Exists (∃)

∃x : P (x) means that P (x) is true for at least 1 value of x ∈ U (there might be more
for which it is true, but at least 1)

Prove: find 1 evidence


Disprove: must show that it is false for all values

Examples:

Some students are hard-working


U = all students
∃x : hardworking(x)
U = everthing
∃x : student(x) ∧ hardworking(x)
All that glitters is not gold
U = everything
∃x : Glitter(x) ∧ ¬Gold(x)
Nested Quantifiers

if all quantifiers are same, then order does not matter


if quantifiers are different, then order matters

Examples

every number except 0 has a multiplicative inverse

∀x : [x =
 0 → (∃y : x ⋅ y = 1)]

every number except 0 has exactly 1 multiplicative inverse

∀x : [x =
 0 → ∃y : (x ⋅ y = 1 ∧ [¬∃z : (y =
 z ∧ x ⋅ z = 1)])]

definition of rational numbers

∀x : [Rational(x) ⟺ ∃p∃q : (x = p/q, p, q ∈ Z, q =


 0, gcd(p, q) =

1)]

definition of even numbers

∀x : [Even(x) ⟺ ∃k : (x = 2 ⋅ k, k ∈ Z)]

De-Morgan’s Law

move the negation inwards, and change the quantifier

¬∃x : P (x) ≡ ∀x : ¬P (x)


no student is short ≡ all students are tall

​ ​ ​ ​

¬∀x : P (x) ≡ ∃x : ¬P (x)


not all students are rich ≡ there is some poor student
Rules of Inference

Rules of inference Tautology Name

p
p→q ​
(p ∧ (p → q)) → q Modus ponens
∴q ​

¬q
p→q ​
(¬q ∧ (p → q)) → ¬p Modus tollens
∴ ¬p ​

p→q
q→r ​
((p → q) ∧ (q → r)) → (p → r) Hypothetical syllogism
∴p→r ​

p→q
(p → q) → (p → (p ∧ q)) Absorption (logic)
∴ p → (p ∧ q)

p
q ​
((p) ∧ (q)) → (p ∧ q) Conjunction introduction
∴p∧q ​

p∧q
(p ∧ q) → p Conjunction elimination
∴p

p
p → (p ∨ q) Disjunction introduction
∴p∨q

p→q
r→q ((p → q) ∧ (r → q) ∧ (p ∨
Disjunction elimination
p∨r r)) → q

∴q ​

p∨q
¬p ​
((p ∨ q) ∧ ¬p) → q Disjunctive syllogism
∴q ​

p∨p
(p ∨ p) → p Idempotency
∴p

p∨q
¬p ∨ r ​
((p ∨ q) ∧ (¬p ∨ r)) → (q ∨ r) Resolution (logic)
∴q∨r ​

p→q
Biconditional
q→p ​
((p → q) ∧ (q → p)) → (p ↔ q)
introduction
∴p↔q ​
Common Sets

Naturals (N) {1, 2, 3, 4 …}

Whole (W) {0, 1, 2, 3, 4 …} = N ∪ {0}

Integers (Z) {… − 3, −2, −1, 0, 1, 2, 3, 4 …}

Positive
{1, 2, 3, 4 …} = N
Integers (Z+ )

Negative
{−1, −2, −3 …}
Integers (Z− )

Non-Negative
{0, 1, 2, 3 …} = Z+ ∪ {0}
Integers

Whole (W) {0, 1, 2, 3, 4 …} = N ∪ {0}


p
x is rational iff it can be written as x = where p, q ∈ Z and

q
Rationals (Q) q=
 0 and gcd(p, q) = 1 (that is, it can be converted to its
lowest terms)

Irrationals (I) x is irrational iff it is not rational

Reals (R) all numbers on the number line = Q∪I

Even n is even iff it can be written as n = 2k where k ∈ Z

Odd n is odd iff it can be written as n = 2k + 1 where k ∈ Z

Perfect Square n is a perfect square iff it can be written as n = k 2 where k ∈ Z


Proofs

Theorem statement which can be shown to be true

Axiom/Postulate statements we assume to be true

less important theorem that is helpful in the proof of other


Lemma
results

theorem that can be established directly from a theorem that


Corollary
has been proved

statement that is being proposed to be a true statement,


usually on the basis of some partial evidence, a heuristic
argument, or the intuition of an expert.
Conjecture When a proof of a conjecture is found, the conjecture becomes
a theorem.
Many times conjectures are shown to be false, so they are not
theorems.

Proof for p → q is vacuous if p is always false (nothing to


Vacuous Proof
prove)

Trivial Proof Proof for p → q is trivial if q is always true (obvious to prove)


Direct Proofs

to show p →q
assume that p is true
use axioms, definitions, and previously proven theorems, together with rules of inference
show that q must also be true

Example 1: Prove that "If n is an odd integer, then n2 is odd.

Direct Proof
Without loss of generality, consider an odd number n.
By definition of odd, we can write n as n = 2k + 1, k ∈ Z

Consider n2 . We can write it as

n2 = (2k + 1)2

= 2 ⋅ (2k 2 + 2k) + 1
​ ​ ​

= 2m + 1 {m = 2k 2 + 2k

Therefore, n2 is also odd


Example 2: Prove that if m and n are both perfect squares, then nm is also a
perfect square

Direct Proof
Consider two perfect squares m and n.

By the definition of a perfect square, we can write m = s2 and n = t2 where s, t ∈ Z

Consider nm. We can write as

nm = s2 × t2


= (st)2 ​ ​

= k2 {k = st

Therefore, nm is also a perfect square



Proof by Contraposition

to show p →q
use the contrapositive ¬q → ¬p, since it is equivalent to the implication
show that the contrapositive is true

Example 1: Prove that if n is an integer and 3n + 2 is odd, then n is odd.

Proof by Contraposition

Contrapositive: if n is even, then 3n + 2 is even

Consider an even number n. By definition, we can write n as n = 2k, k ∈ Z

Therefore,

3n + 2 = 3 ⋅ (2k) + 2

= 6k + 2

= 2 ⋅ (3k + 1)
​ ​ ​

= 2m {m = 3k + 1

Therefore, 3n + 2 is also even.


Example 2: Prove that if n = ab, where a and b are positive integers, then a ≤ n or

b≤ n ​

Proof by Contraposition

Contrapositive (using De-Morgan’s law):


"if a and b are positive integers such that (a > n) AND (b >
​ n), then n =
​  ab"

Consider two positive integers number a > n and b >


​ n.

Then,

ab = ( n + δ1 ) ⋅ ( n + δ1 )
​ ​ ​ ​ {δ1 > 0, δ2 > 0
​ ​

​ =n+ n ⋅ (δ1 + δ2 )
​ ​ ​ ​

>n

Therefore, ab n
=

Proof by Contradiction

to prove p
assume (for the sake of contradiction) that p is false
show that this assumption leads to a contradiction
hence, p must be true

Example 1: Prove that 2 is irrational


Proof by Contradiction

Assume, for the sake of contradiction, that 2 is rational.


By definition of rational, we should be able to write it as


⎧p, q ∈ Z
2 = p/q, where ⎨q =0

​ ​ ​

gcd(p, q) = 1

Now,

p2
2= squaring both sides
q2

2q 2 = p2
​ ​ ​

Therefore, we have that p2 is even, which means that p is even (by Lemma 1)

Lemma 1: if p2 is even, then p must be even

Proof by contraposition: (p is odd) → (p2 is odd)


Consider an odd number p
By definition of off, we can write p = 2k + 1, k ∈ Z
Now,

p2 = (2k + 1)2


= 2(2k 2 + 2) + 1 ​ ​

= 2m + 1 {m = 2k 2 + 2

Therefore, p2 is odd

Therefore,

2q 2 = p2

2q 2 = (2m)2
​ ​ {∵ p is even ​

q 2 = 2m2

Therefore, q 2 is even, which means that q is also even (by Lemma 1)

Thus, gcd(p, q) = 2, which is a contradiction.


Proof by Constructive Evidence

to show ∃x : P (x)
find evidence for x which satisfies P (x)

Example 1: Prove that ∃a, b, c ∈ Z : a 2 + b2 = c 2

Proof by Constructive Evidence

Let a = 3, b = 4, c = 5
Then,

a2 + b2 = 32 + 42
= 25 ​ ​

= c2

Proof by Non-constructive Evidence

to show ∃x : P (x)
do some magic! (no other way to put it)

Example 1: Show that there exist irrational numbers x and y such that xy is rational.

Proof by Non-constructive Evidence

We know that 2 is irrational


2
Consider n = 2 . Two cases arise.

2
Case 1: n = 2 is rational

In this case, we’ve found two irrational numbers x = 2 and y =


​ 2 such that xy is rational.

2
Case 2: n = 2 is irrational

2
Let x = 2 and y = 2.

​ ​

2
=( 2 )
2 2⋅ 2 2

Then, xy = ( 2) = 2 = 2, which is rational


​ ​ ​

​ ​ ​


Mathematical Induction

Does infinite proofs in 1


Similar to recursion
3 step process
1. Induction hypothesis H(n)
2. Base cases: H(n0 ), H(n1 ), …
​ ​

3. Induction Step: H(n) → H(n + 1)

n(n + 1)
Example 1 - Prove that 1 + 2 + 3 + ⋯ + n =
2

Proof by Induction

n(n + 1)
Induction Hypothesis: H(n) :1+2+3+⋯+n= ,n ∈ N
2

Base Cases:

1(1 + 1)
1= . Therefore, H(1)✓
2

2(2 + 1)
1+2=3= . Therefore, H(2)✓
2

3(3 + 1)
1+2+3=6= . Therefore, H(3)✓
2

Inductive Step: To show H(n) → H(n + 1)

1 + 2 + 3 + ⋯ + n + (n + 1)

= [1 + 2 + 3 + ⋯ + n] + (n + 1)

=[ ] + (n + 1)
n(n + 1)
{∵ H(n)
2

​ ​ ​

(n + 1) ⋅ (n + 2)
=
2

∴ H(n + 1)


Strong Induction

similar to induction
assume everything below in the Induction Step

(H (n0 ) ∧ H(n1 ) ∧ ⋯ ∧ H (n)) → H(n + 1)


​ ​

Example 1 - Show that if n is an integer greater than 1, then n can be written as the
product of primes

Proof by Strong Induction

Induction Hypothesis: H(n) : n = pα1 1 ⋅ pα2 1 ⋯ pαk 1 where pi are prime numbers, and αi ∈ W



​ ​ ​

Base Cases:

2 = 21 . Therefore, H(2)✓

3 = 31 . Therefore, H(3)✓

4 = 22 . Therefore, H(4)✓

5 = 51 . Therefore, H(5)✓

6 = 21 ⋅ 31 . Therefore, H(6)✓

Inductive Step: To show (H(n0 ) ∧ H(n1 ) ∧ ⋯ ∧ H(n))


​ ​ → H(n + 1)

Consider the number (n + 1). Since n + 1 > 1, two cases arise.

Case 1: (n + 1) is prime
Here, we already have (n + 1) = (n + 1)1 .
Case 2: (n + 1) is composite
By definition of compositie, we can write (n + 1) = ab where a, b ∈ N and a < n + 1 and b <
n+1
Now,

n + 1 = ab

= (pα1 1 ⋅ pα2 2 ⋯ pαk k ) ⋅ (q1β1 ⋅ q2β2 ⋯ qkβk ) {∵ H(a), H(b)


​ ​ ​

​ ​ ​
​ ​ ​

​ ​ ​ ​ ​ ​ ​ ​

a
b

Therefore, (n + 1) can be written as a product of prime numbers.


Sequences and Sums

⟨a0 , a1 , a2 … an ⟩
​ ​ ​ ​

a0 = first term

an = n-th term

$n = $ number of terms
sequences are always ordered

Arithmetic Progression (AP)

a, (a + d), (a + 2d) … a + (n − 1)d

d = common difference

[a + (n − 1)d] is the n-th term of AP

Sum of first n terms of AP

n n−1
∑ a + (i − 1)d
​ = ∑ a + id

i=1 i=0
n
= [2a + (n − 1)d]
2

​ ​

n
= [first term + last term]
2

Geometric Progression (GP)

a, ar, ar2 … arn−1

r = common ratio

arn−1 is the n-th term of GP

Sum of first n terms of GP

n n−1
rn − 1
∑ ar i−1
= ∑ ari = a
r−1
​ ​ ​

​ ​

i=1 i=0

Sum of ∞ terms of GP

Only when ∣r∣ <1



a
∑ ari =
1−r
​ ​

i=0
Useful Summations

n(n + 1)
1+2+3+⋯+n =
2

(n + 1) (2n + 1)
12 + 22 + 32 + ⋯ + n2 = n⋅ ⋅
2 3
​ ​

n(n + 1)(2n + 1)
=
6

2
n(n + 1)
3
1 +2 +3 +⋯+n 3 3 3
= [ ]
2

1 + 2 + 4 + 8 + ⋯ + 2n = 2n+1 − 1
​ ​

3n+1 − 1
1 + 3 + 9 + 27 + ⋯ + 3n =
2

1 1 1
1+ + + + ⋯ ∞ terms = 2
2 4 8
​ ​ ​

1 1 1 1
1+ + + +⋯ ≈ loge n
2 3 4
​ ​ ​ ​ ​

n
Graphs

G = (V , E), where V are vertices, E are edges, G is graph

Types of graphs

Type edges? self-loops? multi-edges? V vs E example

v(v − 1)
Simple undirected No No 0≤e≤
2

Simple Directed directed No No 0 ≤ e ≤ v(v − 1)

Multi undirected No Yes 0≤e≤∞

Multi Directred directed Yes Yes 0≤e≤∞

v(v + 1)
Pseudo undirected Yes Yes 0≤e≤
2

Mixed directed + undirected Yes Yes 0≤e≤∞

If the edges have weights associated with them, then we call it a weighted graph (weighted simple undirected, weighted simple directed,
weighted mixed, …)
Basic Graph Definitions

Adjacent Vertices / in undirected graph, vertices a and b are adjacent if they’re


Neighbors connected by an edge

Incident edge e is incident on vertices a and b if it connects them

Adjacency / Neighborhood(a) = the set of all vertices that are adjancent to


Neighborhood a

in undirected graphs, degree(a) = number of vertices adjancent


Degree
to it.
deg(vi )
self-loops count as 2 degree for undirected.

in directed graphs, in-degree(a) = number of incoming edges


In-Degree
− self-loops provide both 1 in-degree and 1 out-degree (total
deg (vi )
contribution of 2)

in directed graphs, out-degree(a) = number of outgoing edges


Out-Degree
+ self-loops provide both 1 in-degree and 1 out-degree (total
deg (vi )
contribution of 2)

Degree Sequence sequence of degrees of the graph

Isolated Vertex vertex with degree 0

Pendant Vertex vertex with degree 1

Initial / Start Vertex For a directed edge (a, b) from a to b, the initial vertex is a

Terminal / End Vertex For a directed edge (a, b) from a to b, the initial vertex is b
Basic Graph Theorems

For any undirected graph G = (V , E), with e edges,

Handshaking
2e = ∑ degree(vi )
​ ​

vi ∈ V
Theorem

This applies even for multi-edges and self loops.


Self loops count as 2 degree

An undirected graph has an even number of vertices of


Collolary 1
odd degree.

For any directed graph G = (V , E), with e edges,

Directed e = ∑ in-degree(vi ) = ∑ out-degree(vi )


​ ​ ​ ​

Handshaking vi ∈ V
​ vi ∈ V

Theorem
This applies even for multi-edges and self loops.
Self loops count as 2 degree
Special Graphs

Type Meaning Examples Property

Simple v=n
Complete
undirected
Graph n(n − 1)
graph with all e=
Kn 2

possible edges

Cycle v=n
a closed loop
Cn ​
e=n

add a center
Wheel vertex to the v =n+1
Wn ​ cycle and add e = 2n
spokes

Hypercube
n-dimensional v = 2n
(n-cube)
hypercube e = n ⋅ 2n−1
Qn ​
Bi-partite Graphs

vertex set V can be partitioned into two disjoint sets V1 and V2 such that there
​ ​

are no internal edges inside V1 or inside V2


​ ​

Complete Bi-Partitle Graph has all possible edges from V1 to V2


​ ​

Theorem: A simple graph is bipartite if and only if it is possible to assign one of two
different colors to each vertex of the graph so that no two adjacent vertices are
assigned the same color.
Matching

definition: Matching M in a simple graph G = (V , E) is a subset of the set E of


edges of the graph such that no two edges are incident with the same vertex. In other
words, a matching is a subset of edges such that if s, t and u, v are distinct edges of the
matching

Rules of Matching

think of it like marriages b/w boys and girls


1 boy cannot marry multiple girls, and 1 girl cannot marry muktiple boys (no
polygamy)
Some boy / girl can remain un-married

Matching can also be in a non-biartite graph


Matching definitions

Matched vertex got married to someone

Unmatched vertex left unmarried

every boy got married


Complete/Perfect
(some girls might remain
Matching
unmarried)

we have maximized the


Maximum Matching
number of marriages

we can’t add more


Maximal Matching
marriages

Hall’s Marriage Theorem

The bipartite graph G = (V , E) with bipartition (V1 , V2 ) has a complete matching


​ ​

from V1 to V2 if and only if ∣N (A)∣ ≥ ∣A∣ for all subsets A ⊂ V1 .


​ ​ ​
Subgraphs

A subgraph of a graph G = (V , E) is a graph H = (W , F ), where W ⊆ V and


F ⊆ E.

Proper Subgraph: A subgraph H of G is a proper subgraph of G if H G


=

Induced Graph

The subgraph induced by a subset W of the vertex set V is the graph (W , F ), where
the edge set F contains an edge in E if and only if both endpoints of this edge are in
W.

Graph Union

The union of two simple graphs G1 = (V1 , E1 ) and G2 = (V2 , E2 ) is the simple
​ ​ ​ ​ ​ ​

graph with vertexset V1 ∪ V2 and edge set E1 ∪ E2 . The union of G1 and G2 is


​ ​ ​ ​ ​ ​

denoted by G1 ∪ G2
​ ​
Adjacency List Representation

Prefered for Sparse Graphs


checking adjacency of 2 vertices is expensive: O(v)
is space efficient: O(v + e)

Undirected

Directed
Adjacency Matrix Representation

Prefered for Dense Graphs


checking adjacency of 2 vertices is fast: O(1)
takes a lot of space: O(v 2 )

Undirected

Adjacency matrix is always symmetric for undirected graphs


Diagonal is always zero for simple graphs (because no self loops)
Incidence Matrix Representation

useful for multi-graphs


represents which edges are inceident on which vertices
Graph Isomorphism

two graphs are isomorphic if they can be re-drawn to look the same
The simple graphs G1 = (V1 , E1 ) and G2 = (V2 , E2 ) are isomorphic if
​ ​ ​ ​ ​ ​

there exists a one-to-one and onto function f : V1 → V2 with the property


​ ​

that a and b are adjacent in G1 if and only if f (a) and f (b) are adjacent in

G2 , for all a, b ∈ V1 .
​ ​

Such a function f is called an isomorphism.


Two simple graphs that are not isomorphic are called nonisomorphic.

Example
Graph Connectivity - basic definitions


A path p= v → u of length n from u to v in G is a sequence of n edges e1 , … , en such that there exists a
Path
​ ​

sequence x0 = u, x1 , … , xn−1 , xn = v of vertices such that ei has the endpoints xi−1 and xi .
​ ​ ​ ​ ​ ​ ​

Simple Path path which does not contain the same edge more than once.

Circuit The path is a circuit if it begins and ends at the same vertex, that is, if u = v , and has length greater than zero

Simple Circuit circuit which does not contain the same edge more than once.

Connected Graph An undirected graph is called connected if there is a path between every pair of distinct vertices of the graph.

Disconnected
An undirected graph that is not connected is called disconnected.
Graph

Strongly Connected ∗ ∗
there is a path a → b and a path b → a for all vertices a, b ∈ V
Graph

Weakly Connected
A directed graph is weakly connected if the underlying undirected graph is connected
Graph

Theorem: There is a simple path between every pair of distinct vertices of a connected undirected graph.
Graph Connectivity - measures

Connected
a subgraph which is connected
Components

Strongly Connected ∗ ∗
there is a path a → b and a path b → a for all vertices a, b ∈ V
Components

Cut Vertex /
vertex which when removed makes a connected graph disconnected
Articulation Point

Vertex Cut set of vertices, which on removal make the connected graph disconnected

Cut Edge / Bridge edge which when removed makes a connected graph disconnected

Edge Cut set of edges which on removal make a connected graph disconnected

Non-Separable Graph graph with no cut-vertex

Vertex Connectivity: κ(G) is the minimum number of vertices that you need to remove to make the
κ(G) graph disconnected or to make the get a graph with a single vertex

Edge Connectivity: λ(G) is the minimum number of edges that you need to remove to make the
λ(G) graph disconnected

Relation b/w Edge and Vertex Connectivity

κ(G) ≤ λ(G) ≤ min deg(v) ​

v∈V
Euler Paths & Circuits

simple path containing every edge of G


Euler path ∙ repeating vertices is allowed
∙ repeating edges is not allowed

Euler path which has same start and end vertex


Euler Circuit
(closed loop)

Necessary & Sufficient Conditions:

Euler Circuit: all vertices must have even degree


Euler Path but not circuit: exactly 2 vertices with odd degree
Hamiltonian Paths & Circuits

simple path that passes through every vertex exactly once


Hamiltonian path ∙ repeating vertices is not allowed
∙ repeating edges is not allowed

Hamiltonian Circuit | Hamiltonian path which has same start and end vertex
Note: only the start/end vertex is repeated

Necessary & Sufficient Conditions:

Not known

Sufficient Conditions

if any condition matches, a Hamiltonian path exists. But it is not necessary that
every graph with a Hamiltonian path must satisfy these conditions
Dirac’s Theorem: If G is a simple graph with n vertices with n ≥ 3 such
that the degree of every vertex in G is at least n∕2, then G has a Hamilton
circuit.
≥ 3 such that
Ore’s Theorem: If G is a simple graph with n vertices with n
deg(u) + deg(v) ≥ n for every pair of nonadjacent vertices u and v in G,
then G has a Hamilton circuit.
Planar Graphs

A graph is called planar if it can be drawn in the plane without any edges crossing
otherwise, non-planar

Minimal Non-Planar graphs

Min Vertices: K5 ​
Min Edges: K3,3 ​
Euler’s Formula for Planar graphs

Connected

r = e−v + 2

r is the number of regions / faces


e is the number of edges
v is the number of vertices

General

r = e−v + k + 1

k is the number of connected components

Corrolary 1

For connected planar simple graph with more than 3 vertices, e ≤ 3v−6

Corrolary 2

A connected planar simple graph has a vertex of degree not exceeding five.

Corrolary 3

If a connected planar simple graph has e edges and v vertices with v ≥ 3 and no
circuits of length three, then e ≤ 2v−4
Kuratowski’s Theorem

A graph is nonplanar if and only if it contains a subgraph homeomorphic to K3,3 or K5 .


​ ​
Graph Coloring

Coloring of a simple graph: color each vertex so that no two adjacent vertices are
assigned the same color
Chromatic number χ(G): least number of colors needed for a coloring of this
graph

4 color theorem

The chromatic number of a planar graph is no greater than four.

all planar graphs have χ(G)≤4


non-planar graph can have χ(G) ≤ 4 - example, all bipartite graphs have
χ(G) = 2 irrespective of whether they’re planar or not

Note: all 2d maps are planar


Trees

A tree is a connected undirected graph with no simple circuits (no cycles)


A tree is a connected, acyclic graph

Theorem

An undirected graph is a tree if and only if there is a unique simple path between any
two of its vertices.
Forest

a graph with many disconnected trees

Rooted Tree

A rooted tree is a tree in which one vertex has been designated as the root and every
edge is directed away from the root.

Root Top vertex of a rooted tree

Internal vertex which has children


Vertex (includes root if the root has children)

vertex with no children


Leaf Vertex (doesn’t have to be at the bottom - can be present at a higher
level)
m−ary tree & full m-ary tree

m−ary: A rooted tree is called an m-ary tree if every internal vertex has no more than m
children.
Binary tree: m =2
Ternary tree: m = 3
full m−ary: The tree is called a full m-ary tree if every internal vertex has exactly m children.

Tree properties

A tree with n vertices has n−1 edges.

A full m−ary tree with i internal vertices contains n = mi + 1 vertices.

A full m−ary tree with

n−1 (m−1)⋅n+1
n vertices has i = m
internal vertices and
​ l= m
​leaves

each vertex except the root has a parent, and each parent has exactly m children

i internal vertices has n = mi + 1 vertices and l = (m−1) ⋅ i + 1 leaves

each internal vertex has m children, and there is also a root

l leaves has n = ml−1


m−1
vertices and
​ i= l−1
m−1
internal vertices

l leaves + l
m ​ parents + l
m2 ​ grandparents + ⋯ + 1 root
Spanning Trees

Tree containing all vertices of the graph

All possible spanning trees for graph G have the same number of edges and vertices.

Spanning trees do not have any cycles.

A Spanning tree is a minimally connected sub-graph, which means if we remove any edge
from the spanning tree then it becomes disconnected.

A Spanning tree is a maximally acyclic sub-graph, which means if we add an edge to the
spanning tree then it becomes cyclic.

A connected graph G can have more than one spanning tree.

A Spanning tree always contains n − 1 edges, where n is the total number of vertices in the
graph G.

The total number of spanning trees that a complete graph of n vertices can have is nn−2 .

We can construct a spanning tree by removing atmost e − n + 1 edges from a complete


graph G

Theorem

A simple graph is connected if and only if it has a spanning tree.


Minimum Spanning Tree

A minimum spanning tree in a connected weighted graph is a spanning tree that


has the smallest possible sum of weights of its edges.
Kruskal’s Algorithm for MST

1. Sort all the edges of the graph in the increasing order of their weight.
2. Pick the edge with the smallest weight.
3. Check if it forms a cycle with the spanning tree formed so far.
4. Include the current edge if it does not form any cycle.
Otherwise discard it.
5. Repeat step #3 until there v − 1 edges in the spanning tree
Prim’s Algorithm for MST

1. Select a starting vertex.


2. Select an edge e connecting the tree vertex and fringe vertex that has minimum
weight. Fringe vertices are the vertices adjacent to visited vertices but not yet
visited.
3. Add the selected edge and the vertex to the minimum spanning tree T
4. Repeat step #2 and step #3 until the vertices adjacent to the visited vertex are
unvisited.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy