SlideShare une entreprise Scribd logo
1  sur  37
Télécharger pour lire hors ligne
Graphs



         www.tudorgirba.com
G = (V, E)
E = { {u,v} | u,v ∈ V}

 a                       e




           c         d       g



 b                       f
G = (V, E)
E = { {u,v} | u,v ∈ V}

  a                                      e




               c              d                      g



  b                                      f



V = { a, b, c, d, e, f, g }

E = { {a,b}, {a,c}, {b,c}, {c,d}, {d,e}, {d,f}, {e,g}, {f,g} }
G = (V, E)
E = { {u,v} | u,v ∈ V}

  a                                      e




               c              d                      g



  b                                      f



V = { a, b, c, d, e, f, g }

E = { {a,b}, {a,c}, {b,c}, {c,d}, {d,e}, {d,f}, {e,g}, {f,g} }
a   b   c   d   e   f   g

a   0   1   1   0   0   0   0

b   0   0   1   0   0   0   0   a           e
c   0   0   0   1   0   0   0
                                    c   d       g
d   0   0   0   0   1   1   0

e   0   0   0   0   0   0   1   b           f

f   0   0   0   0   0   0   1

g   0   0   0   0   0   0   0
a   b   c   d   e   f   g

a   0   1   1   0   0   0   0

b   1   0   1   0   0   0   0   a           e
c   1   1   0   1   0   0   0
                                    c   d       g
d   0   0   1   0   1   1   0

e   0   0   0   1   0   0   1   b           f

f   0   0   0   1   0   0   1

g   0   0   0   0   1   1   0
a   b   c   d   e   f   g

a   0   1   1   0   0   0   0   2                 2
b   1   0   1   0   0   0   0   a                 e
c   1   1   0   1   0   0   0
                                    c      d           g
d   0   0   1   0   1   1   0
                                    3      3           2
e   0   0   0   1   0   0   1   b                 f

f   0   0   0   1   0   0   1                     2

g   0   0   0   0   1   1   0

    2   2   3   3   2   2   2       Degree of a node
a   b   c   d   e   f   g

a   0   2   3   0   0   0   0

b   0   0   1   0   0   0   0   a                       e
                                    3               5       3
c   0   0   0   2   0   0   0               2
                                2       c       d               g
d   0   0   0   0   5   4   0
                                    1               4       3
e   0   0   0   0   0   0   3   b                       f

f   0   0   0   0   0   0   3

g   0   0   0   0   0   0   0


                                        Weighted graphs
Not complete   Complete

  a            a

        c            c

  b            b


  a            a

        c            c

  b            b
G = (V, E)
∀ e={v,w} ∈ E, v ∈ V and w ∈ W.



    Bipartite                     Not bipartite
Path                       Cycle

     a                         e

             c        d                 g

     b                         f



Path: (b, a, c); Length (b, a, c) = 2
Path: (b, d, f)
Cycle: (f, g, e, d, f); Length (f, g, e, d, f) = 4
Path                       Cycle

     a                         e

             c        d                 g

     b                         f



Path: (b, a, c); Length (b, a, c) = 2
Path: (b, d, f)
Cycle: (f, g, e, d, f); Length (f, g, e, d, f) = 4
Path                       Cycle

     a                         e

             c        d                 g

     b                         f



Path: (b, a, c); Length (b, a, c) = 2
Path: (b, d, f)
Cycle: (f, g, e, d, f); Length (f, g, e, d, f) = 4
Loop-free                   Loop


a                   e       a              e

    c      d            g       c    d         g

b                   f       b              f
a           e

    c   d       g

b           f
Eulerian path


a           e       a                   e

    c   d       g       c     d             g

b           f       b                   f
Hamiltonian path           Eulerian path


a                  e       a                   e

     c      d          g       c     d             g

b                  f       b                   f
Spanning tree               Components

                                    e
a                   e

                            d                g
     c      d           g

                                    f
b                   f

                            a
     G = (V, E).
     T ⊆ E.                         c
a   Critical node   e

    c          d        g

b   Critical edge   f
Biconnected components

a                    e

     c         d         g

b                    f
G = (V, E)
G1 = (V1, E1)
E1 = {{u,v}∈ E | u,v ∈ V1} ⊆ E.



            a                         e

