Upload
raj-gupta
View
215
Download
0
Embed Size (px)
Citation preview
7/29/2019 Graph Algorithms Screen
1/14
3. Graph Algorithm Concepts
Section authors: David R. Musser and Brian Osman.
7/29/2019 Graph Algorithms Screen
2/14
3.1. Graph Algorithm
Structure Based 3.3
'
&
$
%
'
&
$
%'&
$%
'
&$%
'
& $%
Algorithm 1.2
Input-
Specialized 1.3
Strategy-
Specialized 1.4
Sequence
Algorithm 2.1
Graph
Algorithm
Edge Comparison
Based 3.2
A graph algorithm is an algorithm (1.2) that takes one or more graphsas inputs.
Performance constraints on graph algorithms are generally expressed interms of the number of vertices (|V|) and the number of edges (|E|) in
the input graph.
Refinement of: Algorithm Specialized by Input (1.3).
http://algorithms-screen.pdf/http://algorithms-screen.pdf/http://sequence-algorithms-screen.pdf/http://algorithms-screen.pdf/http://algorithms-screen.pdf/http://algorithms-screen.pdf/7/29/2019 Graph Algorithms Screen
3/14
3.2. Edge Comparison Based Graph Algorithm
Path 3.7
#
"
!#
" !
5
423#
" !5
4235
423
Input-
Specialized 1.3
GraphAlgorithm 3.1
Edge Comparison
BasedStructure Based 3.3
All PairsShortestPath 3.4
Maximum
Flow 3.5
MinimumSpanning
Tree 3.6
Single Source
Shortest
#
" !
An edge comparison based graph algorithm is a graph algorithm (3.1)
whose computation depends on comparisons between pairs of values as-sociated with the edges of the graph. In other words, in addition to aninput graph, the algorithm requires at least one edge property map whichaffects the output of the algorithm.
Many of the well-known graph algorithms are models of this concept. Thedefinition above does not place any restriction on the vertex properties,but often a property map which serves to label the vertices is needed if
http://algorithms-screen.pdf/7/29/2019 Graph Algorithms Screen
4/14
the output of the algorithm is to be meaningful.
Refinement of: Graph Algorithm (3.1)
7/29/2019 Graph Algorithms Screen
5/14
3.3. Structure Based Graph Algorithm
#"
!#
"
!#"
!
#" ! #" ! #" !
Input-
Specialized 1.3
GraphAlgorithm 3.1
Edge Comparison
Based 3.2Structure Based
TopologicalSort 3.19
Breadth FirstSearch 3.19
Depth FirstSearch 3.5.1
A structure based graph algorithm is a graph algorithm (3.1) which
operates strictly on the structural components of the graph. No edgeor vertex property maps are required, just the sets of vertices and edgesthemselves.
There is one important point to be made. The restriction that no propertymaps are needed only applies to the input. Algorithms for computing atopological sorting (3.19) do not need any semantic information abouta graph, but do need to create a vertex property map to specify their
http://topological-sort-screen.pdf/http://dfs-screen.pdf/http://bfs-screen.pdf/http://topological-sort-screen.pdf/http://algorithms-screen.pdf/7/29/2019 Graph Algorithms Screen
6/14
output.
Refinement of: Graph Algorithm (3.1)
7/29/2019 Graph Algorithms Screen
7/14
3.4. All Pairs Shortest Path Algorithm
Johnson 3.4.1
10() 10()10 ()
Graph
Algorithm 3.1
Edge Comparison
Based 3.2
All Pairs
Shortest
Path
Maximum
Flow 3.5
MinimumSpanning
Tree 3.6
Single Source
Shortest
Path 3.7
Floyd-Warshall 3.4.2
An all pairs shortest path algorithm is any algorithm which calculates theshortest path between all pairs of vertices in a given graph. A shortest
path is defined in terms of some edge property map, whose range has awell defined ordering and summation operation. For example, if the edgesare given weights with an edge property map whose range is the integers,then a shortest path is simply the path between two vertices where thesum of weights for the edges used is smallest.
Calculating all such paths and their weights requires both an input graph,and an edge property map. Therefore, such algorithms are a refinement
http://floyd-warshall-screen.pdf/http://johnson-screen.pdf/7/29/2019 Graph Algorithms Screen
8/14
of edge comparison based algorithms (3.2).
The problem of finding the shortest path from one vertex to all other
vertices is similar, but usually solved differently, and is referred to here assingle source shortest path (3.7).
Refinement of: Edge Comparison Based (3.2)
7/29/2019 Graph Algorithms Screen
9/14
3.5. Maximum Flow Algorithm
Algorithm 1.8
'&$% '&$%'& $%
GraphAlgorithm 3.1
Edge Comparison
Based 3.2
All PairsShortestPath 3.4
Maximum
Flow
MinimumSpanning
Tree 3.6
Single Source
ShortestPath 3.7
Edmonds Karp 3.5.1
Iterative
A maximum flow algorithm is any algorithm which calculates the greatestquantity offlow a graph will allow from some sourcevertex to another sink
vertex. This is one aspect of a larger field which studies flow networks.A flow network is a directed graph (G) and an associated edge propertymap, which denotes the capacity of each edge.
A full, formal explanation of maximum flow is beyond the scope of thisdocument. However, a maximum flow can be viewed as another edgeproperty map (f) which defines how much each edge is used. No edgecan be used beyond its capacity. The total in-flow (sum of f for each
http://edmonds-karp-screen.pdf/http://algorithms-screen.pdf/7/29/2019 Graph Algorithms Screen
10/14
in-edge) at each vertex must be equal to the total out-flow (sum off foreach out-edge) at that vertex.
The sink and source vertices are two distinct nodes in the graph whichproduce and consume, respectively, the flow represented by the fproperty map. Thus, the out-flow of the souce is equal to the in-flowof the sink. The goal for maximum flow algorithms is to maximize thisvalue.
Calculating such a value requires both a graph and an edge propertymap. Algorithms to solve the problem are therefore refinements of edgecomparison based algorithms (3.2).
Refinement of: Edge Comparison Based (3.2)
7/29/2019 Graph Algorithms Screen
11/14
3.6. Minimum Spanning Tree Algorithm
Algorithm 3.6.2
#"
!
5423#" !54 235423
#" !#" !
GraphAlgorithm 3.1
Edge Comparison
Based 3.2
All PairsShortestPath 3.4
MaximumFlow 3.5
MinimumSpanning
Tree
Single Source
ShortestPath 3.7
Prims
Algorithm 3.6.1
Kruskals
#"
!
A minimum spanning tree algorithm is any algorithm which calculates
the least weight spanning tree of some graph. A spanning tree is anacyclic, connected subgraph of a given graph which includes all of itsvertices. While any graph has many spanning trees, the problem is to findthe one with the minimum weight, where the weight is defined by someedge property map whose range has both a well defined ordering and
summation operation. For example, if the edges have integer weights,then the minimum spanning tree is the tree which connects all of thevertices, and where the sum of the edge weights is smallest.
http://prim-screen.pdf/http://kruskal-screen.pdf/7/29/2019 Graph Algorithms Screen
12/14
Calculating the minimum spanning tree requires both a graph, and anedge property map. Such algorithms are therefore a refinement of edgecomparison based algorithms (3.2).
Refinement of: Edge Comparison Based (3.2)
3 7 Si l S Sh P h Al i h
7/29/2019 Graph Algorithms Screen
13/14
3.7. Single Source Shortest Path Algorithm
Algorithm 3.17
#"
!
10()#" !10()10 ()#"
!#"
!
GraphAlgorithm 3.1
Edge ComparisonBased 3.2
All PairsShortestPath 3.4
MaximumFlow 3.5
MinimumSpanningTree 3.6
Single Source
ShortestPath
DijkstrasAlgorithm 2.6.1
Bellman-Ford
#"
!
A single source shortest path algorithm is any algorithm which calculates
the shortest path from a source vertex to all other vertices in a givengraph. A shortest path is defined in terms of some edge property map,whose range has a well defined ordering and summation operation. Forexample, if the edges are given weights with an edge property map whoserange is the integers, then a shortest path is simply the path between two
vertices where the sum of weights for the edges used is smallest.
C
http://dijkstra-screen.pdf/http://bellman-ford-screen.pdf/7/29/2019 Graph Algorithms Screen
14/14
Calculating all such paths and their weights requires both an input graph,and an edge property map, so such algorithms are a refinement of edgecomparison based algorithms (3.2).
The problem of finding the shortest path between two specific verticesis a commonly examined subproblem of this one, but which requires thesame amount of time (asymptotically). Finding the shortest paths fromevery vertex to every other vertex is another similar problem which can
be solved using single source shortest path algorithms, but for whichbetter algorithms do exist. These are categorized as all pairs shortestpath algorithms (3.4).
Refinement of: Edge Comparison Based (3.2).