SlideShare une entreprise Scribd logo
1  sur  16
Télécharger pour lire hors ligne
Graph Algorithms




        Mathematical Structures
         for Computer Science
                Chapter 6	





Copyright © 2006 W.H. Freeman & Co.     MSCS Slides   Graph Algorithms
Introduction
     ●        We confine our attention to (unweighted) directed graphs
              with no parallel arcs.	

              ■    Two arcs from node a to node b would be parallel, but one
                   arc from a to b and another from b to a are not parallel arcs.	

     ●        The adjacency matrix of the graph is an n × n matrix, not
              necessarily symmetric. 	

     ●        The adjacency matrix will be a Boolean matrix, that is, a
              matrix whose only elements are 0s and 1s. 	

     ●        There is a one-to-one correspondence between an n × n
              Boolean matrix and the directed graph that the matrix
              represents. 	

                           Directed graphs	

                                                                     n×n Boolean	

                            with n nodes,	

                                                                       matrices
                           no parallel arcs	


Section 6.1                                  Directed Graphs and Binary Relations      1
Directed Graphs and Binary Relations

     ●        Suppose G is a directed graph with n nodes and no parallel
              arcs. Let N be the set of nodes.	

     ●        If (ni, nj) is an ordered pair of nodes, then there either is or
              is not an arc in G from ni to nj.	

     ●        We can use this property to define a binary relation on the
              set N. This relation is the adjacency relation of the graph.
                   	

ni ρ nj ↔ there is an arc in G from ni to nj	

     ●        Conversely, if ρ is a binary relation on a set N, we can
              define a directed graph G with N as the set of nodes, and an
              arc from ni to nj if and only if ni ρ nj. G will have no
              parallel arcs. 	





Section 6.1                           Directed Graphs and Binary Relations       2
Directed Graphs and Binary Relations

     ●        For the directed graph of the figure below, the adjacency
              relation is {(1, 2), (1, 3), (3, 3), (4, 1), (4, 2), (4, 3)}.	





     ●        For the set N {1, 2, 3, 4} and the binary relation {(1, 4),
              (2, 3), (2, 4), (4, 1)} on N, we obtain the associated
              directed graph:	





Section 6.1                            Directed Graphs and Binary Relations      3
Directed Graphs and Binary Relations

     ●        We have the following one-to-one correspondences:	




     ●        If function composition is carried out on these bijections,
              the result is a bijection that gives us a one-to-one
              correspondence between binary relations and matrices.	




     ●        Recall the reflexive, symmetric, antisymmetric, and
              transitive properties of a binary relation on a set. 	

     ●        If a binary relation on a set N has a certain property, this
              will be reflected in the corresponding graph and the
              corresponding Boolean matrix.	


Section 6.1                           Directed Graphs and Binary Relations   4
Reachability

     ●        DEFINITION: REACHABLE NODE In a directed
              graph, node nj is reachable from node ni if there is a path
              from ni to nj.	

     ●        The “reachability” property has an interesting
              interpretation in each of the three equivalent forms in
              directed graph, adjacency relation, and adjacency matrix.	

     ●        The adjacency matrix A of a directed graph G with n nodes
              and no parallel arcs will have a 1 in position i,j if there is
              an arc from ni to nj.	

     ●        Let A(2) be the Boolean matrix multiplication A × A
              given by:




Section 6.1                          Directed Graphs and Binary Relations      5
Reachability

     ●        If a term such as ai2 ∧ a2j in this sum is 0, then either ai2 = 0 or
              a2j = 0 (or both), and there is either no path of length 1 from ni
              to n2 or no path of length 1 from n2 to nj (or both). Thus there
              are no paths of length 2 from ni to nj passing through n2.	

     ●        A path of length 2 from ni to nj will exist if and only if there is a
              path of length 2 passing through at least one of the nodes from 1
              to n, that is, if and only if at least one of the terms in the sum is
              1, A(2)[i, j] = 1.	

     ●        The matrix A(2) indicates the presence or absence of length-2
              paths, this result holds for arbitrary powers and path lengths as
              well.	

     ●        THEOREM ON BOOLEAN ADJACENCY MATRICES
              AND REACHABILITY: If A is the Boolean adjacency matrix
              for a directed graph G with n nodes and no parallel arcs, then A
              (m)[i, j] = 1 if and only if there is a path of length m from node n
                                                                                    i
              to node nj. 	