Subgraph            c             d       g   Not subgraph

            b                         f
Weakly reachable = exists undirected path



     a                     e

            c      d              g

     b                     f



Strongly reachable = exists directed path
9           F
                  E
                                                     6
                            2
                                          11             D
             14                     C
                        9
                                                15
                                    10
               A
                            7               B
                                                                           ithm
                                                          i  jkstr a algor
                                            Exa mple: D
http://scg.unibe.ch/download/lectures/ei/01ComputationalThinking.pptx
9         F
     E
                                    6
             2
                          11            D
14                   C
         9
                               15
                     10
 A
             7             B
                                                          ithm
                                     i      jkstr a algor
                          Exa mple: D
∞
                     9         F
∞        E
                                            6
                 2                                   ∞
                     ∞
                              11                D
    14                   C
             9
                                   15
                         10
0
     A
                 7             B        ∞
                                                                  ithm
                                         i          jkstr a algor
                              Exa mple: D
∞
                     9         F
14       E
                                            6
                 2                                   ∞
                         9
                              11                D
    14                   C
             9
                                   15
                         10
0
     A
                 7             B        7
                                                                  ithm
                                         i          jkstr a algor
                              Exa mple: D
∞
                     9             F
14       E
                                                6
                 2                                        7 + 15 = 22
                         9 < 7 + 10
                                  11                D
    14                   C
             9
                                       15
                         10
0
     A
                 7                B         7
                                                                      ithm
                                             i          jkstr a algor
                                  Exa mple: D
∞
                           9         F
14 > 9 + 2     E
                                                  6
                       2                                   22 > 9 + 11
                               9
                                    11                D
          14                   C
                   9
                                         15
                               10
      0
             A
                       7             B        7
                                                                        ithm
                                               i          jkstr a algor
                                    Exa mple: D
20
                      9         F
11        E
                                             6
                  2                                    20
                          9
                               11                D
     14                   C
              9
                                    15
                          10
0
      A
                  7             B        7
                                                                   ithm
                                          i          jkstr a algor
                               Exa mple: D
20 < 20 + 6
                      9         F
11        E
                                             6
                  2                                    20
                          9
                               11                D
     14                   C
              9
                                    15
                          10
0
      A
                  7             B        7
                                                                   ithm
                                          i          jkstr a algor
                               Exa mple: D
a b c d e f g
                                    a 0 2 3 0 0 0 0
a                       e           b 0 0 1 0 0 0 0
    3               5       3
            2                       c 0 0 0 2 0 0 0
2       c       d               g
                                    d 0 0 0 0 5 4 0
    1               4       3       e 0 0 0 0 0 0 3
b                       f
                                    f 0 0 0 0 0 0 3
                                    g 0 0 0 0 0 0 0




                                                     Warshall
                                             : Floyd
                                     Example
a b c d e f g
                                        a 0 2 3 0 0 0 0
 a                       e              b 0 0 1 0 0 0 0
     3               5       3
             2                          c 0 0 0 2 0 0 0
2        c       d               g
                                        d 0 0 0 0 5 4 0
     1               4       3          e 0 0 0 0 0 0 3
 b                       f
                                        f 0 0 0 0 0 0 3
                                        g 0 0 0 0 0 0 0

procedure FloydWarshall ()
   for k := 1 to n
       for i := 1 to n
          for j := 1 to n
             path[i][j] = min ( path[i][j], path[i][k]+path[k][j] );


                                                           Warshall
                                                   : Floyd
                                          E xample
ing sa lesman
                l
        : Trave
Example
Tudor Gîrba
        www.tudorgirba.com




creativecommons.org/licenses/by/3.0/

Contenu connexe

Similaire à 07 - Graphs

Similaire à 07 - Graphs (20)

Taocp 2.3
Taocp 2.3Taocp 2.3
Taocp 2.3
 
Graph
GraphGraph
Graph
 
Approximation Algorithms
Approximation AlgorithmsApproximation Algorithms
Approximation Algorithms
 
Gabarito vestibular
Gabarito vestibularGabarito vestibular
Gabarito vestibular
 
Ph2100 exam answers
Ph2100 exam answersPh2100 exam answers
Ph2100 exam answers
 
