The document defines and provides examples of key concepts related to graphs and graph traversal algorithms. It describes what a graph is comprised of (vertices and edges), common graph types (directed/undirected, weighted/unweighted), graph terminology (degree, path, cycle, connectivity), and graph traversal algorithms like depth-first search (DFS) and breadth-first search (BFS). It provides pseudocode for DFS and BFS algorithms and analyzes their runtime and ability to find optimal paths.
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
Traversal is a process to visit all the nodes of a tree and may print their values too. Because, all nodes are connected via edges (links) we always start from the root (head) node. That is, we cannot randomly access a node in a tree.
Trees. Defining, Creating and Traversing Trees. Traversing the File System
Binary Search Trees. Balanced Trees
Graphs and Graphs Traversal Algorithms
Exercises: Working with Trees and Graphs
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
Traversal is a process to visit all the nodes of a tree and may print their values too. Because, all nodes are connected via edges (links) we always start from the root (head) node. That is, we cannot randomly access a node in a tree.
Trees. Defining, Creating and Traversing Trees. Traversing the File System
Binary Search Trees. Balanced Trees
Graphs and Graphs Traversal Algorithms
Exercises: Working with Trees and Graphs
Breadth First Search & Depth First SearchKevin Jadiya
The slides attached here describes how Breadth first search and Depth First Search technique is used in Traversing a graph/tree with Algorithm and simple code snippet.
BREADTH FIRST SEARCH (bfs)
Inventor of bfs
Example of bfs
Algorithm of bfs
Complexity
Time Complexity
Space Complexity
Queue in bfs
bfs optimal
Container of bfs
Completeness of bfs
Shallowest node
Uninformed search technique
Application of bfs
Conclusion
Thank you for visiting.......
A presentation on prim's and kruskal's algorithmGaurav Kolekar
This slides are for a presentation on Prim's and Kruskal's algorithm. Where I have tried to explain how both the algorithms work, their similarities and their differences.
Breadth First Search & Depth First SearchKevin Jadiya
The slides attached here describes how Breadth first search and Depth First Search technique is used in Traversing a graph/tree with Algorithm and simple code snippet.
BREADTH FIRST SEARCH (bfs)
Inventor of bfs
Example of bfs
Algorithm of bfs
Complexity
Time Complexity
Space Complexity
Queue in bfs
bfs optimal
Container of bfs
Completeness of bfs
Shallowest node
Uninformed search technique
Application of bfs
Conclusion
Thank you for visiting.......
A presentation on prim's and kruskal's algorithmGaurav Kolekar
This slides are for a presentation on Prim's and Kruskal's algorithm. Where I have tried to explain how both the algorithms work, their similarities and their differences.
introduction and representation of graph.
graph is collection of points and vertices.
there are 2 types of the graph 1. directed
2. undirected graph.
representation of graph 2 ways
Adjacency matrix
Adjacency list
BFS is the most commonly used approach. BFS is a traversing algorithm where you should start traversing from a selected node (source or starting node) and traverse the graph layerwise thus exploring the neighbor nodes (nodes which are directly connected to the source node.
1. Graph Data Structure
A graph is a pictorial representation of a set of objects where some pairs of objects are connected by links. The interconnected objects are represented by points termed as vertices, and the links that connect the vertices are called edges.
Formally, a graph is a pair of sets (V, E), where V is the set of vertices and Eis the set of edges, connecting the pairs of vertices. Take a look at the following graph
V = {a, b, c, d, e}
E = {ab, ac, bd, cd, de}
Honest Reviews of Tim Han LMA Course Program.pptxtimhan337
Personal development courses are widely available today, with each one promising life-changing outcomes. Tim Han’s Life Mastery Achievers (LMA) Course has drawn a lot of interest. In addition to offering my frank assessment of Success Insider’s LMA Course, this piece examines the course’s effects via a variety of Tim Han LMA course reviews and Success Insider comments.
Synthetic Fiber Construction in lab .pptxPavel ( NSTU)
Synthetic fiber production is a fascinating and complex field that blends chemistry, engineering, and environmental science. By understanding these aspects, students can gain a comprehensive view of synthetic fiber production, its impact on society and the environment, and the potential for future innovations. Synthetic fibers play a crucial role in modern society, impacting various aspects of daily life, industry, and the environment. ynthetic fibers are integral to modern life, offering a range of benefits from cost-effectiveness and versatility to innovative applications and performance characteristics. While they pose environmental challenges, ongoing research and development aim to create more sustainable and eco-friendly alternatives. Understanding the importance of synthetic fibers helps in appreciating their role in the economy, industry, and daily life, while also emphasizing the need for sustainable practices and innovation.
Model Attribute Check Company Auto PropertyCeline George
In Odoo, the multi-company feature allows you to manage multiple companies within a single Odoo database instance. Each company can have its own configurations while still sharing common resources such as products, customers, and suppliers.
How to Make a Field invisible in Odoo 17Celine George
It is possible to hide or invisible some fields in odoo. Commonly using “invisible” attribute in the field definition to invisible the fields. This slide will show how to make a field invisible in odoo 17.
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdfTechSoup
In this webinar you will learn how your organization can access TechSoup's wide variety of product discount and donation programs. From hardware to software, we'll give you a tour of the tools available to help your nonprofit with productivity, collaboration, financial management, donor tracking, security, and more.
Safalta Digital marketing institute in Noida, provide complete applications that encompass a huge range of virtual advertising and marketing additives, which includes search engine optimization, virtual communication advertising, pay-per-click on marketing, content material advertising, internet analytics, and greater. These university courses are designed for students who possess a comprehensive understanding of virtual marketing strategies and attributes.Safalta Digital Marketing Institute in Noida is a first choice for young individuals or students who are looking to start their careers in the field of digital advertising. The institute gives specialized courses designed and certification.
for beginners, providing thorough training in areas such as SEO, digital communication marketing, and PPC training in Noida. After finishing the program, students receive the certifications recognised by top different universitie, setting a strong foundation for a successful career in digital marketing.
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...Levi Shapiro
Letter from the Congress of the United States regarding Anti-Semitism sent June 3rd to MIT President Sally Kornbluth, MIT Corp Chair, Mark Gorenberg
Dear Dr. Kornbluth and Mr. Gorenberg,
The US House of Representatives is deeply concerned by ongoing and pervasive acts of antisemitic
harassment and intimidation at the Massachusetts Institute of Technology (MIT). Failing to act decisively to ensure a safe learning environment for all students would be a grave dereliction of your responsibilities as President of MIT and Chair of the MIT Corporation.
This Congress will not stand idly by and allow an environment hostile to Jewish students to persist. The House believes that your institution is in violation of Title VI of the Civil Rights Act, and the inability or
unwillingness to rectify this violation through action requires accountability.
Postsecondary education is a unique opportunity for students to learn and have their ideas and beliefs challenged. However, universities receiving hundreds of millions of federal funds annually have denied
students that opportunity and have been hijacked to become venues for the promotion of terrorism, antisemitic harassment and intimidation, unlawful encampments, and in some cases, assaults and riots.
The House of Representatives will not countenance the use of federal funds to indoctrinate students into hateful, antisemitic, anti-American supporters of terrorism. Investigations into campus antisemitism by the Committee on Education and the Workforce and the Committee on Ways and Means have been expanded into a Congress-wide probe across all relevant jurisdictions to address this national crisis. The undersigned Committees will conduct oversight into the use of federal funds at MIT and its learning environment under authorities granted to each Committee.
• The Committee on Education and the Workforce has been investigating your institution since December 7, 2023. The Committee has broad jurisdiction over postsecondary education, including its compliance with Title VI of the Civil Rights Act, campus safety concerns over disruptions to the learning environment, and the awarding of federal student aid under the Higher Education Act.
• The Committee on Oversight and Accountability is investigating the sources of funding and other support flowing to groups espousing pro-Hamas propaganda and engaged in antisemitic harassment and intimidation of students. The Committee on Oversight and Accountability is the principal oversight committee of the US House of Representatives and has broad authority to investigate “any matter” at “any time” under House Rule X.
• The Committee on Ways and Means has been investigating several universities since November 15, 2023, when the Committee held a hearing entitled From Ivory Towers to Dark Corners: Investigating the Nexus Between Antisemitism, Tax-Exempt Universities, and Terror Financing. The Committee followed the hearing with letters to those institutions on January 10, 202
Unit 8 - Information and Communication Technology (Paper I).pdfThiyagu K
This slides describes the basic concepts of ICT, basics of Email, Emerging Technology and Digital Initiatives in Education. This presentations aligns with the UGC Paper I syllabus.
The French Revolution, which began in 1789, was a period of radical social and political upheaval in France. It marked the decline of absolute monarchies, the rise of secular and democratic republics, and the eventual rise of Napoleon Bonaparte. This revolutionary period is crucial in understanding the transition from feudalism to modernity in Europe.
For more information, visit-www.vavaclasses.com
Biological screening of herbal drugs: Introduction and Need for
Phyto-Pharmacological Screening, New Strategies for evaluating
Natural Products, In vitro evaluation techniques for Antioxidants, Antimicrobial and Anticancer drugs. In vivo evaluation techniques
for Anti-inflammatory, Antiulcer, Anticancer, Wound healing, Antidiabetic, Hepatoprotective, Cardio protective, Diuretics and
Antifertility, Toxicity studies as per OECD guidelines
1. Reference: Data Structures and Algorithm
Analysis in C++ by Weiss Ch. 9
Prepared by Nisha Soms
Graph Traversals
2. 2
Graphs
2
graph: A data structure containing:
a set of vertices V, (sometimes called nodes)
a set of edges E, where an edge
represents a connection between 2 vertices.
Graph G = (V, E)
an edge is a pair (v, w) where v, w are in V
the graph at right:
V = {a, b, c, d}
E = {(a, c), (b, c), (b, d), (c, d)}
degree: number of edges touching a given vertex.
at right: a=1, b=2, c=3, d=2
a
c
b
d
3. 3
Graph examples
3
Web pages with links
Methods in a program that call each other
Road maps (e.g., Google maps)
Airline routes
Facebook friends
Course pre-requisites
Family trees
Paths through a maze
4. 4
Paths
4
path: A path from vertex a to b is a sequence of edges that
can be followed starting from a to reach b.
can be represented as vertices visited, or edges taken
example, one path from V to Z: {b, h} or {V, X, Z}
What are two paths from U to Y?
path length: Number of vertices
or edges contained in the path.
neighbor or adjacent: Two vertices
connected directly by an edge.
example: V and X
X
U
V
W
Z
Y
a
c
b
e
d
f
g
h
5. 5
Reachability & Connectedness
5
reachable: Vertex a is reachable from b
if a path exists from a to b.
connected: A graph is connected if every
vertex is reachable from any other.
strongly connected: When every vertex
has an edge to every other vertex.
X
U
V
W
Z
Y
a
c
b
e
d
f
g
h
a
c
b
d
a
c
b
d
e
6. 6
Loops and cycles
6
cycle: A path that begins and ends at the same node.
example: {b, g, f, c, a} or {V, X, Y, W, U, V}.
example: {c, d, a} or {U, W, V, U}.
acyclic graph: One that does
not contain any cycles.
loop: An edge directly from
a node to itself.
Many graphs don't allow loops.
X
U
V
W
Z
Y
a
c
b
e
d
f
g
h
7. 7
Weighted graphs
7
weight: Cost associated with a given edge.
Some graphs have weighted edges, and some are
unweighted.
Edges in an unweighted graph can be thought of as having
equal weight (e.g. all 0, or all 1, etc.)
Most graphs do not allow negative weights.
example: graph of airline flights, weighted by miles
between cities:
ORD
PVD
MIA
DFW
SFO
LAX
LGA
HNL
8. 8
Directed graphs
8
directed graph ("digraph"): One where edges are one-way
connections between vertices.
If graph is directed, a vertex has a separate in/out degree.
A digraph can be weighted or unweighted.
Is the graph below connected? Why or why not?
a
d
b
e
g
f
c
9. 9
Linked Lists, Trees, Graphs
9
A binary tree is a graph with some restrictions:
The tree is an unweighted, directed, acyclic graph (DAG).
Each node's in-degree is at most 1, and out-degree is at most
2.
There is exactly one path from the root to every node.
A linked list is also a graph:
Unweighted DAG.
In/out degree of at most 1 for all nodes.
F
B
A E
K
H
J
G
A B D
C
10. 10
Searching for paths
10
Searching for a path from one vertex to another:
Sometimes, we just want any path (or want to know there is a
path).
Sometimes, we want to minimize path length (# of edges).
Sometimes, we want to minimize path cost (sum of edge
weights).
What is the shortest path from MIA to SFO?
Which path has the minimum cost?
ORD
PVD
MIA
DFW
SFO
LAX
LGA
HNL
$500
11. 11
Depth-first search
11
Depth-first search (DFS): Finds a path between two
vertices by exploring each possible path as far as possible
before backtracking.
Often implemented recursively.
Many graph algorithms involve visiting or marking vertices.
Depth-first paths from a to all vertices (assuming ABC edge
order):
to b: {a, b}
to c: {a, b, e, f, c}
to d: {a, d}
to e: {a, b, e}
to f: {a, b, e, f}
a
e
b c
h
g
d f
12. 12
DFS pseudocode
12
function dfs(v1, v2):
dfs(v1, v2, { }).
function dfs(v1, v2, path):
path += v1.
mark v1 as visited.
if v1 is v2:
a path is found!
for each unvisited neighbor n of v1:
if dfs(n, v2, path) finds a path: a path is found!
path -= v1. // path is not found.
a
e
b c
h
g
d f
13. 13
DFS observations
13
discovery: DFS is guaranteed to
find a path if one exists.
retrieval: It is easy to retrieve exactly
what the path is (the sequence of
edges taken) if we find it
optimality: not optimal. DFS is guaranteed to find a path,
not necessarily the best/shortest path
Example: dfs(a, f) returns {a, d, c, f} rather than {a, d, f}.
a
e
b c
h
g
d f
14. 14
Breadth-first search
14
Breadth-first search (BFS): Finds a path between two
nodes by taking one step down all paths and then
immediately backtracking.
Often implemented by maintaining a queue of vertices to visit.
BFS always returns the shortest path (the one with the
fewest edges) between the start and the end vertices.
to b: {a, b}
to c: {a, e, f, c}
to d: {a, d}
to e: {a, e}
to f: {a, e, f}
to g: {a, d, g}
to h: {a, d, h}
a
e
b c
h
g
d f
15. 15
BFS pseudocode
15
function bfs(v1, v2):
queue := {v1}.
mark v1 as visited.
while queue is not empty:
v := queue.removeFirst().
if v is v2:
a path is found!
for each unvisited neighbor n of v:
mark n as visited.
queue.addLast(n).
// path is not found.
a
e
b c
h
g
d f
16. 16
BFS observations
16
Optimality:
always finds the shortest path (fewest edges).
In unweighted graphs, finds optimal cost path.
In weighted graphs, not always optimal cost.
Retrieval: harder to reconstruct the actual sequence of
vertices or edges in the path once you find it
conceptually, BFS is exploring many possible paths in parallel,
so it's not easy to store a path array/list in progress
solution: We can keep track of the path by storing
predecessors for each vertex (each vertex can store a
reference to a previous vertex).
DFS uses less memory than BFS, easier to reconstruct the
a
e
b c
h
g
d f
17. 17
DFS, BFS runtime
17
What is the expected runtime of DFS and BFS, in terms of
the number of vertices V and the number of edges E ?
Answer: O(|V| + |E|)
where |V| = number of vertices, |E| = number of edges
Must potentially visit every node and/or examine every edge
once.
18. 18
BFS that finds path
18
function bfs(v1, v2):
queue := {v1}.
mark v1 as visited.
while queue is not empty:
v := queue.removeFirst().
if v is v2:
a path is found! (reconstruct it by following .prev back
to v1.)
for each unvisited neighbor n of v:
mark n as visited. (set n.prev = v.)
queue.addLast(n).
// path is not found.
a
e
b c
h
g
d f
prev