Section 6.1                              Directed Graphs and Binary Relations           6
Reachability

     ●        If node nj is reachable from node ni, it is by a path of
              some length. Such a path will be shown by a 1 as the i,
              j entry in A or A(2) or A(3)…	

     ●        If there are n nodes in the graph, then any path with n
              or more arcs (n + 1 or more nodes) must have a
              repeated node. Therefore, we never need to look for a
              path from ni to nj of length greater than n.	

     ●        To determine reachability, consult element i, j in 
              A, A(2), ... , A(n).	

     ●        We can define a reachability matrix R by:
                   	

R = A ∨ A(2), ∨ ... ∨ A(n)	

     ●        nj is reachable from ni if and only if entry i, j in R is
              positive.	


Section 6.1                        Directed Graphs and Binary Relations   7
Reachability

     ●        If ρ is the adjacency relation for a graph G, we let R
              denote the binary relation of reachability (ni, nj) ∈ ρR
              exactly when there is a path in G from ni to nj.	

     ●        ρR is the transitive closure of ρ	

     ●        The three equivalent representations of adjacency
              relation, directed graph G, and adjacency matrix A,
              correspond to:	



 (ni,nj) belongs 	

                                                        R[i,j] = 1, where	

                               nj reachable from ni	

 to the transitive
                               in G	

                                      R = A ∨A(2) ∨... ∨ A(n)	

 closure of ρ	





Section 6.1                          Directed Graphs and Binary Relations                          8
Reachability Example


     ●        Given the directed graph, G with 5 nodes:	

     ●        The Adjacency Matrix is:	





              The Boolean Sum of the matrices is:	



Section 6.1                          Directed Graphs and Binary Relations   9
Reachability Example

     ●        The adjacency relation is ρ = {(1, 2), (2, 3), (3, 1), (3,
              4), (5, 1), (5, 3)}.	

     ●        Taking the transitive closure of ρ adds the following
              pairs: (1, 3), (2, 1), (2, 4), (3, 2), (5, 2), (5, 4), (1, 1),
              (1, 4), (2, 2), (3, 3).	

     ●        So we have:
              {(l, 1), (1, 2), (1, 3), (1, 4), (2, 1), (2, 2), (2, 3), (2, 4),
              (3, 1), (3, 2), (3, 3), (3, 4), (5, 1), (5, 2), (5, 3), (5, 4)}	

     ●        Notice that it agrees with matrix R.	





Section 6.1                            Directed Graphs and Binary Relations         10
Warshall’s Algorithm

     ●        For a graph G with n nodes, Warshall’s algorithm
              computes a sequence of n + 1 matrices M0, M1, M2, ... ,
              Mn. 	

     ●        For each k, 0 ≤ k ≤ n, Mk[i, j] = 1 if and only if there is a
              path in G from ni to nj whose interior nodes (i.e., nodes that
              are not the endpoints of the path) come only from the set of
              nodes {n1, n2, ... , nk}.	

     ●        Warshall’s algorithm begins with A = M0 and M1, M2,... ,
              Mn = R inductively. 	

     ●        The base case is to let M0 = A. Assume that Mk has been
              computed, Mk+1[i, j] = 1 if and only if there is a path from
              ni to nj whose interior nodes come only from the set {n1,
              n2, ... , nk+1}. 	



Section 6.1                          Directed Graphs and Binary Relations      11
Warshall’s Algorithm

     ●        There are two ways to see if Mk+1[i, j] = 1	

     1.       All the interior nodes come from {n1, n2, ... , nk}, in which
              case Mk[i, j] = 1. Any 1 entries in Mk are carried forward
              into Mk+1.	

     2.       Node nk+1 is an interior node. There must be a path
              from ni to nk+1 whose interior nodes come from {n1,
              n2, ... , nk} and a path from nk+1 to nj whose interior
              nodes come from {n1, n2, ... , nk}, so Mk[i, k + 1] = 1
              and Mk[k + 1, j] = 1.	





Section 6.1                         Directed Graphs and Binary Relations      12
Warshall’s Algorithm

     ●       ALGORITHM Warshall
             Warshall(n × n Boolean matrix M)
             //Initially, M = adjacency matrix of a directed graph
             G //with no parallel arcs
                for k = 0 to n - 1 do
                  for i = 1 to n do
                    for j = 1 to n do
                      M[i, j] = M[i, j] ∨ (M[i, k + 1] ∧ M[k + 1, j ])
                    end for
                  end for
                end for
             //at termination, M = reachability matrix of G	

          	

endWarshall	



Section 6.1                       Directed Graphs and Binary Relations      13
Warshall’s Algorithm

     ●        Informally, Warshall’s algorithm works as follows:	

     1.       Consider column k + 1 in Mk.	

     2.       For each row with a 0 entry in this column, copy that
              row to Mk+1.	

     3.       For each row with a 1 entry in this column, or that
              row with row k + 1 and write the resulting row in Mk
              +1.	