Discrete maths assignment
Discrete maths assignmentDiscrete maths assignment
Discrete maths assignment
 
Worked examples projects unit 1
Worked examples projects unit 1Worked examples projects unit 1
Worked examples projects unit 1
 
Graphs In Data Structure
Graphs In Data StructureGraphs In Data Structure
Graphs In Data Structure
 
Graphs In Data Structure
Graphs In Data StructureGraphs In Data Structure
Graphs In Data Structure
 
Matrix Representation Of Graph
Matrix Representation Of GraphMatrix Representation Of Graph
Matrix Representation Of Graph
 
Gabaritos ok
Gabaritos okGabaritos ok
Gabaritos ok
 
Csr2011 june16 12_00_wagner
Csr2011 june16 12_00_wagnerCsr2011 june16 12_00_wagner
Csr2011 june16 12_00_wagner
 
XXL Graph Algorithms__HadoopSummit2010
XXL Graph Algorithms__HadoopSummit2010XXL Graph Algorithms__HadoopSummit2010
XXL Graph Algorithms__HadoopSummit2010
 
Graphs
GraphsGraphs
Graphs
 
Ficha trab solidos1 resolução
Ficha trab solidos1 resoluçãoFicha trab solidos1 resolução
Ficha trab solidos1 resolução
 
Claves guias
Claves guiasClaves guias
Claves guias
 
Bndes0109 tecnico
Bndes0109 tecnicoBndes0109 tecnico
Bndes0109 tecnico
 
graph.pptx
graph.pptxgraph.pptx
graph.pptx
 
Gabaritos Pebii
Gabaritos PebiiGabaritos Pebii
Gabaritos Pebii
 
Ca8e Ppt 6 1
Ca8e Ppt 6 1Ca8e Ppt 6 1
Ca8e Ppt 6 1
 

Plus de Tudor Girba

Beyond software evolution: Software environmentalism
Beyond software evolution: Software environmentalismBeyond software evolution: Software environmentalism
Beyond software evolution: Software environmentalismTudor Girba
 
Software craftsmanship meetup (Zurich 2015) on solving real problems without ...
Software craftsmanship meetup (Zurich 2015) on solving real problems without ...Software craftsmanship meetup (Zurich 2015) on solving real problems without ...
Software craftsmanship meetup (Zurich 2015) on solving real problems without ...Tudor Girba
 
Don't demo facts. Demo stories! (handouts)
Don't demo facts. Demo stories! (handouts)Don't demo facts. Demo stories! (handouts)
Don't demo facts. Demo stories! (handouts)Tudor Girba
 
Don't demo facts. Demo stories!
Don't demo facts. Demo stories!Don't demo facts. Demo stories!
Don't demo facts. Demo stories!Tudor Girba
 
Humane assessment on cards
Humane assessment on cardsHumane assessment on cards
Humane assessment on cardsTudor Girba
 
Underneath Scrum: Reflective Thinking
Underneath Scrum: Reflective ThinkingUnderneath Scrum: Reflective Thinking
Underneath Scrum: Reflective ThinkingTudor Girba
 
1800+ TED talks later
1800+ TED talks later1800+ TED talks later
1800+ TED talks laterTudor Girba
 
Software assessment by example (lecture at the University of Bern)
Software assessment by example (lecture at the University of Bern)Software assessment by example (lecture at the University of Bern)
Software assessment by example (lecture at the University of Bern)Tudor Girba
 
Humane assessment: Taming the elephant from the development room
Humane assessment: Taming the elephant from the development roomHumane assessment: Taming the elephant from the development room
Humane assessment: Taming the elephant from the development roomTudor Girba
 
Moose: how to solve real problems without reading code
Moose: how to solve real problems without reading codeMoose: how to solve real problems without reading code
Moose: how to solve real problems without reading codeTudor Girba
 
Software Environmentalism (ECOOP 2014 Keynote)
Software Environmentalism (ECOOP 2014 Keynote)Software Environmentalism (ECOOP 2014 Keynote)
Software Environmentalism (ECOOP 2014 Keynote)Tudor Girba
 
The emergent nature of software systems
The emergent nature of software systemsThe emergent nature of software systems
The emergent nature of software systemsTudor Girba
 
