how to win coding competitions: secrets of champions week 4: … · 2016. 11. 19. · 2 1 3/17....

82
How to Win Coding Competitions: Secrets of Champions Week 4: Algorithms on Graphs Lecture 1: Introduction to graphs Maxim Buzdalov Saint Petersburg 2016

Upload: others

Post on 24-Jan-2021

6 views

Category:

Documents


0 download

TRANSCRIPT

  • How to Win Coding Competitions: Secrets of Champions

    Week 4: Algorithms on GraphsLecture 1: Introduction to graphs

    Maxim BuzdalovSaint Petersburg 2016

  • What are graphs?

    Roads and cities

    New York

    Philadelphia

    Allentown

    Reading

    Lancaster

    2 / 17

  • What are graphs?

    Social networks

    Alice

    Bob

    Cynthia

    Dick

    Eugene

    Fritha

    George

    2 / 17

  • What are graphs?

    Even computer programs

    main

    scanf printfspanning tree

    qsort

    ds get

    ds unite

    edge comp

    2 / 17

  • Basic definitions: Undirected graph

    Undirected graph: an ordered pair G = 〈V ,E 〉I V – set of graph’s verticesI E – set of graph’s edges, a multiset of unordered pairs of verticesI (u, v) ∈ E means that an edge connecting vertices u and v exists in the graph

    I Degree of a vertex v – deg(v) – the number of edges in E which contain v

    3

    3

    3

    5

    2

    3

    2

    1

    3 / 17

  • Basic definitions: Undirected graph

    Undirected graph: an ordered pair G = 〈V ,E 〉I V – set of graph’s verticesI E – set of graph’s edges, a multiset of unordered pairs of verticesI (u, v) ∈ E means that an edge connecting vertices u and v exists in the graph

    I Degree of a vertex v – deg(v) – the number of edges in E which contain v

    3

    3

    3

    5

    2

    3

    2

    1

    3 / 17

  • Basic definitions: Undirected graph

    Undirected graph: an ordered pair G = 〈V ,E 〉I V – set of graph’s verticesI E – set of graph’s edges, a multiset of unordered pairs of verticesI (u, v) ∈ E means that an edge connecting vertices u and v exists in the graphI Degree of a vertex v – deg(v) – the number of edges in E which contain v

    3

    3

    3

    5

    2

    3

    2

    1

    3 / 17

  • Basic definitions: Undirected graph

    Undirected graph: an ordered pair G = 〈V ,E 〉I V – set of graph’s verticesI E – set of graph’s edges, a multiset of unordered pairs of verticesI (u, v) ∈ E means that an edge connecting vertices u and v exists in the graphI Degree of a vertex v – deg(v) – the number of edges in E which contain v

    3

    3

    3

    5

    2

    3

    2

    1

    3 / 17

  • Basic definitions: Directed graph

    Directed graph: an ordered pair G = 〈V ,E 〉I V – set of graph’s vertices

    I E – set of graph’s edges, a multiset of ordered pairs of vertices

    I Incoming degree of a vertex v – deg−(v) – the number of edges (x , v) ∈ EI Outgoing degree of a vertex v – deg+(v) – the number of edges (v , x) ∈ E

    4 / 17

  • Basic definitions: Directed graph

    Directed graph: an ordered pair G = 〈V ,E 〉I V – set of graph’s vertices

    I E – set of graph’s edges, a multiset of ordered pairs of vertices

    I Incoming degree of a vertex v – deg−(v) – the number of edges (x , v) ∈ EI Outgoing degree of a vertex v – deg+(v) – the number of edges (v , x) ∈ E

    4 / 17

  • Basic definitions: Directed graph

    Directed graph: an ordered pair G = 〈V ,E 〉I V – set of graph’s vertices

    I E – set of graph’s edges, a multiset of ordered pairs of vertices

    I Incoming degree of a vertex v – deg−(v) – the number of edges (x , v) ∈ E

    I Outgoing degree of a vertex v – deg+(v) – the number of edges (v , x) ∈ E

    0

    1

    1

    4

    1

    2

    2

    0

    4 / 17

  • Basic definitions: Directed graph

    Directed graph: an ordered pair G = 〈V ,E 〉I V – set of graph’s vertices

    I E – set of graph’s edges, a multiset of ordered pairs of vertices

    I Incoming degree of a vertex v – deg−(v) – the number of edges (x , v) ∈ EI Outgoing degree of a vertex v – deg+(v) – the number of edges (v , x) ∈ E

    3

    2

    2

    1

    1

    1

    0

    1

    4 / 17

  • Basic definitions: Weighted graph

    Weighted graph

    I Can be either directed or undirected graph

    I Has a function W : E → X , where X is the set of weightsI X is typically integers or reals, can also be symbols or strings

    I In some cases, an unweighted graph is the same as a weighted graph with X = {1}

    A

    B

    C

    D

    E

    F

    G

    H5

    7 4

    2

    6

    1

    3

    5

    8

    9

    2

    5 / 17

  • Basic definitions: Weighted graph

    Weighted graph

    I Can be either directed or undirected graph

    I Has a function W : E → X , where X is the set of weightsI X is typically integers or reals, can also be symbols or strings

    I In some cases, an unweighted graph is the same as a weighted graph with X = {1}

    A

    B

    C

    D

    E

    F

    G

    H5

    7 4

    2

    6

    1

    3

    5

    8

    9

    2

    5 / 17

  • Basic definitions: Weighted graph

    Weighted graph

    I Can be either directed or undirected graph

    I Has a function W : E → X , where X is the set of weightsI X is typically integers or reals, can also be symbols or strings

    I In some cases, an unweighted graph is the same as a weighted graph with X = {1}

    A

    B

    C

    D

    E

    F

    G

    H5

    7 4

    2

    6

    1

    3

    5

    8

    9

    2

    5 / 17

  • Basic definitions: Paths

    Path in the graph G = 〈V ,E 〉I A list of vertices v1, v2, . . . , vk , such that (vi , vi+1) ∈ E for all 1 ≤ i < k

    I Example: [A,B,F ,D,C ,G ] is a path

    I Simple path: no vertex appears twice in the path

    A

    B

    C

    D

    E

    F

    G

    H

    6 / 17

  • Basic definitions: Paths

    Path in the graph G = 〈V ,E 〉I A list of vertices v1, v2, . . . , vk , such that (vi , vi+1) ∈ E for all 1 ≤ i < kI Example: [A,B,F ,D,C ,G ] is a path

    I Simple path: no vertex appears twice in the path

    A

    B

    C

    D

    E

    F

    G

    H

    6 / 17

  • Basic definitions: Paths

    Path in the graph G = 〈V ,E 〉I A list of vertices v1, v2, . . . , vk , such that (vi , vi+1) ∈ E for all 1 ≤ i < kI Example: [A,B,F ,D,C ,G ] is a path

    I Simple path: no vertex appears twice in the path

    A

    B

    C

    D

    E

    F

    G

    H

    6 / 17

  • Basic definitions: Paths

    Path in the graph G = 〈V ,E 〉I A list of vertices v1, v2, . . . , vk , such that (vi , vi+1) ∈ E for all 1 ≤ i < kI Example: [A,B,F ,D,C ,G ] is a path

    I Simple path: no vertex appears twice in the path

    A

    B

    C

    D

    E

    F

    G

    H

    6 / 17

  • Basic definitions: Paths

    Path in the graph G = 〈V ,E 〉I A list of vertices v1, v2, . . . , vk , such that (vi , vi+1) ∈ E for all 1 ≤ i < kI Example: [A,B,F ,D,C ,G ] is a path

    I Simple path: no vertex appears twice in the path

    A

    B

    C

    D

    E

    F

    G

    H

    6 / 17

  • Basic definitions: Paths

    Path in the graph G = 〈V ,E 〉I A list of vertices v1, v2, . . . , vk , such that (vi , vi+1) ∈ E for all 1 ≤ i < kI Example: [A,B,F ,D,C ,G ] is a path

    I Simple path: no vertex appears twice in the path

    A

    B

    C

    D

    E

    F

    G

    H

    6 / 17

  • Basic definitions: Paths

    Path in the graph G = 〈V ,E 〉I A list of vertices v1, v2, . . . , vk , such that (vi , vi+1) ∈ E for all 1 ≤ i < kI Example: [A,B,F ,D,C ,G ] is a path

    I Simple path: no vertex appears twice in the path

    A

    B

    C

    D

    E

    F

    G

    H

    6 / 17

  • Basic definitions: Paths

    Path in the graph G = 〈V ,E 〉I A list of vertices v1, v2, . . . , vk , such that (vi , vi+1) ∈ E for all 1 ≤ i < kI Example: [A,B,F ,D,C ,G ] is a path

    I Simple path: no vertex appears twice in the path

    A

    B

    C

    D

    E

    F

    G

    H

    6 / 17

  • Basic definitions: Paths

    Path in the graph G = 〈V ,E 〉I A list of vertices v1, v2, . . . , vk , such that (vi , vi+1) ∈ E for all 1 ≤ i < kI Example: [A,B,F ,D,C ,G ] is a path

    I Simple path: no vertex appears twice in the path

    A

    B

    C

    D

    E

    F

    G

    H

    6 / 17

  • Basic definitions: Paths

    Path in the graph G = 〈V ,E 〉I A list of vertices v1, v2, . . . , vk , such that (vi , vi+1) ∈ E for all 1 ≤ i < kI Example: [A,B,F ,D,C ,G ] is a path

    I Simple path: no vertex appears twice in the path

    A

    B

    C

    D

    E

    F

    G

    H

    6 / 17

  • Basic definitions: Cycle

    Cycle in the graph G = 〈V ,E 〉I A path v1, v2, . . . , vk , such that vk = v1

    I Example: [C ,G ,H,D] is a cycle

    I Simple cycle: no vertex appears twice in the path, except for v1 = vk

    A

    B

    C

    D

    E

    F

    G

    H

    7 / 17

  • Basic definitions: Cycle

    Cycle in the graph G = 〈V ,E 〉I A path v1, v2, . . . , vk , such that vk = v1I Example: [C ,G ,H,D] is a cycle

    I Simple cycle: no vertex appears twice in the path, except for v1 = vk

    A

    B

    C

    D

    E

    F

    G

    H

    7 / 17

  • Basic definitions: Cycle

    Cycle in the graph G = 〈V ,E 〉I A path v1, v2, . . . , vk , such that vk = v1I Example: [C ,G ,H,D] is a cycle

    I Simple cycle: no vertex appears twice in the path, except for v1 = vk

    A

    B

    C

    D

    E

    F

    G

    H

    7 / 17

  • Basic definitions: Cycle

    Cycle in the graph G = 〈V ,E 〉I A path v1, v2, . . . , vk , such that vk = v1I Example: [C ,G ,H,D] is a cycle

    I Simple cycle: no vertex appears twice in the path, except for v1 = vk

    A

    B

    C

    D

    E

    F

    G

    H

    7 / 17

  • Basic definitions: Cycle

    Cycle in the graph G = 〈V ,E 〉I A path v1, v2, . . . , vk , such that vk = v1I Example: [C ,G ,H,D] is a cycle

    I Simple cycle: no vertex appears twice in the path, except for v1 = vk

    A

    B

    C

    D

    E

    F

    G

    H

    7 / 17

  • Basic definitions: Cycle

    Cycle in the graph G = 〈V ,E 〉I A path v1, v2, . . . , vk , such that vk = v1I Example: [C ,G ,H,D] is a cycle

    I Simple cycle: no vertex appears twice in the path, except for v1 = vk

    A

    B

    C

    D

    E

    F

    G

    H

    7 / 17

  • Basic definitions: Cycle

    Cycle in the graph G = 〈V ,E 〉I A path v1, v2, . . . , vk , such that vk = v1I Example: [C ,G ,H,D] is a cycle

    I Simple cycle: no vertex appears twice in the path, except for v1 = vk

    A

    B

    C

    D

    E

    F

    G

    H

    7 / 17

  • Basic definitions: Cycle

    Cycle in the graph G = 〈V ,E 〉I A path v1, v2, . . . , vk , such that vk = v1I Example: [C ,G ,H,D] is a cycle

    I Simple cycle: no vertex appears twice in the path, except for v1 = vk

    A

    B

    C

    D

    E

    F

    G

    H

    7 / 17

  • Basic definitions: Loops and multiedges

    Loop is an edge which connects a vertex to itselfMultiedge is an edge which appears multiple times in E

    A

    B

    E F

    8 / 17

  • Basic definitions: Loops and multiedges

    Loop is an edge which connects a vertex to itselfMultiedge is an edge which appears multiple times in E

    A

    B

    E F

    8 / 17

  • Basic definitions: Connectivity

    An undirected graph is connected if there exists a path between any two vertices

    A

    B

    C

    D

    E

    F

    G

    H

    9 / 17

  • Basic definitions: Connectivity

    An undirected graph is connected if there exists a path between any two verticesExample of connected graph

    A

    B

    C

    D

    E

    F

    G

    H

    9 / 17

  • Basic definitions: Connectivity

    An undirected graph is connected if there exists a path between any two verticesExample of graph which is not connected

    A

    B

    C

    D

    E

    F

    G

    H

    9 / 17

  • Basic definitions: Connectivity

    An undirected graph is connected if there exists a path between any two verticesExample of graph which is not connected – three connected components

    A

    B

    C

    D

    E

    F

    G

    H

    9 / 17

  • Basic definitions: Strong connectivity

    A directed graph is strongly connected if, for any two vertices u and v , there exists apath from u to v , and a path from v to u

    A

    B

    C

    D

    E

    F

    G

    H

    10 / 17

  • Basic definitions: Strong connectivity

    A directed graph is strongly connected if, for any two vertices u and v , there exists apath from u to v , and a path from v to uExample of strongly connected graph

    A

    B

    C

    D

    E

    F

    G

    H

    10 / 17

  • Basic definitions: Strong connectivity

    A directed graph is strongly connected if, for any two vertices u and v , there exists apath from u to v , and a path from v to uExample of graph which is not strongly connected

    A

    B

    C

    D

    E

    F

    G

    H

    10 / 17

  • Basic definitions: Strong connectivity

    A directed graph is strongly connected if, for any two vertices u and v , there exists apath from u to v , and a path from v to uExample of graph which is not strongly connected – two strongly connectedcomponents

    A

    B

    C

    D

    E

    F

    G

    H

    10 / 17

  • Types of graphs

    There exist several important types of graphs. Some of these frequently appear inprogramming competitions. Here they are:

    I Trees, rooted trees and forests

    I Cactuses

    I Complete graphs and tournaments

    I Bipartite graphs

    I Planar graphs

    11 / 17

  • Trees and forests

    Tree: an undirected graph in which any two vertices are connected by exactly one path

    I A tree does not contain any cycles. Graphs without cycles are called acyclicI In any tree, |E | = |V | − 1

    Forest: a disjoint union of treesRooted tree: a tree where one of the vertices is a root.All edges have direction either from or towards root

    A

    B

    C

    D

    E

    FG H

    I J

    K

    L

    M

    N

    O P

    12 / 17

  • Trees and forests

    Tree: an undirected graph in which any two vertices are connected by exactly one path

    I A tree does not contain any cycles. Graphs without cycles are called acyclic

    I In any tree, |E | = |V | − 1Forest: a disjoint union of treesRooted tree: a tree where one of the vertices is a root.All edges have direction either from or towards root

    A

    B

    C

    D

    E

    FG H

    I J

    K

    L

    M

    N

    O P

    12 / 17

  • Trees and forests

    Tree: an undirected graph in which any two vertices are connected by exactly one path

    I A tree does not contain any cycles. Graphs without cycles are called acyclicI In any tree, |E | = |V | − 1

    Forest: a disjoint union of treesRooted tree: a tree where one of the vertices is a root.All edges have direction either from or towards root

    A

    B

    C

    D

    E

    FG H

    I J

    K

    L

    M

    N

    O P

    12 / 17

  • Trees and forests

    Tree: an undirected graph in which any two vertices are connected by exactly one path

    I A tree does not contain any cycles. Graphs without cycles are called acyclicI In any tree, |E | = |V | − 1

    Forest: a disjoint union of trees

    Rooted tree: a tree where one of the vertices is a root.All edges have direction either from or towards root

    A

    B

    C

    D

    E

    FG H

    I J K

    L

    M

    N

    O P12 / 17

  • Trees and forests

    Tree: an undirected graph in which any two vertices are connected by exactly one path

    I A tree does not contain any cycles. Graphs without cycles are called acyclicI In any tree, |E | = |V | − 1

    Forest: a disjoint union of treesRooted tree: a tree where one of the vertices is a root.All edges have direction either from or towards root

    A

    B

    C

    D

    E

    FG H

    I J K

    L

    M

    N

    O P12 / 17

  • Spanning tree

    Spanning tree: a subgraph of an undirected graph G ,which is a tree and contains all vertices of G

    I A graph G ′ = 〈V ′,E ′〉 is a subgraph of G = 〈V ,E 〉 if:I V ′ ⊆ V , E ′ ⊆ EI For all (u, v) ∈ E ′, u ∈ V ′ and v ∈ V ′

    A

    B

    C

    D

    E

    F

    G

    H

    13 / 17

  • Spanning tree

    Spanning tree: a subgraph of an undirected graph G ,which is a tree and contains all vertices of G

    I A graph G ′ = 〈V ′,E ′〉 is a subgraph of G = 〈V ,E 〉 if:I V ′ ⊆ V , E ′ ⊆ EI For all (u, v) ∈ E ′, u ∈ V ′ and v ∈ V ′

    A

    B

    C

    D

    E

    F

    G

    H

    13 / 17

  • Spanning tree

    Spanning tree: a subgraph of an undirected graph G ,which is a tree and contains all vertices of G

    I A graph G ′ = 〈V ′,E ′〉 is a subgraph of G = 〈V ,E 〉 if:I V ′ ⊆ V , E ′ ⊆ EI For all (u, v) ∈ E ′, u ∈ V ′ and v ∈ V ′

    A

    B

    C

    D

    E

    F

    G

    H

    13 / 17

  • Spanning tree

    Spanning tree: a subgraph of an undirected graph G ,which is a tree and contains all vertices of G

    I A graph G ′ = 〈V ′,E ′〉 is a subgraph of G = 〈V ,E 〉 if:I V ′ ⊆ V , E ′ ⊆ EI For all (u, v) ∈ E ′, u ∈ V ′ and v ∈ V ′

    A

    B

    C

    D

    E

    F

    G

    H

    13 / 17

  • Spanning tree

    Fix a spanning tree T of graph G . Every edge of G not in T forms a cycle with T .These are the fundamental cycles with regards to T .

    Any cycle can be uniquely expressed as a combination of fundamental cycles

    A

    B

    C

    D

    E

    F

    G

    H

    13 / 17

  • Spanning tree

    Fix a spanning tree T of graph G . Every edge of G not in T forms a cycle with T .These are the fundamental cycles with regards to T .

    Any cycle can be uniquely expressed as a combination of fundamental cycles

    A

    B

    C

    D

    E

    F

    G

    H

    13 / 17

  • Spanning tree

    Fix a spanning tree T of graph G . Every edge of G not in T forms a cycle with T .These are the fundamental cycles with regards to T .

    Any cycle can be uniquely expressed as a combination of fundamental cycles

    A

    B

    C

    D

    E

    F

    G

    H

    13 / 17

  • Spanning tree

    Fix a spanning tree T of graph G . Every edge of G not in T forms a cycle with T .These are the fundamental cycles with regards to T .

    Any cycle can be uniquely expressed as a combination of fundamental cycles

    A

    B

    C

    D

    E

    F

    G

    H

    13 / 17

  • Spanning tree

    Fix a spanning tree T of graph G . Every edge of G not in T forms a cycle with T .These are the fundamental cycles with regards to T .

    Any cycle can be uniquely expressed as a combination of fundamental cycles

    A

    B

    C

    D

    E

    F

    G

    H

    13 / 17

  • Spanning tree

    Fix a spanning tree T of graph G . Every edge of G not in T forms a cycle with T .These are the fundamental cycles with regards to T .

    Any cycle can be uniquely expressed as a combination of fundamental cycles

    A

    B

    C

    D

    E

    F

    G

    H

    13 / 17

  • Spanning tree

    Fix a spanning tree T of graph G . Every edge of G not in T forms a cycle with T .These are the fundamental cycles with regards to T .

    Any cycle can be uniquely expressed as a combination of fundamental cycles

    A

    B

    C

    D

    E

    F

    G

    H

    13 / 17

  • Spanning tree

    Fix a spanning tree T of graph G . Every edge of G not in T forms a cycle with T .These are the fundamental cycles with regards to T .Any cycle can be uniquely expressed as a combination of fundamental cycles

    A

    B

    C

    D

    E

    F

    G

    H

    13 / 17

  • Cactus

    Edge-cactus: connected, undirected, any two simple cycles share at most one vertex

    I Each edge belongs to at most one cycle

    Vertex-cactus: any two simple cycles share no common vertices

    I Each vertex belongs to at most one cycle

    14 / 17

  • Cactus

    Edge-cactus: connected, undirected, any two simple cycles share at most one vertex

    I Each edge belongs to at most one cycle

    Vertex-cactus: any two simple cycles share no common vertices

    I Each vertex belongs to at most one cycle

    14 / 17

  • Cactus

    Edge-cactus: connected, undirected, any two simple cycles share at most one vertex

    I Each edge belongs to at most one cycle

    Vertex-cactus: any two simple cycles share no common vertices

    I Each vertex belongs to at most one cycle

    14 / 17

  • Cactus

    Edge-cactus: connected, undirected, any two simple cycles share at most one vertex

    I Each edge belongs to at most one cycle

    Vertex-cactus: any two simple cycles share no common vertices

    I Each vertex belongs to at most one cycle

    14 / 17

  • Cactus

    Edge-cactus: connected, undirected, any two simple cycles share at most one vertex

    I Each edge belongs to at most one cycle

    Vertex-cactus: any two simple cycles share no common vertices

    I Each vertex belongs to at most one cycle

    14 / 17

  • Cactus

    Edge-cactus: connected, undirected, any two simple cycles share at most one vertex

    I Each edge belongs to at most one cycle

    Vertex-cactus: any two simple cycles share no common vertices

    I Each vertex belongs to at most one cycle

    14 / 17

  • Bipartite graphs

    Bipartite graph: a undirected graph where V = L ∪ R, L ∩ R = ∅,such that for any edge (u, v) it holds that u ∈ L, v ∈ R

    I In any bipartite graph, every loop has an even length

    15 / 17

  • Bipartite graphs

    Bipartite graph: a undirected graph where V = L ∪ R, L ∩ R = ∅,such that for any edge (u, v) it holds that u ∈ L, v ∈ R

    I In any bipartite graph, every loop has an even length

    15 / 17

  • Bipartite graphs

    Bipartite graph: a undirected graph where V = L ∪ R, L ∩ R = ∅,such that for any edge (u, v) it holds that u ∈ L, v ∈ R

    I In any bipartite graph, every loop has an even length

    15 / 17

  • Complete graphs and tournaments

    Complete graph Kn: an undirected graph with edges between all pairs of vertices

    Tournament Tn: a directed graph with either (u, v) or (v , u) for all u and vComplete bipartite graph Kn,m: an undirected graph with edges between all pairs ofvertices from different parts

    16 / 17

  • Complete graphs and tournaments

    Complete graph Kn: an undirected graph with edges between all pairs of vertices

    Tournament Tn: a directed graph with either (u, v) or (v , u) for all u and vComplete bipartite graph Kn,m: an undirected graph with edges between all pairs ofvertices from different parts

    16 / 17

  • Complete graphs and tournaments

    Complete graph Kn: an undirected graph with edges between all pairs of verticesTournament Tn: a directed graph with either (u, v) or (v , u) for all u and v

    Complete bipartite graph Kn,m: an undirected graph with edges between all pairs ofvertices from different parts

    16 / 17

  • Complete graphs and tournaments

    Complete graph Kn: an undirected graph with edges between all pairs of verticesTournament Tn: a directed graph with either (u, v) or (v , u) for all u and v

    Complete bipartite graph Kn,m: an undirected graph with edges between all pairs ofvertices from different parts

    16 / 17

  • Complete graphs and tournaments

    Complete graph Kn: an undirected graph with edges between all pairs of verticesTournament Tn: a directed graph with either (u, v) or (v , u) for all u and vComplete bipartite graph Kn,m: an undirected graph with edges between all pairs ofvertices from different parts

    16 / 17

  • Complete graphs and tournaments

    Complete graph Kn: an undirected graph with edges between all pairs of verticesTournament Tn: a directed graph with either (u, v) or (v , u) for all u and vComplete bipartite graph Kn,m: an undirected graph with edges between all pairs ofvertices from different parts

    16 / 17

  • Planar graph

    Planar graph: a graph which can be laid out on the plane without edges intersections

    I Face: a piece of plane bounded by a loop in the graph never intersected by edges

    I Fact 1 (Euler characteristic): |V | − |E |+ |F | = 2.I Fact 2: If |V | ≥ 3 then |E | < 3|V | − 6I Fact 3 (Kuratowski): The graph is planar if and only if it doesn’t contain

    subgraphs which are subdivision of K5 or K3,3. Subdivision of the graph isintroducing some number of vertices in each edge.

    A

    B

    C

    D

    E

    F G

    H

    17 / 17

  • Planar graph

    Planar graph: a graph which can be laid out on the plane without edges intersections

    I Face: a piece of plane bounded by a loop in the graph never intersected by edges

    I Fact 1 (Euler characteristic): |V | − |E |+ |F | = 2.I Fact 2: If |V | ≥ 3 then |E | < 3|V | − 6I Fact 3 (Kuratowski): The graph is planar if and only if it doesn’t contain

    subgraphs which are subdivision of K5 or K3,3. Subdivision of the graph isintroducing some number of vertices in each edge.

    A

    B

    C

    D

    E

    F G

    H

    17 / 17

  • Planar graph

    Planar graph: a graph which can be laid out on the plane without edges intersections

    I Face: a piece of plane bounded by a loop in the graph never intersected by edges

    I Fact 1 (Euler characteristic): |V | − |E |+ |F | = 2.I Fact 2: If |V | ≥ 3 then |E | < 3|V | − 6I Fact 3 (Kuratowski): The graph is planar if and only if it doesn’t contain

    subgraphs which are subdivision of K5 or K3,3. Subdivision of the graph isintroducing some number of vertices in each edge.

    A

    B

    C

    D

    E

    F G

    H

    17 / 17

  • Planar graph

    Planar graph: a graph which can be laid out on the plane without edges intersections

    I Face: a piece of plane bounded by a loop in the graph never intersected by edges

    I Fact 1 (Euler characteristic): |V | − |E |+ |F | = 2.

    I Fact 2: If |V | ≥ 3 then |E | < 3|V | − 6I Fact 3 (Kuratowski): The graph is planar if and only if it doesn’t contain

    subgraphs which are subdivision of K5 or K3,3. Subdivision of the graph isintroducing some number of vertices in each edge.

    A

    B

    C

    D

    E

    F G

    H

    17 / 17

  • Planar graph

    Planar graph: a graph which can be laid out on the plane without edges intersections

    I Face: a piece of plane bounded by a loop in the graph never intersected by edges

    I Fact 1 (Euler characteristic): |V | − |E |+ |F | = 2.I Fact 2: If |V | ≥ 3 then |E | < 3|V | − 6

    I Fact 3 (Kuratowski): The graph is planar if and only if it doesn’t containsubgraphs which are subdivision of K5 or K3,3. Subdivision of the graph isintroducing some number of vertices in each edge.

    A

    B

    C

    D

    E

    F G

    H

    17 / 17

  • Planar graph

    Planar graph: a graph which can be laid out on the plane without edges intersections

    I Face: a piece of plane bounded by a loop in the graph never intersected by edges

    I Fact 1 (Euler characteristic): |V | − |E |+ |F | = 2.I Fact 2: If |V | ≥ 3 then |E | < 3|V | − 6I Fact 3 (Kuratowski): The graph is planar if and only if it doesn’t contain

    subgraphs which are subdivision of K5 or K3,3. Subdivision of the graph isintroducing some number of vertices in each edge.

    A

    B

    C

    D

    E

    F G

    H

    17 / 17