Section 6.1                      Directed Graphs and Binary Relations   14
Warshall’s Algorithm Example


     ●        Given the follow graph: 	

     ●        The initial adjacency matrix is M0	

     ●        M4= M5 = M3 (not shown)	





Section 6.1                           Directed Graphs and Binary Relations   15

Contenu connexe

Tendances

IJCER (www.ijceronline.com) International Journal of computational Engineerin...
IJCER (www.ijceronline.com) International Journal of computational Engineerin...IJCER (www.ijceronline.com) International Journal of computational Engineerin...
IJCER (www.ijceronline.com) International Journal of computational Engineerin...ijceronline
 
A study on connectivity in graph theory june 18 pdf
A study on connectivity in graph theory  june 18 pdfA study on connectivity in graph theory  june 18 pdf
A study on connectivity in graph theory june 18 pdfaswathymaths
 
Tutorial of topological_data_analysis_part_1(basic)
Tutorial of topological_data_analysis_part_1(basic)Tutorial of topological_data_analysis_part_1(basic)
Tutorial of topological_data_analysis_part_1(basic)Ha Phuong
 
Graph theory and its applications
Graph theory and its applicationsGraph theory and its applications
Graph theory and its applicationsManikanta satyala
 
Physics of Algorithms Talk
Physics of Algorithms TalkPhysics of Algorithms Talk
Physics of Algorithms Talkjasonj383
 
Note on Character Theory-summer 2013
Note on Character Theory-summer 2013Note on Character Theory-summer 2013
Note on Character Theory-summer 2013Fan Huang (Wright)
 
Application of graph theory in drug design
Application of graph theory in drug designApplication of graph theory in drug design
Application of graph theory in drug designReihaneh Safavi
 
Graph theory in network system
Graph theory in network systemGraph theory in network system
Graph theory in network systemManikanta satyala
 
Steven Duplij - Polyadic systems, representations and quantum groups
Steven Duplij - Polyadic systems, representations and quantum groupsSteven Duplij - Polyadic systems, representations and quantum groups
Steven Duplij - Polyadic systems, representations and quantum groupsSteven Duplij (Stepan Douplii)
 
Ottosen&petersson fem cap 5
Ottosen&petersson fem cap 5Ottosen&petersson fem cap 5
Ottosen&petersson fem cap 5guest0d07c9db
 
013_20160328_Topological_Measurement_Of_Protein_Compressibility
013_20160328_Topological_Measurement_Of_Protein_Compressibility013_20160328_Topological_Measurement_Of_Protein_Compressibility
013_20160328_Topological_Measurement_Of_Protein_CompressibilityHa Phuong
 
Parabolic Restricted Three Body Problem
Parabolic Restricted Three Body ProblemParabolic Restricted Three Body Problem
Parabolic Restricted Three Body ProblemEsther Barrabés Vera
 

Tendances (18)

N0747577
N0747577N0747577
N0747577
 
IJCER (www.ijceronline.com) International Journal of computational Engineerin...
IJCER (www.ijceronline.com) International Journal of computational Engineerin...IJCER (www.ijceronline.com) International Journal of computational Engineerin...
IJCER (www.ijceronline.com) International Journal of computational Engineerin...
 
A study on connectivity in graph theory june 18 pdf
A study on connectivity in graph theory  june 18 pdfA study on connectivity in graph theory  june 18 pdf
A study on connectivity in graph theory june 18 pdf
 
Tutorial of topological_data_analysis_part_1(basic)
Tutorial of topological_data_analysis_part_1(basic)Tutorial of topological_data_analysis_part_1(basic)
Tutorial of topological_data_analysis_part_1(basic)
 
64 66
64 6664 66
64 66
 
201977 1-1-1-pb
201977 1-1-1-pb201977 1-1-1-pb
201977 1-1-1-pb
 
Graph theory and its applications
Graph theory and its applicationsGraph theory and its applications
Graph theory and its applications
 
Physics of Algorithms Talk
Physics of Algorithms TalkPhysics of Algorithms Talk
Physics of Algorithms Talk
 
Eigenaxes
EigenaxesEigenaxes
Eigenaxes
 
Note on Character Theory-summer 2013
Note on Character Theory-summer 2013Note on Character Theory-summer 2013
Note on Character Theory-summer 2013
 
Application of graph theory in drug design
Application of graph theory in drug designApplication of graph theory in drug design
Application of graph theory in drug design
 