Presenting is storytelling at Uni Zurich - slides (2014-03-05)
Presenting is storytelling at Uni Zurich - slides (2014-03-05)Presenting is storytelling at Uni Zurich - slides (2014-03-05)
Presenting is storytelling at Uni Zurich - slides (2014-03-05)Tudor Girba
 
Presenting is storytelling at Uni Zurich - handouts (2014-03-05)
Presenting is storytelling at Uni Zurich - handouts (2014-03-05)Presenting is storytelling at Uni Zurich - handouts (2014-03-05)
Presenting is storytelling at Uni Zurich - handouts (2014-03-05)Tudor Girba
 
Underneath Scrum: Reflective Thinking (talk at Scrum Breakfast Bern, 2013)
Underneath Scrum: Reflective Thinking (talk at Scrum Breakfast Bern, 2013)Underneath Scrum: Reflective Thinking (talk at Scrum Breakfast Bern, 2013)
Underneath Scrum: Reflective Thinking (talk at Scrum Breakfast Bern, 2013)Tudor Girba
 
Demo-driven innovation teaser
Demo-driven innovation teaserDemo-driven innovation teaser
Demo-driven innovation teaserTudor Girba
 
Software assessment essentials (lecture at the University of Bern 2013)
Software assessment essentials (lecture at the University of Bern 2013)Software assessment essentials (lecture at the University of Bern 2013)
Software assessment essentials (lecture at the University of Bern 2013)Tudor Girba
 
Demo-driven innovation (University of Zurich, June 2013)
Demo-driven innovation (University of Zurich, June 2013)Demo-driven innovation (University of Zurich, June 2013)
Demo-driven innovation (University of Zurich, June 2013)Tudor Girba
 
Humane assessment with Moose at GOTO Aarhus 2011
Humane assessment with Moose at GOTO Aarhus 2011Humane assessment with Moose at GOTO Aarhus 2011
Humane assessment with Moose at GOTO Aarhus 2011Tudor Girba
 

Plus de Tudor Girba (20)

Beyond software evolution: Software environmentalism
Beyond software evolution: Software environmentalismBeyond software evolution: Software environmentalism
Beyond software evolution: Software environmentalism
 
Software craftsmanship meetup (Zurich 2015) on solving real problems without ...
Software craftsmanship meetup (Zurich 2015) on solving real problems without ...Software craftsmanship meetup (Zurich 2015) on solving real problems without ...
Software craftsmanship meetup (Zurich 2015) on solving real problems without ...
 
GT Spotter
GT SpotterGT Spotter
GT Spotter
 
Don't demo facts. Demo stories! (handouts)
Don't demo facts. Demo stories! (handouts)Don't demo facts. Demo stories! (handouts)
Don't demo facts. Demo stories! (handouts)
 
Don't demo facts. Demo stories!
Don't demo facts. Demo stories!Don't demo facts. Demo stories!
Don't demo facts. Demo stories!
 
Humane assessment on cards
Humane assessment on cardsHumane assessment on cards
Humane assessment on cards
 
Underneath Scrum: Reflective Thinking
Underneath Scrum: Reflective ThinkingUnderneath Scrum: Reflective Thinking
Underneath Scrum: Reflective Thinking
 
1800+ TED talks later
1800+ TED talks later1800+ TED talks later
1800+ TED talks later
 
Software assessment by example (lecture at the University of Bern)
Software assessment by example (lecture at the University of Bern)Software assessment by example (lecture at the University of Bern)
Software assessment by example (lecture at the University of Bern)
 
Humane assessment: Taming the elephant from the development room
Humane assessment: Taming the elephant from the development roomHumane assessment: Taming the elephant from the development room
Humane assessment: Taming the elephant from the development room
 
Moose: how to solve real problems without reading code
Moose: how to solve real problems without reading codeMoose: how to solve real problems without reading code
Moose: how to solve real problems without reading code
 
Software Environmentalism (ECOOP 2014 Keynote)
Software Environmentalism (ECOOP 2014 Keynote)Software Environmentalism (ECOOP 2014 Keynote)
Software Environmentalism (ECOOP 2014 Keynote)
 
The emergent nature of software systems
The emergent nature of software systemsThe emergent nature of software systems
The emergent nature of software systems
 
