This document defines key graph concepts like paths, cycles, degrees of vertices, and different types of graphs like trees, forests, and directed acyclic graphs. It also describes common graph representations like adjacency matrices and lists. Finally, it covers graph traversal algorithms like breadth-first search and depth-first search, outlining their time complexities and providing examples of their process.
A graph G consists of a non empty set V called the set of nodes (points, vertices) of the graph, a set E, which is the set of edges of the graph and a mapping from the set of edges E to a pair of elements of V.
Any two nodes, which are connected by an edge in a graph are called "adjacent nodes".
In a graph G(V,E) an edge which is directed from one node to another is called a "directed edge", while an edge which has no specific direction is called an "undirected edge". A graph in which every edge is directed is called a "directed graph" or a "digraph". A graph in which every edge is undirected is called an "undirected graph".
If some of edges are directed and some are undirected in a graph then the graph is called a "mixed graph".
Any graph which contains some parallel edges is called a "multigraph".
If there is no more than one edge but a pair of nodes then, such a graph is called "simple graph."
A graph in which weights are assigned to every edge is called a "weighted graph".
In a graph, a node which is not adjacent to any other node is called "isolated node".
A graph containing only isolated nodes is called a "null graph". In a directed graph for any node v the number of edges which have v as initial node is called the "outdegree" of the node v. The number of edges to have v as their terminal node is called the "Indegree" of v and Sum of outdegree and indegree of a node v is called its total degree.
A graph G consists of a non empty set V called the set of nodes (points, vertices) of the graph, a set E, which is the set of edges of the graph and a mapping from the set of edges E to a pair of elements of V.
Any two nodes, which are connected by an edge in a graph are called "adjacent nodes".
In a graph G(V,E) an edge which is directed from one node to another is called a "directed edge", while an edge which has no specific direction is called an "undirected edge". A graph in which every edge is directed is called a "directed graph" or a "digraph". A graph in which every edge is undirected is called an "undirected graph".
If some of edges are directed and some are undirected in a graph then the graph is called a "mixed graph".
Any graph which contains some parallel edges is called a "multigraph".
If there is no more than one edge but a pair of nodes then, such a graph is called "simple graph."
A graph in which weights are assigned to every edge is called a "weighted graph".
In a graph, a node which is not adjacent to any other node is called "isolated node".
A graph containing only isolated nodes is called a "null graph". In a directed graph for any node v the number of edges which have v as initial node is called the "outdegree" of the node v. The number of edges to have v as their terminal node is called the "Indegree" of v and Sum of outdegree and indegree of a node v is called its total degree.
Graph in data structure it gives you the information of the graph application. How to represent the Graph and also Graph Travesal is also there many terms are there related to garph
This Presentation Explains a very Important topic of Data Structure in Programming which is Graphs and Methods of Graph Traversing.
I think this presentation will help you in understanding the Data Structure Graph and its Traversing Methods.
A Graph is a non-linear data structure, which consists of vertices(or nodes) connected by edges(or arcs) where edges may be directed or undirected.
Graphs are a powerful and versatile data structure that easily allow you to represent real life relationships between different types of data (nodes).
3. We will discuss 3 types of graphs
>BASIC TERMINOLOGIES
>REPRESENTATION OF GRAPH
>OPERATIONS ON GRAPH
4. BASIC TERMINOLOGIES
A directed graph G is defined as an ordered pair (V, E) where, V is a set of vertices and the ordered pairs in E are called edges on V. A directed graph can be represented geometrically as a set of marked points (called vertices) V with a set of arrows (called edges) E between pairs of points (or vertex or nodes) so that there is at most one arrow from one vertex to another vertex.
5. BASIC
TERMINOLOGIES
For example, Figure shows a directed graph, where G = {a, b, c, d }, {(a, b),
(a, d), (d, b), (d, d), (c, c)}
6. which shows the distance in km between four metropolitan cities in India. Here V = {N, K, M, C,} E = {(N, K), (N,M,), (M,K), (M,C), (K,C)} We
= {55,47, 39, 27, 113} and Wv = {N, K, M, C} The weight at the vertices is not necessary to maintain have become the set Wv and V are same.
An undirected graph is said to be connected if there exist a path from any vertex to any other vertex. Otherwise it is said to be disconnected
7.shows the disconnected graph, where the vertex c is not connected to the graph
8.The graph is a mathematical structure and finds its application in many areas, where the problem is to be solved by computers. The problems related to graph G must be represented in computer memory using any suitable data structure to solve the same. There are two standard ways of maintaining a graph G in the memory of a computer.
9.Sequential representation of a graph using adjacent
Linked representation of a graph using linked list
10.In this representation (also called
adjacency list representation), we store
a graph as a linked structure. First we
store all the vertices of the graph in a list
and then each adjacent vertices will be
represented using linked list node. Here terminal vertex of an edge is stored in a structure node and linked to a corresponding initial vertex in the list
11.The weighted graph can be represented using a linked list by storing the corresponding weight along with the terminal vertex of the edge. Consider a weighted graph in Figure, it can be represented using a linked list as in Figure
12. Input the total number of vertices in the graph, say n
Allocate the memory dynamically for the vertices to store in list array
Input the first vertex and the vertices through which it has edge(s) by linking the node from list array through nodes.
Repeat the process by incrementing the list array to add other vertices and edges.
Exit.
13.Input an edge to be searched
Search for an initial vertex of edge in list arrays by incrementing the array
index.
Once it is found, search through the link list for the terminal vertex of the edge.
If found display “the edge is present in the graph”.
Then delete the node where the terminal vertex is found and rearrange the link list.
Exit
Graph in data structure it gives you the information of the graph application. How to represent the Graph and also Graph Travesal is also there many terms are there related to garph
This Presentation Explains a very Important topic of Data Structure in Programming which is Graphs and Methods of Graph Traversing.
I think this presentation will help you in understanding the Data Structure Graph and its Traversing Methods.
A Graph is a non-linear data structure, which consists of vertices(or nodes) connected by edges(or arcs) where edges may be directed or undirected.
Graphs are a powerful and versatile data structure that easily allow you to represent real life relationships between different types of data (nodes).
3. We will discuss 3 types of graphs
>BASIC TERMINOLOGIES
>REPRESENTATION OF GRAPH
>OPERATIONS ON GRAPH
4. BASIC TERMINOLOGIES
A directed graph G is defined as an ordered pair (V, E) where, V is a set of vertices and the ordered pairs in E are called edges on V. A directed graph can be represented geometrically as a set of marked points (called vertices) V with a set of arrows (called edges) E between pairs of points (or vertex or nodes) so that there is at most one arrow from one vertex to another vertex.
5. BASIC
TERMINOLOGIES
For example, Figure shows a directed graph, where G = {a, b, c, d }, {(a, b),
(a, d), (d, b), (d, d), (c, c)}
6. which shows the distance in km between four metropolitan cities in India. Here V = {N, K, M, C,} E = {(N, K), (N,M,), (M,K), (M,C), (K,C)} We
= {55,47, 39, 27, 113} and Wv = {N, K, M, C} The weight at the vertices is not necessary to maintain have become the set Wv and V are same.
An undirected graph is said to be connected if there exist a path from any vertex to any other vertex. Otherwise it is said to be disconnected
7.shows the disconnected graph, where the vertex c is not connected to the graph
8.The graph is a mathematical structure and finds its application in many areas, where the problem is to be solved by computers. The problems related to graph G must be represented in computer memory using any suitable data structure to solve the same. There are two standard ways of maintaining a graph G in the memory of a computer.
9.Sequential representation of a graph using adjacent
Linked representation of a graph using linked list
10.In this representation (also called
adjacency list representation), we store
a graph as a linked structure. First we
store all the vertices of the graph in a list
and then each adjacent vertices will be
represented using linked list node. Here terminal vertex of an edge is stored in a structure node and linked to a corresponding initial vertex in the list
11.The weighted graph can be represented using a linked list by storing the corresponding weight along with the terminal vertex of the edge. Consider a weighted graph in Figure, it can be represented using a linked list as in Figure
12. Input the total number of vertices in the graph, say n
Allocate the memory dynamically for the vertices to store in list array
Input the first vertex and the vertices through which it has edge(s) by linking the node from list array through nodes.
Repeat the process by incrementing the list array to add other vertices and edges.
Exit.
13.Input an edge to be searched
Search for an initial vertex of edge in list arrays by incrementing the array
index.
Once it is found, search through the link list for the terminal vertex of the edge.
If found display “the edge is present in the graph”.
Then delete the node where the terminal vertex is found and rearrange the link list.
Exit
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.
Artificial Bee Colony (ABC) is a swarm
optimization technique. This algorithm generally used to solve
nonlinear and complex problems. ABC is one of the simplest
and up to date population based probabilistic strategy for
global optimization. Analogous to other population based
algorithms, ABC also has some drawbacks computationally
pricey due to its sluggish temperament of search procedure.
The solution search equation of ABC is notably motivated by a
haphazard quantity which facilitates in exploration at the cost
of exploitation of the search space. Due to the large step size in
the solution search equation of ABC there are chances of
skipping the factual solution are higher. For that reason, this
paper introduces a new search strategy in order to balance the
diversity and convergence capability of the ABC. Both
employed bee phase and onlooker bee phase are improved
with help of a local search strategy stimulated by memetic
algorithm. This paper also proposes a new strategy for fitness
calculation and probability calculation. The proposed
algorithm is named as Improved Memetic Search in ABC
(IMeABC). It is tested over 13 impartial benchmark functions
of different complexities and two real word problems are also
considered to prove proposed algorithms superiority over
original ABC algorithm and its recent variants
Spider Monkey optimization (SMO) algorithm is newest addition in class of swarm intelligence. SMO is a population based stochastic meta-heuristic. It is motivated by intelligent foraging behaviour of fission fusion structured social creatures. SMO is a very good option for complex optimization problems. This paper proposed a modified strategy in order to enhance performance of original SMO. This paper introduces a position update strategy in SMO and modifies both local leader and global leader phase. The proposed strategy is named as Modified Position Update in Spider Monkey Optimization (MPU-SMO) algorithm. The proposed algorithm tested over benchmark problems and results show that it gives better results for considered unbiased problems.
Artificial Bee Colony (ABC) algorithm is a Nature Inspired Algorithm (NIA) which based in intelligent food foraging behaviour of honey bee swarm. ABC outperformed over other NIAs and other local search heuristics when tested for benchmark functions as well as factual world problems but occasionally it shows premature convergence and stagnation due to lack of balance between exploration and exploitation. This paper establishes a local search mechanism that enhances exploration capability of ABC and avoids the dilemma of stagnation. With help of recently introduces local search strategy it tries to balance intensification and diversification of search space. The anticipated algorithm named as Enhanced local search in ABC (EnABC) and tested over eleven benchmark functions. Results are evidence for its dominance over other competitive algorithms.
Artificial Bee Colony (ABC) optimization
algorithm is one of the recent population based probabilistic
approach developed for global optimization. ABC is simple
and has been showed significant improvement over other
Nature Inspired Algorithms (NIAs) when tested over some
standard benchmark functions and for some complex real
world optimization problems. Memetic Algorithms also
become one of the key methodologies to solve the very large
and complex real-world optimization problems. The solution
search equation of Memetic ABC is based on Golden Section
Search and an arbitrary value which tries to balance
exploration and exploitation of search space. But still there
are some chances to skip the exact solution due to its step
size. In order to balance between diversification and
intensification capability of the Memetic ABC, it is
randomized the step size in Memetic ABC. The proposed
algorithm is named as Randomized Memetic ABC (RMABC).
In RMABC, new solutions are generated nearby the best so
far solution and it helps to increase the exploitation capability
of Memetic ABC. The experiments on some test problems of
different complexities and one well known engineering
optimization application show that the proposed algorithm
outperforms over Memetic ABC (MeABC) and some other
variant of ABC algorithm(like Gbest guided ABC
(GABC),Hooke Jeeves ABC (HJABC), Best-So-Far ABC
(BSFABC) and Modified ABC (MABC) in case of almost all
the problems.
Differential Evolution (DE) is a renowned optimization stratagem that can easily solve nonlinear and comprehensive problems. DE is a well known and uncomplicated population based probabilistic approach for comprehensive optimization. It has apparently outperformed a number of Evolutionary Algorithms and further search heuristics in the vein of Particle Swarm Optimization at what time of testing over both yardstick and actual world problems. Nevertheless, DE, like other probabilistic optimization algorithms, from time to time exhibits precipitate convergence and stagnates at suboptimal position. In order to stay away from stagnation behavior while maintaining an excellent convergence speed, an innovative search strategy is introduced, named memetic search in DE. In the planned strategy, positions update equation customized as per a memetic search stratagem. In this strategy a better solution participates more times in the position modernize procedure. The position update equation is inspired from the memetic search in artificial bee colony algorithm. The proposed strategy is named as Memetic Search in Differential Evolution (MSDE). To prove efficiency and efficacy of MSDE, it is tested over 8 benchmark optimization problems and three real world optimization problems. A comparative analysis has also been carried out among proposed MSDE and original DE. Results show that the anticipated algorithm go one better than the basic DE and its recent deviations in a good number of the experiments.
Artificial Bee Colony (ABC) is a distinguished optimization strategy that can resolve nonlinear and multifaceted problems. It is comparatively a straightforward and modern population based probabilistic approach for comprehensive optimization. In the vein of the other population based algorithms, ABC is moreover computationally classy due to its slow nature of search procedure. The solution exploration equation of ABC is extensively influenced by a arbitrary quantity which helps in exploration at the cost of exploitation of the better search space. In the solution exploration equation of ABC due to the outsized step size the chance of skipping the factual solution is high. Therefore, here this paper improve onlooker bee phase with help of a local search strategy inspired by memetic algorithm to balance the diversity and convergence capability of the ABC. The proposed algorithm is named as Improved Onlooker Bee Phase in ABC (IoABC). It is tested over 12 well known un-biased test problems of diverse complexities and two engineering optimization problems; results show that the anticipated algorithm go one better than the basic ABC and its recent deviations in a good number of the experiments.
Artificial bee colony (ABC) algorithm is a well known and one of the latest swarm intelligence based techniques. This method is a population based meta-heuristic algorithm used for numerical optimization. It is based on the intelligent behavior of honey bees. Artificial Bee Colony algorithm is one of the most popular techniques that are used in optimization problems. Artificial Bee Colony algorithm has some major advantages over other heuristic methods. To utilize its good feature a number of researchers combined ABC algorithm with other methods, and generate some new hybrid methods. This paper provides comparative analysis of hybrid differential Artificial Bee Colony algorithm with hybrid ABC – SPSO, Genetic algorithm and Independent rough set approach based on some parameters like technique, dimension, methodology etc. KEYWORDS
Artificial bee colony (ABC) algorithm has proved its importance in solving a number of problems including engineering optimization problems. ABC algorithm is one of the most popular and youngest member of the family of population based nature inspired meta-heuristic swarm intelligence method. ABC has been proved its superiority over some other Nature Inspired Algorithms (NIA) when applied for both benchmark functions and real world problems. The performance of search process of ABC depends on a random value which tries to balance exploration and exploitation phase. In order to increase the performance it is required to balance the exploration of search space and exploitation of optimal solution of the ABC. This paper outlines a new hybrid of ABC algorithm with Genetic Algorithm. The proposed method integrates crossover operation from Genetic Algorithm (GA) with original ABC algorithm. The proposed method is named as Crossover based ABC (CbABC). The CbABC strengthens the exploitation phase of ABC as crossover enhances exploration of search space. The CbABC tested over four standard benchmark functions and a popular continuous optimization problem.
Multiplication of two 3 d sparse matrices using 1d arrays and linked listsDr Sandeep Kumar Poonia
A basic algorithm of 3D sparse matrix multiplication (BASMM) is presented using one dimensional (1D) arrays which is used further for multiplying two 3D sparse matrices using Linked Lists. In this algorithm, a general concept is derived in which we enter non- zeros elements in 1st and 2nd sparse matrices (3D) but store that values in 1D arrays and linked lists so that zeros could be removed or ignored to store in memory. The positions of that non-zero value are also stored in memory like row and column position. In this way space complexity is decreased. There are two ways to store the sparse matrix in memory. First is row major order and another is column major order. But, in this algorithm, row major order is used. Now multiplying those two matrices with the help of BASMM algorithm, time complexity also decreased. For the implementation of this, simple c programming and concepts of data structures are used which are very easy to understand for everyone.
Smart Huffman Compression is a software appliance designed to compress a file in a better way. By functioning as an JSP, it provides high level abstraction of java Servlet. For example, Smart Huffman Compression encodes the digital information using fewer bits, reduces the size of file without loss of data in a single, easy-to-manage software appliance form factor. It also provides us the decompression facility also. Smart Huffman Compression provides our organization with effective solutions to reduce the file size or lossless compression of data. It also expedites security of data using the encoding functionality. It is necessary to analyze the relationship between different methods and put them into a framework to better understand and better exploit the possibilities that compression provides us image compression, data compression, audio compression, video compression etc.
Artificial Bee Colony (ABC) algorithm is a Nature
Inspired Algorithm (NIA) which based on intelligent food
foraging behaviour of honey bee swarm. This paper introduces
a local search strategy that enhances exploration competence
of ABC and avoids the problem of stagnation. The proposed
strategy introduces two new local search phases in original
ABC. One just after onlooker bee phase and one after scout
bee phase. The newly introduced phases are inspired by
modified Golden Section Search (GSS) strategy. The proposed
strategy named as new local search strategy in ABC
(NLSSABC). The proposed NLSSABC algorithm applied over
thirteen standard benchmark functions in order to prove its
efficiency.
Program slicing technique is used for decomposition of a program by analyzing that particular program data
and control flow. The main application of program slicing includes various software engineering activities such as
program debugging, understanding, program maintenance, and testing and complexity measurement. When a slicing
technique gathers information about the data and control flow of the program taking an actual and specific execution
(or set of executions) of it, then it is said to be dynamic slicing, otherwise it is said to be static slicing. Generally,
dynamic slices are smaller than static because the statements of the program that affect by the slicing criterion for a
particular execution are contained by dynamic slicing. This paper reports a new approach of program slicing that is a
mixed approach of static and dynamic slice (S-D slicing) using Object Oriented Concepts in C++ Language that will
reduce the complexity of the program and simplify the program for various software engineering applications like
program debubbing.
Articial bee Colony algorithm (ABC) is a population based
heuristic search technique used for optimization problems. ABC
is a very eective optimization technique for continuous opti-
mization problem. Crossover operators have a better exploration
property so crossover operators are added to the ABC. This pa-
per presents ABC with dierent types of real coded crossover op-
erator and its application to Travelling Salesman Problem (TSP).
Each crossover operator is applied to two randomly selected par-
ents from current swarm. Two o-springs generated from crossover
and worst parent is replaced by best ospring, other parent remains
same. ABC with real coded crossover operator applied to travelling
salesman problem. The experimental result shows that our proposed
algorithm performs better than the ABC without crossover in terms
of eciency and accuracy.
Performance evaluation of diff routing protocols in wsn using difft network p...Dr Sandeep Kumar Poonia
In the recent past, wireless sensor networks have been introduced to use in many applications. To design the networks, the factors needed to be considered are the coverage area, mobility, power consumption, communication capabilities etc. The challenging goal of our project is to create a simulator to support the wireless sensor network simulation. The network simulator (NS-2) which supports both wire and wireless networks is implemented to be used with the wireless sensor network.
Normal Labour/ Stages of Labour/ Mechanism of LabourWasim Ak
Normal labor is also termed spontaneous labor, defined as the natural physiological process through which the fetus, placenta, and membranes are expelled from the uterus through the birth canal at term (37 to 42 weeks
Introduction to AI for Nonprofits with Tapp NetworkTechSoup
Dive into the world of AI! Experts Jon Hill and Tareq Monaur will guide you through AI's role in enhancing nonprofit websites and basic marketing strategies, making it easy to understand and apply.
A Strategic Approach: GenAI in EducationPeter Windle
Artificial Intelligence (AI) technologies such as Generative AI, Image Generators and Large Language Models have had a dramatic impact on teaching, learning and assessment over the past 18 months. The most immediate threat AI posed was to Academic Integrity with Higher Education Institutes (HEIs) focusing their efforts on combating the use of GenAI in assessment. Guidelines were developed for staff and students, policies put in place too. Innovative educators have forged paths in the use of Generative AI for teaching, learning and assessments leading to pockets of transformation springing up across HEIs, often with little or no top-down guidance, support or direction.
This Gasta posits a strategic approach to integrating AI into HEIs to prepare staff, students and the curriculum for an evolving world and workplace. We will highlight the advantages of working with these technologies beyond the realm of teaching, learning and assessment by considering prompt engineering skills, industry impact, curriculum changes, and the need for staff upskilling. In contrast, not engaging strategically with Generative AI poses risks, including falling behind peers, missed opportunities and failing to ensure our graduates remain employable. The rapid evolution of AI technologies necessitates a proactive and strategic approach if we are to remain relevant.
2024.06.01 Introducing a competency framework for languag learning materials ...Sandy Millin
http://sandymillin.wordpress.com/iateflwebinar2024
Published classroom materials form the basis of syllabuses, drive teacher professional development, and have a potentially huge influence on learners, teachers and education systems. All teachers also create their own materials, whether a few sentences on a blackboard, a highly-structured fully-realised online course, or anything in between. Despite this, the knowledge and skills needed to create effective language learning materials are rarely part of teacher training, and are mostly learnt by trial and error.
Knowledge and skills frameworks, generally called competency frameworks, for ELT teachers, trainers and managers have existed for a few years now. However, until I created one for my MA dissertation, there wasn’t one drawing together what we need to know and do to be able to effectively produce language learning materials.
This webinar will introduce you to my framework, highlighting the key competencies I identified from my research. It will also show how anybody involved in language teaching (any language, not just English!), teacher training, managing schools or developing language learning materials can benefit from using the framework.
Acetabularia Information For Class 9 .docxvaibhavrinwa19
Acetabularia acetabulum is a single-celled green alga that in its vegetative state is morphologically differentiated into a basal rhizoid and an axially elongated stalk, which bears whorls of branching hairs. The single diploid nucleus resides in the rhizoid.
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.
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.
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
Macroeconomics- Movie Location
This will be used as part of your Personal Professional Portfolio once graded.
Objective:
Prepare a presentation or a paper using research, basic comparative analysis, data organization and application of economic information. You will make an informed assessment of an economic climate outside of the United States to accomplish an entertainment industry objective.
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.
2. Paths and cycles
● A path is a sequence of nodes
v1, v2, …, vN such that (vi,vi+1)E for 0<i<N
■ The length of the path is N-1.
■ Simple path: all vi are distinct, 0<i<N
● A cycle is a path such that v1=vN
■ An acyclic graph has no cycles
4. More useful definitions
● The degree of a vertex is the number of
edges incident to that vertex
● In a directed graph:
● The indegree of a node v is the number of
distinct edges (w,v)E.
● The outdegree of a node v is the number of
distinct edges (v,w)E.
● A node with indegree 0 is a root.
5. Trees are graphs
● A dag is a directed acyclic graph.
● A tree is a connected acyclic undirected graph.
● A forest is an acyclic undirected graph (not
necessarily connected), i.e., each connected
component is a tree.
6. Even More Terminology
● subgraph: subset of vertices and edges forming a graph
● connected component: maximal connected subgraph. E.g., the graph below has
3 connected components.
connected not connected
•connected graph: any two vertices are connected by some path
7. Connectivity
● Let n = #vertices, and m = #edges
● A complete graph: one in which all pairs of vertices are
adjacent
● How many total edges in a complete graph?
■ Each of the n vertices is incident to n-1 edges, however, we would
have counted each edge twice! Therefore, intuitively, m = n(n -1)/2.
● Therefore, if a graph is not complete, m < n(n -1)/2
n 5
m (5
8. More Connectivity
n = #vertices
m = #edges
● For a tree m = n - 1
n 5
m 4
n 5
m 3
If m < n - 1, G is not
connected
9. G = (V, E)
a vertex may have:
0 or more predecessors
0 or more successors
10. some problems that can be
represented by a graph
● computer networks
● airline flights
● road map
● course prerequisite structure
● tasks for completing a job
● flow of control through a program
● many more
11. Graphs in Computer Science: How
do they help?
● What do they model?
■ An abstraction in Core CS.
○ Examples: VLSI Circuits, Communication Networks, Logical
flow of a computer program, Data structures.
■ An abstraction for data and relationships.
○ Examples: The Web, Social Networks, Flows and Flow
Networks, Biological Data, Taxonomies, Citations, Explicit
relations within a DB system.
● What aspects are studied?
■ Algorithms, Data Structures and Complexity Theory.
■ Characterization and Modeling of Graphs.
■ Implementations of Graph Algorithms in Specific
contexts.
12. What is a graph?
● A set of vertices and edges
■ Directed/Undirected
■ Weighted/Unweighted
■ Cyclic/Acyclic
vertex
edge
13. Representation of Graphs
● Adjacency Matrix
■ A V x V array, with matrix[i][j] storing whether
there is an edge between the ith vertex and the jth
vertex
● Adjacency Linked List
■ One linked list per vertex, each storing directly
reachable vertices
15. graph variations
● undirected graph (graph)
■ edges do not have a direction
○ (V1, V2) and (V2, V1) are the same edge
● directed graph (digraph)
■ edges have a direction
○ <V1, V2> and <V2, V1> are different edges
● for either type, edges may be weighted or
unweighted
16. a digraph
A
B
C D
E
V = [A, B, C, D, E]
E = [<A,B>, <B,C>, <C,B>, <A,C>, <A,E>, <C,D>]
17. graph data structures
● storing the vertices
■ each vertex has a unique identifier and, maybe,
other information
■ for efficiency, associate each vertex with a number
that can be used as an index
● storing the edges
■ adjacency matrix – represent all possible edges
■ adjacency lists – represent only the existing edges
18. storing the vertices
● when a vertex is added to the graph, assign it
a number
■ vertices are numbered between 0 and n-1
● graph operations start by looking up the
number associated with a vertex
● many data structures to use
■ any of the associative data structures
■ for small graphs a vector can be used
○ search will be O(n)
23. many graphs are “sparse”
● degree of “sparseness” key factor in
choosing a data structure for edges
■ adjacency matrix requires space for all
possible edges
■ adjacency list requires space for existing
edges only
● affects amount of memory space needed
● affects efficiency of graph operations
25. Adjacency Lists
A representation of the graph consisting of a list of nodes, with
each node containing a list of its neighboring nodes.
This representation takes O(|V | + |E|) space.
27. Introduction
● A free tree is a connected undirected graph without a cycle.
■ Note: This definition of tree is different from the one of a rooted tree
● In a free tree |E| = |V| - 1
● Example of a free tree:
● A forest is an acyclic directed or undirected graph consisting of
two or more trees
● The trees in a directed forest are rooted trees
● The trees in an undirected forest are free trees
29. Use of a stack
● It is very common to use a stack to keep track
of:
■ nodes to be visited next, or
■ nodes that we have already visited.
● Typically, use of a stack leads to a depth-first
visit order.
● Depth-first visit order is “aggressive” in the
sense that it examines complete paths.
30. Use of a queue
● It is very common to use a queue to keep track
of:
■ nodes to be visited next, or
■ nodes that we have already visited.
● Typically, use of a queue leads to a breadth-
first visit order.
● Breadth-first visit order is “cautious” in the
sense that it examines every path of length i
before going on to paths of length i+1.
31. Breadth-First Search (BFS)
● BFS tries to search all paths.
● BFS makes use of a queue to store visited (but
not dead) vertices, expanding the path from the
earliest visited vertices.
49. Example
● Breadth-first traversal using a queue.
Order of
Traversal Queue rearA B D E C G F H I
Queue front
A
B D E
C G
F H
I
BFS-tree:
Note: The BFS-tree for undirected graph is a free tree
50. Analysis of BFS
For a Graph G=(V, E) and n = |V| and m=|E|
• When Adjacency List is used
Complexity is O(m + n)
• When Adjacency Matrix is used
Scanning each row for checking the connectivity of a Vertex
is in order O(n).
So, Complexity is O(n2)
51. Depth-First Search (DFS)
● Strategy: Go as far as you can (if you have not
visit there), otherwise, go back and try another
way
72. Example
● Depth-first traversal using an explicit stack.
Order of
Traversal StackA B C F E G D H I
The Preorder Depth First Tree:
Note: The DFS-tree for undirected graph is a free tree
73. Recursive preorder Depth-First Traversal Tracing
At each stage, a set of unvisited adjacent
vertices of the current vertex is generated.
The Preorder Depth First Tree:
74.
75.
76.
77.
78. Analysis of DFS
For a Graph G=(V, E) and n = |V| and m=|E|
• When Adjacency List is used
Complexity is O(m + n)
• When Adjacency Matrix is used
Scanning each row for checking the connectivity of a Vertex
is in order O(n).
So, Complexity is O(n2)
DFS uses space O(|V|) in the worst case to store the stack
of vertices on the current search path as well as the set of
already-visited vertices.