The document discusses various graph algorithms and representations including:
- Adjacency lists and matrices for representing graphs
- Breadth-first search (BFS) which explores edges from a source vertex s level-by-level
- Depth-first search (DFS) which explores "deeper" first, producing a depth-first forest
- Classifying edges as tree, back, forward, or cross based on vertex colors in DFS
- Topological sorting of directed acyclic graphs (DAGs)
- Strongly connected components (SCCs) in directed graphs and using the transpose
Depth-first search (DFS) is an algorithm for traversing or searching tree or graph data structures. The algorithm starts at the root node (selecting some arbitrary node as the root node in the case of a graph) and explores as far as possible along each branch before backtracking
Discrete Mathematics - Sets. ... He had defined a set as a collection of definite and distinguishable objects selected by the means of certain rules or description. Set theory forms the basis of several other fields of study like counting theory, relations, graph theory and finite state machines.
Depth-first search (DFS) is an algorithm for traversing or searching tree or graph data structures. The algorithm starts at the root node (selecting some arbitrary node as the root node in the case of a graph) and explores as far as possible along each branch before backtracking
Discrete Mathematics - Sets. ... He had defined a set as a collection of definite and distinguishable objects selected by the means of certain rules or description. Set theory forms the basis of several other fields of study like counting theory, relations, graph theory and finite state machines.
It is related to Analysis and Design Of Algorithms Subject.Basically it describe basic of topological sorting, it's algorithm and step by step process to solve the example of topological sort.
In computer science, a data structure is a particular way of organizing data in a computer so that it can be used efficiently. Different kinds of data structures are suited to different kinds of applications, and some are highly specialized to specific tasks.
breadth-first search (BFS) is a strategy for searching in a graph when search is limited to essentially two operations
Depth-first search (DFS) is an algorithm for traversing or searching tree or graph data structures.
It is related to Analysis and Design Of Algorithms Subject.Basically it describe basic of topological sorting, it's algorithm and step by step process to solve the example of topological sort.
In computer science, a data structure is a particular way of organizing data in a computer so that it can be used efficiently. Different kinds of data structures are suited to different kinds of applications, and some are highly specialized to specific tasks.
breadth-first search (BFS) is a strategy for searching in a graph when search is limited to essentially two operations
Depth-first search (DFS) is an algorithm for traversing or searching tree or graph data structures.
Introduction to Algorithms and Asymptotic NotationAmrinder Arora
Asymptotic Notation is a notation used to represent and compare the efficiency of algorithms. It is a concise notation that deliberately omits details, such as constant time improvements, etc. Asymptotic notation consists of 5 commonly used symbols: big oh, small oh, big omega, small omega, and theta.
A Distributed File System(DFS) is simply a classical model of a file system distributed across multiple machines.The purpose is to promote sharing of dispersed files.
Dynamic Programming design technique is one of the fundamental algorithm design techniques, and possibly one of the ones that are hardest to master for those who did not study it formally. In these slides (which are continuation of part 1 slides), we cover two problems: maximum value contiguous subarray, and maximum increasing subsequence.
graphin-c1.png
graphin-c1.txt
1: 2
2: 3 8
3: 4
4: 5
5: 3
6: 7
7: 3 6 8
8: 1 9
9: 1
graphin-c2.jpg
graphin-c2.txt
1: 2 9
2: 3 8
3: 4
4: 5 9
5: 3
6: 7
7: 3 6 8
8: 1
9:
graphin-DAG.png
graphin-DAG.txt
1: 2
2: 3 8
3: 4
4: 5
5: 9
6: 4 7
7: 3 8
8: 9
9:
CS 340 Programming Assignment III:
Topological Sort
Description: You are to implement the Depth-First Search (DFS) based algorithm for (i)
testing whether or not the input directed graph G is acyclic (a DAG), and (ii) if G is a DAG,
topologically sorting the vertices of G and outputting the topologically sorted order.
I/O Specifications: You will prompt the user from the console to select an input graph
filename, including the sample file graphin.txt as an option. The graph input files must be of
the following adjacency list representation where each xij is the j'th neighbor of vertex i (vertex
labels are 1 through n):
1: x11 x12 x13 ...
2: x21 x22 x23 ...
.
.
n: xn1 xn2 xn3 ...
Your output will be to the console. You will first output whether or not the graph is acyclic. If
the graph is NOT acyclic, then you will output the set of back edges you have detected during
DFS. Otherwise, if the graph is acyclic, then you will output the vertices in topologically
sorted order.
Algorithmic specifications:
Your algorithm must use DFS appropriately and run in O(E + V) time on any input graph. You will
need to keep track of edge types and finish times so that you can use DFS for detecting
cyclicity/acyclicity and topologically sorting if the graph is a DAG. You may implement your graph
class as you wish so long as your overall algorithm runs correctly and efficiently.
What to Turn in: You must turn in a single zipped file containing your source code, a Makefile
if your language must be compiled, appropriate input and output files, and a README file
indicating how to execute your program (especially if not written in C++ or Java). Refer to
proglag.pdf for further specifications.
This assignment is due by MIDNIGHT of Monday, February 19. Late submissions
carry a minus 40% per-day late penalty.
Sheet1Name:Possible:Score:Comments:10Graph structure with adjacency list representationDFS16Correct and O(V+E) time10Detecting cycles, is graph DAG?Topological Sort16Correctness of Topo-Sort algorithm and output18No problems in compilation and execution? Non-compiling projects receive max total 10 points, and code that compiles but crashes during execution receives max total 18 points.700Total
&"Helvetica,Regular"&12&K000000&P
Sheet2
&"Helvetica,Regular"&12&K000000&P
Sheet3
&"Helvetica,Regular"&12&K000000&P
DFS and topological sort
CS340
Depth first search
breadth
depth
Search "deeper" whenever possible
*example shows discovery times
Depth first search
Input: G = (V,E), directed or undirected.
No source vertex is given!
Output: 2 timestamps on each vertex:
v.d discovery time
v.f finishing time
These will be useful ...
3. Adjacency List Representation of a Graph For each u є V , the adjacency list Adj [ u ] contains all the vertices v such that there is an edge ( u , v ) є E .
4. Adjacency Matrix Representation of a Graph The adjacency-matrix representation of a graph G consists of a | V | × | V | matrix A = ( aij ) such that a ij =1 if (i,j) є E =o otherwise
14. Depth-first Search The strategy followed by depth-first search is, as its name implies, to search "deeper" in the graph whenever possible.
15. Depth-first Search The predecessor sub-graph of a depth-first search forms a depth-first forest composed of several depth-first trees . The edges in Eπ are called tree edges .
16.
17. Depth-first Search Each vertex v has two timestamps: the first timestamp d [ v ] records when v is first discovered (and grayed), and the second timestamp f [ v ] records when the search finishes examining v 's adjacency list (and blackens v ).
23. Classification of Edges We can define four edge types in terms of the depth-first forest Gπ produced by a depth-first search on G . 1. Tree edges are edges in the depth-first forest Gπ . Edge ( u , v ) is a tree edge if v was first discovered by exploring edge ( u , v ). 2. Back edges are those edges ( u , v ) connecting a vertex u to an ancestor v in a depth first tree. Self-loops, which may occur in directed graphs, are considered to be back edges.
24. Classification of Edges 3. Forward edges are those non-tree edges ( u , v ) connecting a vertex u to a descendant v in a depth-first tree. 4. Cross edges are all other edges.
25. Classification of Edges The DFS algorithm can be modified to classify edges as it encounters them. The key idea is that each edge ( u , v ) can be classified by the color of the vertex v that is reached when the edge is first explored . 1. WHITE indicates a tree edge, 2. GRAY indicates a back edge, and 3. BLACK indicates a forward or cross edge.
26. Topological Sort A topological sort of a graph can be viewed as an ordering of its vertices along a horizontal line so that all directed edges go from left to right.
29. Strongly Connected Components A strongly connected component of a directed graph G=(V,E) is a maximal set of vertices such that for every pair of vertices u and v in C , we have both u ~v and v ~u
31. Strongly Connected Components The transpose of a graph G, G T =(V,E T ) is used for finding the strongly connected components of a graph G=(V,E) It is interesting to observe that G and G T have exactly the same strongly connected components