49
1 er Cours : Introduction MPRI 2012–2013 1 er Cours : Introduction MPRI 2012–2013 Michel Habib [email protected] http://www.liafa.univ-Paris-Diderot.fr/ ~ habib Chevaleret, septembre 2012

1er Cours : Introduction MPRI 2012 2013habib/Documents/Cours_1-2012.pdf1er Cours : Introduction MPRI 2012{2013 Introduction Practical issues Graphs made up with vertices and edges

  • Upload
    others

  • View
    12

  • Download
    0

Embed Size (px)

Citation preview

  • 1er Cours : Introduction MPRI 2012–2013

    1er Cours : IntroductionMPRI 2012–2013

    Michel [email protected]

    http://www.liafa.univ-Paris-Diderot.fr/~habib

    Chevaleret, septembre 2012

    http://www.liafa.univ-Paris-Diderot.fr/~habib

  • 1er Cours : Introduction MPRI 2012–2013

    Schedule

    Introduction

    Which algorithms ?

    Structuration and decomposition

    Schedule of the course

    Problems and Exercises

    Graph Representations

  • 1er Cours : Introduction MPRI 2012–2013

    Introduction

    Academic year : 2012-2013

    I Research team : Distributed algorithms and graphs, LIAFA :

    I Part IPractical graph algorithmsMichel Habib (Pr Univ. Paris Diderot)

    I Part IITreewithStructure theorems (minors theory and graph decompositionsRobertson and Seymour)Pierre Charbit (MdC, Univ. Paris Diderot)

    I contact : [email protected]

  • 1er Cours : Introduction MPRI 2012–2013

    Introduction

    Google et Facebook

  • 1er Cours : Introduction MPRI 2012–2013

    Introduction

    Next challenges

    I Merging the 2 Webs ?

    I Recommender Algorithms (bipartite graph clustering) orreasoning with heterogeneous data.

  • 1er Cours : Introduction MPRI 2012–2013

    Introduction

    Quelques grosses capitalisations boursières !

  • 1er Cours : Introduction MPRI 2012–2013

    Introduction

    Programme détaillé de la partie I

    I Classes de graphes (cographes, graphes triangulés, graphesd’intervalles ...), Représentations géométriques

    I Une théorie des parcours de graphes

    I Techniques de partionnement.

    I Graphes triangulés et algorithmes gloutons.

    I Décompositions de graphes calculables polynomialement :décomposition modulaire, en coupes, 2-join ... Etude desmeilleurs algorithmes disponibles.

    I Décompositions de graphes NP-difficiles à calculer : largeurd’arborescence, de rang ou de cliques et invariants de graphes.

  • 1er Cours : Introduction MPRI 2012–2013

    Introduction

    Programme suite

    I Quelques algorithmes sur les ensembles ordonnésI Applications directes de ces notions à :

    I Certains calculs dans les réseaux (diamètre, centres, flots),I La théorie de la complexité paramétréeI Des problèmes de phylogénie en Bioinformatique

  • 1er Cours : Introduction MPRI 2012–2013

    Introduction

    First question

    Why such a course ?

    Fagin’s theorems in structural complexity

    Characterizations of P and NP using graphs and logics fragments.

    NP

    The class of all graph-theoretic properties expressible in existentialsecond-order logic is precisely NP.

    P

    The class of all graph-theoretic properties expressible in Hornexistential second-order logic with successor is precisely P.

  • 1er Cours : Introduction MPRI 2012–2013

    Introduction

    Practical issues

    Graphs made up with vertices and edges (or arcs) provide a verypowerful tool to model real-life problems. Weights on vertices oredges can be added.Many applications involve graph algorithms, in particular manyfacets of computer science !Also many new leading economical applications Google PageRankand FaceBook are graph based

  • 1er Cours : Introduction MPRI 2012–2013

    Introduction

    The great importance of the right model

    It is crucial to use all the characteristics of the problem you wantto solve and find a good model. Two examples from PeterWinkler’s nice book on Mathematical Puzzles :All the discrete structures considered her are supposed to be finite.

    1. An odd number of soldiers in a field in such a way that allpairwise distances are different. Each soldier is told to keep aneye on the nearest other soldier.Show that at least one soldier is not being watched.

    2. A problem on rectangles :A large rectangle of the plane is partitioned into smallerrectangles, each of witch has either integer height or integerwidth (or both). Prove that the large rectangle also has thisproperty.

  • 1er Cours : Introduction MPRI 2012–2013

    Which algorithms ?

    Which algorithms ?

    I Optimal ?

    I Linear

    I Efficient ?

    I Simple ?

    I Easy to program

  • 1er Cours : Introduction MPRI 2012–2013

    Which algorithms ?

    In our work on optimization problems on graphs, we will metseveral complexity barriers :

    I Polynomial versus NP hardIn this case an algorithm running in O(n75.m252) could be anice result !

    I Linear versus Boolean matrix multiplicationAlgorithms running in O(n.m), hard to find a lower bound !

    I Practical issues need linear algorithms in order to be appliedI on huge graphs such as Web graph . . ..I many times such as inheritance in object oriented

    programming.I Need for heuristics !

  • 1er Cours : Introduction MPRI 2012–2013

    Which algorithms ?

    Brute Force algorithms

    For some problem

    1. Enumerate the set S of solutions

    2. Select the optimal one

    3. Show that |S | is polynomial in the size of the problem

  • 1er Cours : Introduction MPRI 2012–2013

    Which algorithms ?

    Variations

    1. Find the best way to enumerate S (for example a Gray codein O(|S |) constant time per element)

    2. Many variations . . .

    3. Sometimes the problem is NP-hard and the the game is tofind the exponential algorithm with the lowest exponent.

  • 1er Cours : Introduction MPRI 2012–2013

    Which algorithms ?

    Le Parcours en profondeur

    DFS(G ) :

    for all v ∈ X doFerme(x)← Faux ;

    end forfor all v ∈ X doif Ferme(x) = Faux thenExplorer(G , x);

    end ifend for

  • 1er Cours : Introduction MPRI 2012–2013

    Which algorithms ?

    Explorer(G , x) :

    Ferme(x)← Vrai ;pre(x);for all xy ∈ U doif Ferme(y) = Faux thenExplorer(G , y) ;

    end ifpost(x) ;

    end for

  • 1er Cours : Introduction MPRI 2012–2013

    Which algorithms ?

    Et les deux fonctions suivantes utilisant deux variables : comptpreet comptpost étant initialisées à 1.pre(x) :

    pre(x)← comptpre ;comptpre ← comptpre + 1 ;

    post(x) :

    post(x)← comptpost ;comptpost ← comptpost + 1 ;

  • 1er Cours : Introduction MPRI 2012–2013

    Which algorithms ?

    L’algorithme de Tarjan pour les composantes fortementconnexes

    DFS(G ) :

    comptpre ← 1;Resultat ← ∅;for all v ∈ X doFerme(x)← Faux ;

    end forfor all v ∈ X doif Ferme(x) = Faux thenExplorer(G , x) ;

    end ifend for

  • 1er Cours : Introduction MPRI 2012–2013

    Which algorithms ?

    Explorer(G , x) :

    Empiler(Resultat, x);Pile(x)← Vrai ;Ferme(x)← Vrai ;pre(x)← comptpre; comptpre ← comptpre + 1 ;racine(x)← pre(x);for all xy ∈ U do

    if Ferme(y) = Faux thenExplorer(G , y);racine(x)← min{racine(x), racine(y)} ;

    else if Pile(y) = Vrai thenracine(x)← min{racine(x), racine(y)} ;

    end ifend forif racine(x) = pre(x) then

    Dépiler Resultat jusqu’à x ;end if

  • 1er Cours : Introduction MPRI 2012–2013

    Which algorithms ?

    Fundamental questions about algorithms

    1. How can we prove such a nice algorithm ?

    2. It has some greedy flavor, why ?

  • 1er Cours : Introduction MPRI 2012–2013

    Which algorithms ?

    Algorithme de Kosaraju 1978, Sharir 1981

    1. Exécuter un parcours en profondeur sur G .

    2. Faire un autre parcours en profondeur sur G− avec pour ordreinitial l’ordre postd

    3. Les arbres de la forêt recouvrante de G−, sont lescomposantes fortement connexes de G

  • 1er Cours : Introduction MPRI 2012–2013

    Which algorithms ?

    Goals

    I Reach a good level of knowledge on graph algorithms (manystudents FAQ)

    I Understand the greedy algorithms

    I Try to understand why some simple heuristics works for mostpractical data

    I Understand how to use structural results to design algorithms

    I Panorama of research

  • 1er Cours : Introduction MPRI 2012–2013

    Structuration and decomposition

    Our Claims or thesis

    An efficient algorithm running on a discrete structure is alwaysbased :

    I on a theorem describing a combinatorial structure

    I a combinatorial decomposition of this discrete structure.

    I or in some other cases a geometric representation of thestructure provides the algorithm.

    Examples

    I Chordal graph recognition and maximal clique trees (particular case of treewidth).

    I Transitive orientation and modular decompostion.

    I Max Flow and decomposing a flow in a sum of positivecircuits.

    I Greedy algorithms for minimum spanning trees and matroids

    I . . .

  • 1er Cours : Introduction MPRI 2012–2013

    Structuration and decomposition

    Uses of geometric representations

    I Computing a maximum clique (of maximum size) or anefficient representation of an interval graph.

    I Numerous algorithms on planar graphs use the existence of adual graph. ( Ex : flows transform into paths)

  • 1er Cours : Introduction MPRI 2012–2013

    Schedule of the course

    Schedule of the course

    1. Introduction (this course)

    2. Chordal and interval graphs and their nice structure

    3. Algorithms for modular decomposition and extensions

    4. Treewidth and other width parameters (parametrizedcomplexity)

    5. Graph Searches, a new approach

    6. Diameter Computations

  • 1er Cours : Introduction MPRI 2012–2013

    Schedule of the course

    Examples of algorithmic problems

    I shortest paths, reachability (existence of a path)

    I Center and diameter computations

    I Graph encoding, distance labeling

    I Routing

    I Sandwich (or completion) problems

    I Colorations

  • 1er Cours : Introduction MPRI 2012–2013

    Schedule of the course

    Decompositions used here

    I modular decomposition

    I split decomposition

    I Cliquewidth)

    I Treewidth, pathwidth

    I Branchwidth and rankwidth

  • 1er Cours : Introduction MPRI 2012–2013

    Schedule of the course

    Graph classes used here

    I Tournaments (Tournois), posets, bipartite graphs

    I Cographs (P4-free)

    I Interval graphs

    I Chordal

    I Comparability

    I Asteroidal triple free

    I Distance-hereditary

    I Permutation

    I Perfect Graphs

    I Convex, bi-convex, . . .

  • 1er Cours : Introduction MPRI 2012–2013

    Schedule of the course

    Typical questions

    I Recognition algorithms, if possible linear-time and robust.

    I Efficient decomposition algorithms

    I Computations of compact encodings and representation

    I Random generation and enumeration

    I Routing protocols and diameter estimation

    I Computation of some invariant (for example mini coloring ormax clique).

  • 1er Cours : Introduction MPRI 2012–2013

    Schedule of the course

    Application domains

    ThemesI Bioinformatics (mainly phylogeny and other graph problems)

    I Networks and Distributed systems

    I Analysis of huge graphs in social sciences (ranking, clustering)

    GANG

    An INRIA–LIAFA project on graphs an networks, dir. L. Viennot

    SAE

    A biological group at UPMC with E. Bapteste and P. Lopez

    Social sciences

    ANR Project AlgoPol, a collaboration with D. Cardon (OrangeLab) and C. Prieur (LIAFA)

  • 1er Cours : Introduction MPRI 2012–2013

    Schedule of the course

    Notation

    For a finite loopless undirected graph G = (V ,E )V set of verticesE edges set|V | = n and |E | = m

  • 1er Cours : Introduction MPRI 2012–2013

    Problems and Exercises

    Some exercises

    1. A linear algorithm for isomorphism on trees

    2. Computation of the diameter of a tree

    3. Propose an algorithm which determines if a clique of size∆ + 1 exists in a graph with maximum degree ∆ ?

  • 1er Cours : Introduction MPRI 2012–2013

    Problems and Exercises

    Solution de l’exercice

    I Propose an algorithm which determines if a clique of size∆ + 1 exists in a graph with maximum degree ∆ ?

    I A solutionLet S be the set of vertices with degree ∆ of the graph.Until it exists a ∈ S with a neighbour /∈ S , delete a from S .The remaining connected components of size exactly ∆ + 1are the solutions.

    I The algorithm requires O(n + m).

  • 1er Cours : Introduction MPRI 2012–2013

    Problems and Exercises

    Bound on the number of edges

    Triangle free graphs

    Show that if G has no triangle then :

    |E | ≤ |V |2

    4

    Planar graphs

    Show that if G is a simple planar graph (i.e. without loop andparallel edge) then :|E | ≤ 3|V | − 6

  • 1er Cours : Introduction MPRI 2012–2013

    Problems and Exercises

    Classes of twin vertices

    Definition

    x and y are called false twins, (resp. true twins) ifN(x) = N(y) (resp. N(x) ∪ {x} = N(y) ∪ {y}))

    Exercise

    Propose a good algorithm to compute these classes

  • 1er Cours : Introduction MPRI 2012–2013

    Problems and Exercises

    Research Problems

    I Find a linear-time algorithm that minimizes a deterministicautomaton.

    I Find a linear-time algorithm which computes a doublylexicographic ordering of a 0-1 matrix, i.e. an ordering of thecolumns and the lines for which lines and columns appear tobe lexicographically ordered.

  • 1er Cours : Introduction MPRI 2012–2013

    Problems and Exercises

    Example of a doubly lexicographic ordering

    C1 C2 C3 C4 C5

    L1 1 0 1 0 1

    L2 0 1 0 1 1

    L3 1 1 0 1 1

    L4 0 0 0 0 1

    L5 0 1 1 0 0

    C3 C1 C4 C5 C2

    L4 0 0 0 1 0

    L1 1 1 0 1 0

    L5 1 0 0 0 1

    L2 0 0 1 1 1

    L3 0 1 1 1 1

  • 1er Cours : Introduction MPRI 2012–2013

    Problems and Exercises

    I Such an ordering always exists

    I Best algorithm to compute one :Paige and Tarjan [1987] proposed an O(LlogL) whereL = n + m + e for a matrix with n lines, m columns and e nonzero values, using partition refinement.

    I For undirected graphs, such an ordering of the symmetricincidence matrix, yields an ordering of the vertices which hasnice properties.

  • 1er Cours : Introduction MPRI 2012–2013

    Graph Representations

    I Implicit hypothesis : the memory words have k bits withk > dlog(|V |)e

    I To be sure, consider the bit encoding level

  • 1er Cours : Introduction MPRI 2012–2013

    Graph Representations

    I Adjacency listsO(|V |+ |E |) memory wordsAdjacency test : xy is an arc in O(|N(x)|)

    I Adjacency MatrixO(|V |2) memory words (can be compressed)Adjacency test : xy is an arc in O(1)

    I Customized representations, a pointer for each arc . . .

  • 1er Cours : Introduction MPRI 2012–2013

    Graph Representations

    For some large graphs, the Adjacency matrix, is not easy to obtainand manipulate.But the neighbourhood of a given vertex can be obtained. (WEBGraph or graphs is Game Theory)

  • 1er Cours : Introduction MPRI 2012–2013

    Graph Representations

    Quicksands

    I To compute this invariant or this property of a given graph Gone needs to ”see”( or visit) every edge at least once.

    I False statement as for example the computation of twins resp.connected components on G knowing G .

  • 1er Cours : Introduction MPRI 2012–2013

    Graph Representations

    Exercise

    Can the advantages of the 2 previous representations can be mixedin a unique new one ?Adjacency lists : construction in O(n + m)Inicence matrix : cost of the query : xy ∈ E? in O(1)

    In other words

    Using O(n2) space, but with linear time algorithms on graphs ?

  • 1er Cours : Introduction MPRI 2012–2013

    Graph Representations

    Auto-complemented representations

    Initial Matrix

    1 2 3 4

    1 1 1 1 0

    2 0 0 1 0

    3 1 0 1 1

    4 1 0 0 0

    Tagged Matrix

    1 2 3 4

    1 0 1 0 0

    2 1 0 0 0

    3 0 0 0 1

    4 0 0 1 0

  • 1er Cours : Introduction MPRI 2012–2013

    Graph Representations

    I At most 2n tags (bits).O(n + m′) with m′

  • 1er Cours : Introduction MPRI 2012–2013

    Graph Representations

    I Find a minimum sized representation

    I If G is undirected a minimum is unique.

  • 1er Cours : Introduction MPRI 2012–2013

    Graph Representations

    What is an elementary operation for a graph ?

    I Traversing an edge or Visiting the neighbourhood ?

    I It explains the very few lower bounds known for graphalgorithms on a RAM Machine.

    I Our graph algorithms must accept any auto-complementedrepresentation.Partition Refinement

  • 1er Cours : Introduction MPRI 2012–2013

    Graph Representations

    Last exercise

    Suppose that a graph G = (V ,E ) is given by its adjacency listsand let σ be some total ordering of its vertices.

    I How can we sort the adjacency with respect to σ (increasing) ?

    I What is the complexity of this operation ?

    I Let σ be the total ordering of the vertices with decreasingdegrees, how to compute σ ?