Am03102420247
Am03102420247Am03102420247
Am03102420247
 
1411.4232v1
1411.4232v11411.4232v1
1411.4232v1
 
Graph theory in network system
Graph theory in network systemGraph theory in network system
Graph theory in network system
 
Steven Duplij - Polyadic systems, representations and quantum groups
Steven Duplij - Polyadic systems, representations and quantum groupsSteven Duplij - Polyadic systems, representations and quantum groups
Steven Duplij - Polyadic systems, representations and quantum groups
 
Ottosen&petersson fem cap 5
Ottosen&petersson fem cap 5Ottosen&petersson fem cap 5
Ottosen&petersson fem cap 5
 
013_20160328_Topological_Measurement_Of_Protein_Compressibility
013_20160328_Topological_Measurement_Of_Protein_Compressibility013_20160328_Topological_Measurement_Of_Protein_Compressibility
013_20160328_Topological_Measurement_Of_Protein_Compressibility
 
Parabolic Restricted Three Body Problem
Parabolic Restricted Three Body ProblemParabolic Restricted Three Body Problem
Parabolic Restricted Three Body Problem
 

Similaire à Cpsc125 ch6sec1

CPSC 125 Ch 5 Sec 1
CPSC 125 Ch 5 Sec 1CPSC 125 Ch 5 Sec 1
CPSC 125 Ch 5 Sec 1David Wood
 
Graph in data structure
Graph in data structureGraph in data structure
Graph in data structureAbrish06
 
On the Adjacency Matrix and Neighborhood Associated with Zero-divisor Graph f...
On the Adjacency Matrix and Neighborhood Associated with Zero-divisor Graph f...On the Adjacency Matrix and Neighborhood Associated with Zero-divisor Graph f...
On the Adjacency Matrix and Neighborhood Associated with Zero-divisor Graph f...Editor IJCATR
 
Graph theory concepts complex networks presents-rouhollah nabati
Graph theory concepts   complex networks presents-rouhollah nabatiGraph theory concepts   complex networks presents-rouhollah nabati
Graph theory concepts complex networks presents-rouhollah nabatinabati
 
Elements of Graph Theory for IS.pptx
Elements of Graph Theory for IS.pptxElements of Graph Theory for IS.pptx
Elements of Graph Theory for IS.pptxmiki304759
 
DATA STRUCTURES unit 4.pptx
DATA STRUCTURES unit 4.pptxDATA STRUCTURES unit 4.pptx
DATA STRUCTURES unit 4.pptxShivamKrPathak
 
Data structure - Graph
Data structure - GraphData structure - Graph
Data structure - GraphMadhu Bala
 
Representing Graphs by Touching Domains
Representing Graphs by Touching DomainsRepresenting Graphs by Touching Domains
Representing Graphs by Touching Domainsnazlitemu
 
Deep learning book_chap_02
Deep learning book_chap_02Deep learning book_chap_02
Deep learning book_chap_02HyeongGooKang
 
Skiena algorithm 2007 lecture10 graph data strctures
Skiena algorithm 2007 lecture10 graph data strcturesSkiena algorithm 2007 lecture10 graph data strctures
Skiena algorithm 2007 lecture10 graph data strctureszukun
 
Conference Poster: Discrete Symmetries of Symmetric Hypergraph States
Conference Poster: Discrete Symmetries of Symmetric Hypergraph StatesConference Poster: Discrete Symmetries of Symmetric Hypergraph States
Conference Poster: Discrete Symmetries of Symmetric Hypergraph StatesChase Yetter
 

Similaire à Cpsc125 ch6sec1 (20)

CPSC 125 Ch 5 Sec 1
CPSC 125 Ch 5 Sec 1CPSC 125 Ch 5 Sec 1
CPSC 125 Ch 5 Sec 1
 
Graph in data structure
Graph in data structureGraph in data structure
Graph in data structure
 
Siegel
SiegelSiegel
Siegel
 
On the Adjacency Matrix and Neighborhood Associated with Zero-divisor Graph f...
On the Adjacency Matrix and Neighborhood Associated with Zero-divisor Graph f...On the Adjacency Matrix and Neighborhood Associated with Zero-divisor Graph f...
On the Adjacency Matrix and Neighborhood Associated with Zero-divisor Graph f...
 
Graph theory concepts complex networks presents-rouhollah nabati
Graph theory concepts   complex networks presents-rouhollah nabatiGraph theory concepts   complex networks presents-rouhollah nabati
Graph theory concepts complex networks presents-rouhollah nabati
 