Presenting is storytelling at Uni Zurich - slides (2014-03-05)
Presenting is storytelling at Uni Zurich - slides (2014-03-05)Presenting is storytelling at Uni Zurich - slides (2014-03-05)
Presenting is storytelling at Uni Zurich - slides (2014-03-05)
 
Presenting is storytelling at Uni Zurich - handouts (2014-03-05)
Presenting is storytelling at Uni Zurich - handouts (2014-03-05)Presenting is storytelling at Uni Zurich - handouts (2014-03-05)
Presenting is storytelling at Uni Zurich - handouts (2014-03-05)
 
Underneath Scrum: Reflective Thinking (talk at Scrum Breakfast Bern, 2013)
Underneath Scrum: Reflective Thinking (talk at Scrum Breakfast Bern, 2013)Underneath Scrum: Reflective Thinking (talk at Scrum Breakfast Bern, 2013)
Underneath Scrum: Reflective Thinking (talk at Scrum Breakfast Bern, 2013)
 
Demo-driven innovation teaser
Demo-driven innovation teaserDemo-driven innovation teaser
Demo-driven innovation teaser
 
Software assessment essentials (lecture at the University of Bern 2013)
Software assessment essentials (lecture at the University of Bern 2013)Software assessment essentials (lecture at the University of Bern 2013)
Software assessment essentials (lecture at the University of Bern 2013)
 
Demo-driven innovation (University of Zurich, June 2013)
Demo-driven innovation (University of Zurich, June 2013)Demo-driven innovation (University of Zurich, June 2013)
Demo-driven innovation (University of Zurich, June 2013)
 
Humane assessment with Moose at GOTO Aarhus 2011
Humane assessment with Moose at GOTO Aarhus 2011Humane assessment with Moose at GOTO Aarhus 2011
Humane assessment with Moose at GOTO Aarhus 2011
 

Dernier

A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?Igalia
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CVKhem
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...apidays
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAndrey Devyatkin
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024The Digital Insurer
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobeapidays
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdflior mazor
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024SynarionITSolutions
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...DianaGray10
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoffsammart93
 

Dernier (20)

A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 