09_DS_MCA_Graphs.pdf
09_DS_MCA_Graphs.pdf09_DS_MCA_Graphs.pdf
09_DS_MCA_Graphs.pdf
 
graph theory
graph theorygraph theory
graph theory
 
Unit 2: All
Unit 2: AllUnit 2: All
Unit 2: All
 
Stochastic Processes Homework Help
Stochastic Processes Homework Help Stochastic Processes Homework Help
Stochastic Processes Homework Help
 
Elements of Graph Theory for IS.pptx
Elements of Graph Theory for IS.pptxElements of Graph Theory for IS.pptx
Elements of Graph Theory for IS.pptx
 
DATA STRUCTURES unit 4.pptx
DATA STRUCTURES unit 4.pptxDATA STRUCTURES unit 4.pptx
DATA STRUCTURES unit 4.pptx
 
Data structure - Graph
Data structure - GraphData structure - Graph
Data structure - Graph
 
Representing Graphs by Touching Domains
Representing Graphs by Touching DomainsRepresenting Graphs by Touching Domains
Representing Graphs by Touching Domains
 
Spectral graph theory
Spectral graph theorySpectral graph theory
Spectral graph theory
 
26 spanning
26 spanning26 spanning
26 spanning
 
Network Theory
Network TheoryNetwork Theory
Network Theory
 
Deep learning book_chap_02
Deep learning book_chap_02Deep learning book_chap_02
Deep learning book_chap_02
 
Graphs.pdf
Graphs.pdfGraphs.pdf
Graphs.pdf
 
Skiena algorithm 2007 lecture10 graph data strctures
Skiena algorithm 2007 lecture10 graph data strcturesSkiena algorithm 2007 lecture10 graph data strctures
Skiena algorithm 2007 lecture10 graph data strctures
 
Conference Poster: Discrete Symmetries of Symmetric Hypergraph States
Conference Poster: Discrete Symmetries of Symmetric Hypergraph StatesConference Poster: Discrete Symmetries of Symmetric Hypergraph States
Conference Poster: Discrete Symmetries of Symmetric Hypergraph States
 

Plus de David Wood

Internet of Things (IoT) two-factor authentication using blockchain
Internet of Things (IoT) two-factor authentication using blockchainInternet of Things (IoT) two-factor authentication using blockchain
Internet of Things (IoT) two-factor authentication using blockchainDavid Wood
 
Returning to Online Privacy?
Returning to Online Privacy?Returning to Online Privacy?
Returning to Online Privacy?David Wood
 
Methods for Securing Spacecraft Tasking and Control via an Enterprise Ethereu...
Methods for Securing Spacecraft Tasking and Control via an Enterprise Ethereu...Methods for Securing Spacecraft Tasking and Control via an Enterprise Ethereu...
Methods for Securing Spacecraft Tasking and Control via an Enterprise Ethereu...David Wood
 
BlockSW 2019 Keynote
BlockSW 2019 KeynoteBlockSW 2019 Keynote
BlockSW 2019 KeynoteDavid Wood
 
Returning to Online Privacy - W3C/ANU Future of the Web Roadshow 20190221
Returning to Online Privacy - W3C/ANU Future of the Web Roadshow 20190221Returning to Online Privacy - W3C/ANU Future of the Web Roadshow 20190221
Returning to Online Privacy - W3C/ANU Future of the Web Roadshow 20190221David Wood
 
Privacy in the Smart City
Privacy in the Smart CityPrivacy in the Smart City
Privacy in the Smart CityDavid Wood
 
Controlling Complexities in Software Development
Controlling Complexities in Software DevelopmentControlling Complexities in Software Development
Controlling Complexities in Software DevelopmentDavid Wood
 
Privacy Concerns related to Verifiable Claims
Privacy Concerns related to Verifiable ClaimsPrivacy Concerns related to Verifiable Claims
Privacy Concerns related to Verifiable ClaimsDavid Wood
 
Implementing the Verifiable Claims data model
Implementing the Verifiable Claims data modelImplementing the Verifiable Claims data model
Implementing the Verifiable Claims data modelDavid Wood
 
So You Wanna be a Startup CTO 20170301
So You Wanna be a Startup CTO 20170301So You Wanna be a Startup CTO 20170301
So You Wanna be a Startup CTO 20170301David Wood
 
Functional manipulations of large data graphs 20160601
Functional manipulations of large data graphs 20160601Functional manipulations of large data graphs 20160601
Functional manipulations of large data graphs 20160601David Wood
 
When Metaphors Kill
When Metaphors KillWhen Metaphors Kill
When Metaphors KillDavid Wood
 