07 - Graphs

  • 1. Graphs www.tudorgirba.com
  • 2.
  • 3.
  • 4.
  • 5. G = (V, E) E = { {u,v} | u,v ∈ V} a e c d g b f
  • 6. G = (V, E) E = { {u,v} | u,v ∈ V} a e c d g b f V = { a, b, c, d, e, f, g } E = { {a,b}, {a,c}, {b,c}, {c,d}, {d,e}, {d,f}, {e,g}, {f,g} }
  • 7. G = (V, E) E = { {u,v} | u,v ∈ V} a e c d g b f V = { a, b, c, d, e, f, g } E = { {a,b}, {a,c}, {b,c}, {c,d}, {d,e}, {d,f}, {e,g}, {f,g} }
  • 8. a b c d e f g a 0 1 1 0 0 0 0 b 0 0 1 0 0 0 0 a e c 0 0 0 1 0 0 0 c d g d 0 0 0 0 1 1 0 e 0 0 0 0 0 0 1 b f f 0 0 0 0 0 0 1 g 0 0 0 0 0 0 0
  • 9. a b c d e f g a 0 1 1 0 0 0 0 b 1 0 1 0 0 0 0 a e c 1 1 0 1 0 0 0 c d g d 0 0 1 0 1 1 0 e 0 0 0 1 0 0 1 b f f 0 0 0 1 0 0 1 g 0 0 0 0 1 1 0
  • 10. a b c d e f g a 0 1 1 0 0 0 0 2 2 b 1 0 1 0 0 0 0 a e c 1 1 0 1 0 0 0 c d g d 0 0 1 0 1 1 0 3 3 2 e 0 0 0 1 0 0 1 b f f 0 0 0 1 0 0 1 2 g 0 0 0 0 1 1 0 2 2 3 3 2 2 2 Degree of a node
  • 11. a b c d e f g a 0 2 3 0 0 0 0 b 0 0 1 0 0 0 0 a e 3 5 3 c 0 0 0 2 0 0 0 2 2 c d g d 0 0 0 0 5 4 0 1 4 3 e 0 0 0 0 0 0 3 b f f 0 0 0 0 0 0 3 g 0 0 0 0 0 0 0 Weighted graphs
  • 12. Not complete Complete a a c c b b a a c c b b
  • 13. G = (V, E) ∀ e={v,w} ∈ E, v ∈ V and w ∈ W. Bipartite Not bipartite
  • 14. Path Cycle a e c d g b f Path: (b, a, c); Length (b, a, c) = 2 Path: (b, d, f) Cycle: (f, g, e, d, f); Length (f, g, e, d, f) = 4
  • 15. Path Cycle a e c d g b f Path: (b, a, c); Length (b, a, c) = 2 Path: (b, d, f) Cycle: (f, g, e, d, f); Length (f, g, e, d, f) = 4
  • 16. Path Cycle a e c d g b f Path: (b, a, c); Length (b, a, c) = 2 Path: (b, d, f) Cycle: (f, g, e, d, f); Length (f, g, e, d, f) = 4
  • 17. Loop-free Loop a e a e c d g c d g b f b f
  • 18. a e c d g b f
  • 19. Eulerian path a e a e c d g c d g b f b f
  • 20. Hamiltonian path Eulerian path a e a e c d g c d g b f b f
  • 21. Spanning tree Components e a e d g c d g f b f a G = (V, E). T ⊆ E. c
  • 22. a Critical node e c d g b Critical edge f
  • 24. G = (V, E) G1 = (V1, E1) E1 = {{u,v}∈ E | u,v ∈ V1} ⊆ E. a e Subgraph c d g Not subgraph b f
  • 25. Weakly reachable = exists undirected path a e c d g b f Strongly reachable = exists directed path
  • 26. 9 F E 6 2 11 D 14 C 9 15 10 A 7 B ithm i jkstr a algor Exa mple: D http://scg.unibe.ch/download/lectures/ei/01ComputationalThinking.pptx
  • 27. 9 F E 6 2 11 D 14 C 9 15 10 A 7 B ithm i jkstr a algor Exa mple: D
  • 28. 9 F ∞ E 6 2 ∞ ∞ 11 D 14 C 9 15 10 0 A 7 B ∞ ithm i jkstr a algor Exa mple: D
  • 29. 9 F 14 E 6 2 ∞ 9 11 D 14 C 9 15 10 0 A 7 B 7 ithm i jkstr a algor Exa mple: D
  • 30. 9 F 14 E 6 2 7 + 15 = 22 9 < 7 + 10 11 D 14 C 9 15 10 0 A 7 B 7 ithm i jkstr a algor Exa mple: D
  • 31. 9 F 14 > 9 + 2 E 6 2 22 > 9 + 11 9 11 D 14 C 9 15 10 0 A 7 B 7 ithm i jkstr a algor Exa mple: D
  • 32. 20 9 F 11 E 6 2 20 9 11 D 14 C 9 15 10 0 A 7 B 7 ithm i jkstr a algor Exa mple: D
  • 33. 20 < 20 + 6 9 F 11 E 6 2 20 9 11 D 14 C 9 15 10 0 A 7 B 7 ithm i jkstr a algor Exa mple: D
  • 34. a b c d e f g a 0 2 3 0 0 0 0 a e b 0 0 1 0 0 0 0 3 5 3 2 c 0 0 0 2 0 0 0 2 c d g d 0 0 0 0 5 4 0 1 4 3 e 0 0 0 0 0 0 3 b f f 0 0 0 0 0 0 3 g 0 0 0 0 0 0 0 Warshall : Floyd Example
  • 35. a b c d e f g a 0 2 3 0 0 0 0 a e b 0 0 1 0 0 0 0 3 5 3 2 c 0 0 0 2 0 0 0 2 c d g d 0 0 0 0 5 4 0 1 4 3 e 0 0 0 0 0 0 3 b f f 0 0 0 0 0 0 3 g 0 0 0 0 0 0 0 procedure FloydWarshall () for k := 1 to n for i := 1 to n for j := 1 to n path[i][j] = min ( path[i][j], path[i][k]+path[k][j] ); Warshall : Floyd E xample
  • 36. ing sa lesman l : Trave Example
  • 37. Tudor Gîrba www.tudorgirba.com creativecommons.org/licenses/by/3.0/