Secularism in Australia
Secularism in AustraliaSecularism in Australia
Secularism in AustraliaDavid Wood
 
Meditations on Writing in Paradoxes, Oxymorons, and Pleonasms
Meditations on Writing in Paradoxes, Oxymorons, and PleonasmsMeditations on Writing in Paradoxes, Oxymorons, and Pleonasms
Meditations on Writing in Paradoxes, Oxymorons, and PleonasmsDavid Wood
 
Building a writer's platform with social media
Building a writer's platform with social mediaBuilding a writer's platform with social media
Building a writer's platform with social mediaDavid Wood
 
Summary of the Hero's Journey
Summary of the Hero's JourneySummary of the Hero's Journey
Summary of the Hero's JourneyDavid Wood
 
Open by Default
Open by DefaultOpen by Default
Open by DefaultDavid Wood
 
Lod Then, Now and Next 20110926
Lod Then, Now and Next 20110926Lod Then, Now and Next 20110926
Lod Then, Now and Next 20110926David Wood
 
Linked Data ROI 20110426
Linked Data ROI 20110426Linked Data ROI 20110426
Linked Data ROI 20110426David Wood
 
Introduction to Linked Data: RDF Vocabularies
Introduction to Linked Data: RDF VocabulariesIntroduction to Linked Data: RDF Vocabularies
Introduction to Linked Data: RDF VocabulariesDavid Wood
 

Plus de David Wood (20)

Internet of Things (IoT) two-factor authentication using blockchain
Internet of Things (IoT) two-factor authentication using blockchainInternet of Things (IoT) two-factor authentication using blockchain
Internet of Things (IoT) two-factor authentication using blockchain
 
Returning to Online Privacy?
Returning to Online Privacy?Returning to Online Privacy?
Returning to Online Privacy?
 
Methods for Securing Spacecraft Tasking and Control via an Enterprise Ethereu...
Methods for Securing Spacecraft Tasking and Control via an Enterprise Ethereu...Methods for Securing Spacecraft Tasking and Control via an Enterprise Ethereu...
Methods for Securing Spacecraft Tasking and Control via an Enterprise Ethereu...
 
BlockSW 2019 Keynote
BlockSW 2019 KeynoteBlockSW 2019 Keynote
BlockSW 2019 Keynote
 
Returning to Online Privacy - W3C/ANU Future of the Web Roadshow 20190221
Returning to Online Privacy - W3C/ANU Future of the Web Roadshow 20190221Returning to Online Privacy - W3C/ANU Future of the Web Roadshow 20190221
Returning to Online Privacy - W3C/ANU Future of the Web Roadshow 20190221
 
Privacy in the Smart City
Privacy in the Smart CityPrivacy in the Smart City
Privacy in the Smart City
 
Controlling Complexities in Software Development
Controlling Complexities in Software DevelopmentControlling Complexities in Software Development
Controlling Complexities in Software Development
 
Privacy Concerns related to Verifiable Claims
Privacy Concerns related to Verifiable ClaimsPrivacy Concerns related to Verifiable Claims
Privacy Concerns related to Verifiable Claims
 
Implementing the Verifiable Claims data model
Implementing the Verifiable Claims data modelImplementing the Verifiable Claims data model
Implementing the Verifiable Claims data model
 
So You Wanna be a Startup CTO 20170301
So You Wanna be a Startup CTO 20170301So You Wanna be a Startup CTO 20170301
So You Wanna be a Startup CTO 20170301
 
Functional manipulations of large data graphs 20160601
Functional manipulations of large data graphs 20160601Functional manipulations of large data graphs 20160601
Functional manipulations of large data graphs 20160601
 
When Metaphors Kill
When Metaphors KillWhen Metaphors Kill
When Metaphors Kill
 
Secularism in Australia
Secularism in AustraliaSecularism in Australia
Secularism in Australia
 
Meditations on Writing in Paradoxes, Oxymorons, and Pleonasms
Meditations on Writing in Paradoxes, Oxymorons, and PleonasmsMeditations on Writing in Paradoxes, Oxymorons, and Pleonasms
Meditations on Writing in Paradoxes, Oxymorons, and Pleonasms
 
Building a writer's platform with social media
Building a writer's platform with social mediaBuilding a writer's platform with social media
Building a writer's platform with social media
 
Summary of the Hero's Journey
Summary of the Hero's JourneySummary of the Hero's Journey
Summary of the Hero's Journey
 
Open by Default
Open by DefaultOpen by Default
Open by Default
 
Lod Then, Now and Next 20110926
Lod Then, Now and Next 20110926Lod Then, Now and Next 20110926
Lod Then, Now and Next 20110926
 
Linked Data ROI 20110426
Linked Data ROI 20110426Linked Data ROI 20110426
Linked Data ROI 20110426
 
Introduction to Linked Data: RDF Vocabularies
Introduction to Linked Data: RDF VocabulariesIntroduction to Linked Data: RDF Vocabularies
Introduction to Linked Data: RDF Vocabularies
 

Cpsc125 ch6sec1

  • 1. Graph Algorithms Mathematical Structures for Computer Science Chapter 6 Copyright © 2006 W.H. Freeman & Co. MSCS Slides Graph Algorithms
  • 2. Introduction ●  We confine our attention to (unweighted) directed graphs with no parallel arcs. ■  Two arcs from node a to node b would be parallel, but one arc from a to b and another from b to a are not parallel arcs. ●  The adjacency matrix of the graph is an n × n matrix, not necessarily symmetric. ●  The adjacency matrix will be a Boolean matrix, that is, a matrix whose only elements are 0s and 1s. ●  There is a one-to-one correspondence between an n × n Boolean matrix and the directed graph that the matrix represents. Directed graphs n×n Boolean with n nodes, matrices no parallel arcs Section 6.1 Directed Graphs and Binary Relations 1
  • 3. Directed Graphs and Binary Relations ●  Suppose G is a directed graph with n nodes and no parallel arcs. Let N be the set of nodes. ●  If (ni, nj) is an ordered pair of nodes, then there either is or is not an arc in G from ni to nj. ●  We can use this property to define a binary relation on the set N. This relation is the adjacency relation of the graph. ni ρ nj ↔ there is an arc in G from ni to nj ●  Conversely, if ρ is a binary relation on a set N, we can define a directed graph G with N as the set of nodes, and an arc from ni to nj if and only if ni ρ nj. G will have no parallel arcs. Section 6.1 Directed Graphs and Binary Relations 2
  • 4. Directed Graphs and Binary Relations ●  For the directed graph of the figure below, the adjacency relation is {(1, 2), (1, 3), (3, 3), (4, 1), (4, 2), (4, 3)}. ●  For the set N {1, 2, 3, 4} and the binary relation {(1, 4), (2, 3), (2, 4), (4, 1)} on N, we obtain the associated directed graph: Section 6.1 Directed Graphs and Binary Relations 3
  • 5. Directed Graphs and Binary Relations ●  We have the following one-to-one correspondences: ●  If function composition is carried out on these bijections, the result is a bijection that gives us a one-to-one correspondence between binary relations and matrices. ●  Recall the reflexive, symmetric, antisymmetric, and transitive properties of a binary relation on a set. ●  If a binary relation on a set N has a certain property, this will be reflected in the corresponding graph and the corresponding Boolean matrix. Section 6.1 Directed Graphs and Binary Relations 4
  • 6. Reachability ●  DEFINITION: REACHABLE NODE In a directed graph, node nj is reachable from node ni if there is a path from ni to nj. ●  The “reachability” property has an interesting interpretation in each of the three equivalent forms in directed graph, adjacency relation, and adjacency matrix. ●  The adjacency matrix A of a directed graph G with n nodes and no parallel arcs will have a 1 in position i,j if there is an arc from ni to nj. ●  Let A(2) be the Boolean matrix multiplication A × A given by: Section 6.1 Directed Graphs and Binary Relations 5
  • 7. Reachability ●  If a term such as ai2 ∧ a2j in this sum is 0, then either ai2 = 0 or a2j = 0 (or both), and there is either no path of length 1 from ni to n2 or no path of length 1 from n2 to nj (or both). Thus there are no paths of length 2 from ni to nj passing through n2. ●  A path of length 2 from ni to nj will exist if and only if there is a path of length 2 passing through at least one of the nodes from 1 to n, that is, if and only if at least one of the terms in the sum is 1, A(2)[i, j] = 1. ●  The matrix A(2) indicates the presence or absence of length-2 paths, this result holds for arbitrary powers and path lengths as well. ●  THEOREM ON BOOLEAN ADJACENCY MATRICES AND REACHABILITY: If A is the Boolean adjacency matrix for a directed graph G with n nodes and no parallel arcs, then A (m)[i, j] = 1 if and only if there is a path of length m from node n i to node nj. Section 6.1 Directed Graphs and Binary Relations 6
  • 8. Reachability ●  If node nj is reachable from node ni, it is by a path of some length. Such a path will be shown by a 1 as the i, j entry in A or A(2) or A(3)… ●  If there are n nodes in the graph, then any path with n or more arcs (n + 1 or more nodes) must have a repeated node. Therefore, we never need to look for a path from ni to nj of length greater than n. ●  To determine reachability, consult element i, j in A, A(2), ... , A(n). ●  We can define a reachability matrix R by: R = A ∨ A(2), ∨ ... ∨ A(n) ●  nj is reachable from ni if and only if entry i, j in R is positive. Section 6.1 Directed Graphs and Binary Relations 7
  • 9. Reachability ●  If ρ is the adjacency relation for a graph G, we let R denote the binary relation of reachability (ni, nj) ∈ ρR exactly when there is a path in G from ni to nj. ●  ρR is the transitive closure of ρ ●  The three equivalent representations of adjacency relation, directed graph G, and adjacency matrix A, correspond to: (ni,nj) belongs R[i,j] = 1, where nj reachable from ni to the transitive in G R = A ∨A(2) ∨... ∨ A(n) closure of ρ Section 6.1 Directed Graphs and Binary Relations 8
  • 10. Reachability Example ●  Given the directed graph, G with 5 nodes: ●  The Adjacency Matrix is: The Boolean Sum of the matrices is: Section 6.1 Directed Graphs and Binary Relations 9
  • 11. Reachability Example ●  The adjacency relation is ρ = {(1, 2), (2, 3), (3, 1), (3, 4), (5, 1), (5, 3)}. ●  Taking the transitive closure of ρ adds the following pairs: (1, 3), (2, 1), (2, 4), (3, 2), (5, 2), (5, 4), (1, 1), (1, 4), (2, 2), (3, 3). ●  So we have: {(l, 1), (1, 2), (1, 3), (1, 4), (2, 1), (2, 2), (2, 3), (2, 4), (3, 1), (3, 2), (3, 3), (3, 4), (5, 1), (5, 2), (5, 3), (5, 4)} ●  Notice that it agrees with matrix R. Section 6.1 Directed Graphs and Binary Relations 10
  • 12. Warshall’s Algorithm ●  For a graph G with n nodes, Warshall’s algorithm computes a sequence of n + 1 matrices M0, M1, M2, ... , Mn. ●  For each k, 0 ≤ k ≤ n, Mk[i, j] = 1 if and only if there is a path in G from ni to nj whose interior nodes (i.e., nodes that are not the endpoints of the path) come only from the set of nodes {n1, n2, ... , nk}. ●  Warshall’s algorithm begins with A = M0 and M1, M2,... , Mn = R inductively. ●  The base case is to let M0 = A. Assume that Mk has been computed, Mk+1[i, j] = 1 if and only if there is a path from ni to nj whose interior nodes come only from the set {n1, n2, ... , nk+1}. Section 6.1 Directed Graphs and Binary Relations 11
  • 13. Warshall’s Algorithm ●  There are two ways to see if Mk+1[i, j] = 1 1.  All the interior nodes come from {n1, n2, ... , nk}, in which case Mk[i, j] = 1. Any 1 entries in Mk are carried forward into Mk+1. 2.  Node nk+1 is an interior node. There must be a path from ni to nk+1 whose interior nodes come from {n1, n2, ... , nk} and a path from nk+1 to nj whose interior nodes come from {n1, n2, ... , nk}, so Mk[i, k + 1] = 1 and Mk[k + 1, j] = 1. Section 6.1 Directed Graphs and Binary Relations 12
  • 14. Warshall’s Algorithm ●  ALGORITHM Warshall Warshall(n × n Boolean matrix M) //Initially, M = adjacency matrix of a directed graph G //with no parallel arcs for k = 0 to n - 1 do for i = 1 to n do for j = 1 to n do M[i, j] = M[i, j] ∨ (M[i, k + 1] ∧ M[k + 1, j ]) end for end for end for //at termination, M = reachability matrix of G endWarshall Section 6.1 Directed Graphs and Binary Relations 13
  • 15. Warshall’s Algorithm ●  Informally, Warshall’s algorithm works as follows: 1.  Consider column k + 1 in Mk. 2.  For each row with a 0 entry in this column, copy that row to Mk+1. 3.  For each row with a 1 entry in this column, or that row with row k + 1 and write the resulting row in Mk +1. Section 6.1 Directed Graphs and Binary Relations 14
  • 16. Warshall’s Algorithm Example ●  Given the follow graph: ●  The initial adjacency matrix is M0 ●  M4= M5 = M3 (not shown) Section 6.1 Directed Graphs and Binary Relations 15