The document discusses graphs and graph algorithms. It begins by defining what a graph is - a collection of vertices connected by edges. It then lists four learning objectives related to representing graphs, traversing graphs, calculating minimum spanning trees, and finding shortest routes. The document goes on to describe different ways of representing graphs through adjacency matrices and lists. It also explains graph traversal algorithms like depth-first search and breadth-first search. Finally, it discusses algorithms for finding minimum spanning trees and shortest paths in weighted graphs.
The document discusses graphs and graph algorithms. It defines what a graph is and how they can be represented. It also explains graph traversal algorithms like depth-first search (DFS) and breadth-first search (BFS). Additionally, it covers algorithms for finding the shortest path using Dijkstra's algorithm and calculating minimum spanning trees using Kruskal's algorithm.
The document discusses graphs and graph algorithms. It defines what a graph is - a non-linear data structure consisting of vertices connected by edges. It describes different graph representations like adjacency matrix, incidence matrix and adjacency list. It also explains graph traversal algorithms like depth-first search and breadth-first search. Finally, it covers minimum spanning tree algorithms like Kruskal's and Prim's algorithms for finding minimum cost spanning trees in graphs.
This document summarizes algorithms for finding connected components, topological sorting of directed acyclic graphs (DAGs), and finding minimal spanning trees in weighted undirected graphs. It describes:
1) Using breadth-first or depth-first search to find the connected components of an undirected graph by traversing from each unvisited vertex.
2) Topological sorting of DAGs by recursively traversing vertices in depth-first order and listing them in the order they are finished.
3) Kruskal's algorithm for finding a minimal spanning tree by adding edges in order of increasing weight if they do not form cycles.
This document provides definitions and concepts related to graphs. It defines a graph as a data structure consisting of vertices and edges linking vertices, which can represent objects and relationships. Graphs are a generalization of trees that allow any type of relationship between nodes. Common graph representations include adjacency lists and matrices. The document also discusses graph traversal methods, minimum spanning trees, and applications of graphs.
This document provides an overview of the topics covered in Unit 5, which include graphs, hashing, and collision resolution techniques. It defines graphs and their components such as vertices, edges, directed and undirected graphs. It also discusses different graph representations like adjacency matrix and adjacency list. Elementary graph operations like breadth-first search and depth-first search are explained along with examples. Hashing functions and collision resolution are also introduced.
The document defines graphs and discusses their properties and applications. It covers topics like directed vs undirected graphs, representations using adjacency matrices and lists, graph traversals using depth-first and breadth-first search, minimum spanning trees, and applications of graphs in areas like social networks and the world wide web.
Graphs are non-linear data structures used to represent connections between pairs of elements called nodes. Nodes represent real-world objects and edges represent the connections between nodes. Graphs can be used to model transportation networks, social networks, and more. There are different types of graphs including directed graphs, undirected graphs, weighted graphs, and more. Common graph algorithms include depth-first search, breadth-first search, topological sorting, minimum spanning trees, and more which have various applications.
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
The document discusses graphs and graph algorithms. It defines what a graph is and how they can be represented. It also explains graph traversal algorithms like depth-first search (DFS) and breadth-first search (BFS). Additionally, it covers algorithms for finding the shortest path using Dijkstra's algorithm and calculating minimum spanning trees using Kruskal's algorithm.
The document discusses graphs and graph algorithms. It defines what a graph is - a non-linear data structure consisting of vertices connected by edges. It describes different graph representations like adjacency matrix, incidence matrix and adjacency list. It also explains graph traversal algorithms like depth-first search and breadth-first search. Finally, it covers minimum spanning tree algorithms like Kruskal's and Prim's algorithms for finding minimum cost spanning trees in graphs.
This document summarizes algorithms for finding connected components, topological sorting of directed acyclic graphs (DAGs), and finding minimal spanning trees in weighted undirected graphs. It describes:
1) Using breadth-first or depth-first search to find the connected components of an undirected graph by traversing from each unvisited vertex.
2) Topological sorting of DAGs by recursively traversing vertices in depth-first order and listing them in the order they are finished.
3) Kruskal's algorithm for finding a minimal spanning tree by adding edges in order of increasing weight if they do not form cycles.
This document provides definitions and concepts related to graphs. It defines a graph as a data structure consisting of vertices and edges linking vertices, which can represent objects and relationships. Graphs are a generalization of trees that allow any type of relationship between nodes. Common graph representations include adjacency lists and matrices. The document also discusses graph traversal methods, minimum spanning trees, and applications of graphs.
This document provides an overview of the topics covered in Unit 5, which include graphs, hashing, and collision resolution techniques. It defines graphs and their components such as vertices, edges, directed and undirected graphs. It also discusses different graph representations like adjacency matrix and adjacency list. Elementary graph operations like breadth-first search and depth-first search are explained along with examples. Hashing functions and collision resolution are also introduced.
The document defines graphs and discusses their properties and applications. It covers topics like directed vs undirected graphs, representations using adjacency matrices and lists, graph traversals using depth-first and breadth-first search, minimum spanning trees, and applications of graphs in areas like social networks and the world wide web.
Graphs are non-linear data structures used to represent connections between pairs of elements called nodes. Nodes represent real-world objects and edges represent the connections between nodes. Graphs can be used to model transportation networks, social networks, and more. There are different types of graphs including directed graphs, undirected graphs, weighted graphs, and more. Common graph algorithms include depth-first search, breadth-first search, topological sorting, minimum spanning trees, and more which have various applications.
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
Graphs are data structures used to represent connections between pairs of elements called nodes. The connections between nodes are called edges. There are different types of graphs such as weighted graphs where edges have a cost or value. Graphs can be represented using data structures like adjacency matrices and adjacency lists. Common graph algorithms include depth-first search (DFS), breadth-first search (BFS), minimum spanning trees (MST), shortest path algorithms like Dijkstra's algorithm, and topological sorting. Graphs have many real-world applications such as modeling transportation and social networks.
This document discusses different graph traversal algorithms and spanning trees. It explains that breadth-first search (BFS) traverses a graph level-by-level using a queue, while depth-first search (DFS) traverses as far as possible from the root node using a stack. A spanning tree connects all nodes of a graph using the minimum number of edges without cycles. Minimum spanning trees for weighted graphs use algorithms like Kruskal's and Prim's that apply greedy approaches.
This document discusses various algorithms for finding shortest paths in graphs, including Dijkstra's algorithm, breadth-first search (BFS), depth-first search (DFS), and Bellman-Ford algorithm. It provides pseudocode examples and explanations of how each algorithm works. It also covers properties of spanning trees, minimum spanning tree algorithms like Kruskal's and Prim's, and applications of spanning trees like network planning and routing protocols.
This section provides an introduction to graphs and graph theory. Key points include:
- Graphs consist of vertices and edges that connect the vertices. They can be directed or undirected.
- Common terminology is introduced, such as adjacent vertices, neighborhoods, degrees of vertices, and handshaking theorem.
- Different types of graphs are discussed, including multigraphs, pseudographs, and directed graphs.
- Examples of graph models are given for computer networks, social networks, information networks, transportation networks, and software design. Graphs can be used to model many real-world systems and applications.
A graph is a pictorial representation consisting of vertices connected by edges. It is represented as a pair of sets (V,E) where V is the set of vertices and E is the set of edges connecting vertex pairs. Key aspects include vertices, edges, adjacency, paths, degrees of vertices, directed/undirected graphs, cycles, and representations using adjacency matrices. Common graph algorithms are BFS, DFS, minimum spanning trees using Prim's and Kruskal's algorithms.
Graph terminology and algorithm and tree.pptxasimshahzad8611
This document provides an overview of key concepts in graph theory including graph terminology, representations, traversals, spanning trees, minimum spanning trees, and shortest path algorithms. It defines graphs, directed vs undirected graphs, connectedness, degrees, adjacency, paths, cycles, trees, and graph representations using adjacency matrices and lists. It also describes breadth-first and depth-first traversals, spanning trees, minimum spanning trees, and algorithms for finding minimum spanning trees and shortest paths like Kruskal's, Prim's, Dijkstra's, Bellman-Ford and A* algorithms.
The document discusses elements and operations related to graphs. It defines key graph elements like vertices, edges, loops, and degrees of vertices. It also describes operations on graphs such as finding paths and circuits, determining connectivity, and extracting subgraphs. Various graph types and conversions between directed and undirected graphs are also covered.
A graph is a data structure consisting of nodes connected by edges. There are different types of graphs such as undirected graphs, directed graphs, connected graphs, and strongly connected graphs. Algorithms like depth-first search, Kosaraju's algorithm, and Warshall's algorithm can be used to find strongly connected components, biconnected components, and shortest paths in graphs.
This document discusses graphs and spanning trees. A graph is a data structure containing vertices and edges connecting the vertices. A spanning tree of a graph is a subgraph that connects all vertices without cycles. Spanning trees can be found using graph search algorithms like breadth-first search or depth-first search. Spanning trees have properties like containing no cycles, having the minimum number of edges to connect all vertices, and being uniquely defined up to the choice of starting vertex for the search algorithm.
Trees are hierarchical data structures that organize data in a recursive structure. Binary trees have nodes with at most two children. Tree traversal algorithms visit each node exactly once in a defined order, such as depth-first or breadth-first. Threaded binary trees make inorder traversal faster using node pointers instead of recursion. Multiway trees can be represented as binary trees by making the leftmost child the left child of its corresponding binary tree node.
A graph is a data structure consisting of vertices and edges. Graphs are used to represent real-world networks like social networks and road maps. There are two main representations of graphs: adjacency matrix and adjacency list. Adjacency matrix uses a 2D array to store edge information while adjacency list uses an array of lists. Graph traversal algorithms like depth-first search and breadth-first search are used to search graphs in a systematic way without loops.
Graph theory concepts complex networks presents-rouhollah nabatinabati
This document provides an introduction to network and social network analysis theory, including basic concepts of graph theory and network structures. It defines what a network and graph are, explains what network theory techniques are used for, and gives examples of real-world networks that can be represented as graphs. It also summarizes key graph theory concepts such as nodes, edges, walks, paths, cycles, connectedness, degree, and centrality measures.
This document provides an overview of graph theory concepts. It defines what a graph is consisting of vertices and edges. It describes different types of graphs such as directed vs undirected, simple vs complex graphs. It introduces common graph terminology like degree of a vertex, adjacent/incident vertices, and connectivity. Examples of applications are given such as transportation networks, web graphs, and scheduling problems. Special graph cases like complete graphs and cycles are also defined.
The document discusses graph theory and provides definitions and examples of various graph concepts. It defines what a graph is consisting of vertices and edges. It also defines different types of graphs such as simple graphs, multigraphs, digraphs and provides examples. It discusses graph terminology, models, degree of graphs, handshaking lemma, special graphs and applications. It also provides explanations of planar graphs, Euler's formula and graph coloring.
This document provides an overview of graph theory. It defines various graph types including simple graphs, multigraphs, pseudographs, directed graphs, and labeled graphs. It also defines key graph terminology such as vertices, edges, degree, adjacency, connectivity, and planar graphs. Graph theory has many applications in fields like transportation, computer networks, and chemistry for modeling relationships between objects.
1. A graph is a collection of objects called vertices that are connected by links called edges. Graphs can be represented as a pair of sets (V,E) where V is the set of vertices and E is the set of edges.
2. There are several important terms used to describe graphs including adjacent nodes, degree of a node, regular graphs, paths, cycles, connected graphs, and complete graphs. Graphs can be represented using adjacency matrices or adjacency lists.
3. There are two main techniques for traversing graphs - depth-first search (DFS) and breadth-first search (BFS). DFS uses a stack and traverses graphs in a depth-wise manner while BFS uses a
1) The document provides definitions and theorems related to graph theory, including definitions of graphs, degrees, paths, cycles, connectedness, trees, and colorings. 2) It proves theorems such as a graph with n vertices and at least n edges contains a cycle, trees have a unique path between vertices, and connected graphs contain spanning trees. 3) It discusses decompositions of graphs into cycles and proves a graph has such a decomposition if and only if every vertex has even degree. 4) It also covers graph colorings, proving for example the chromatic number of a cycle is 2 if even length and 3 if odd length.
Graphs are data structures used to represent connections between pairs of elements called nodes. The connections between nodes are called edges. There are different types of graphs such as weighted graphs where edges have a cost or value. Graphs can be represented using data structures like adjacency matrices and adjacency lists. Common graph algorithms include depth-first search (DFS), breadth-first search (BFS), minimum spanning trees (MST), shortest path algorithms like Dijkstra's algorithm, and topological sorting. Graphs have many real-world applications such as modeling transportation and social networks.
This document discusses different graph traversal algorithms and spanning trees. It explains that breadth-first search (BFS) traverses a graph level-by-level using a queue, while depth-first search (DFS) traverses as far as possible from the root node using a stack. A spanning tree connects all nodes of a graph using the minimum number of edges without cycles. Minimum spanning trees for weighted graphs use algorithms like Kruskal's and Prim's that apply greedy approaches.
This document discusses various algorithms for finding shortest paths in graphs, including Dijkstra's algorithm, breadth-first search (BFS), depth-first search (DFS), and Bellman-Ford algorithm. It provides pseudocode examples and explanations of how each algorithm works. It also covers properties of spanning trees, minimum spanning tree algorithms like Kruskal's and Prim's, and applications of spanning trees like network planning and routing protocols.
This section provides an introduction to graphs and graph theory. Key points include:
- Graphs consist of vertices and edges that connect the vertices. They can be directed or undirected.
- Common terminology is introduced, such as adjacent vertices, neighborhoods, degrees of vertices, and handshaking theorem.
- Different types of graphs are discussed, including multigraphs, pseudographs, and directed graphs.
- Examples of graph models are given for computer networks, social networks, information networks, transportation networks, and software design. Graphs can be used to model many real-world systems and applications.
A graph is a pictorial representation consisting of vertices connected by edges. It is represented as a pair of sets (V,E) where V is the set of vertices and E is the set of edges connecting vertex pairs. Key aspects include vertices, edges, adjacency, paths, degrees of vertices, directed/undirected graphs, cycles, and representations using adjacency matrices. Common graph algorithms are BFS, DFS, minimum spanning trees using Prim's and Kruskal's algorithms.
Graph terminology and algorithm and tree.pptxasimshahzad8611
This document provides an overview of key concepts in graph theory including graph terminology, representations, traversals, spanning trees, minimum spanning trees, and shortest path algorithms. It defines graphs, directed vs undirected graphs, connectedness, degrees, adjacency, paths, cycles, trees, and graph representations using adjacency matrices and lists. It also describes breadth-first and depth-first traversals, spanning trees, minimum spanning trees, and algorithms for finding minimum spanning trees and shortest paths like Kruskal's, Prim's, Dijkstra's, Bellman-Ford and A* algorithms.
The document discusses elements and operations related to graphs. It defines key graph elements like vertices, edges, loops, and degrees of vertices. It also describes operations on graphs such as finding paths and circuits, determining connectivity, and extracting subgraphs. Various graph types and conversions between directed and undirected graphs are also covered.
A graph is a data structure consisting of nodes connected by edges. There are different types of graphs such as undirected graphs, directed graphs, connected graphs, and strongly connected graphs. Algorithms like depth-first search, Kosaraju's algorithm, and Warshall's algorithm can be used to find strongly connected components, biconnected components, and shortest paths in graphs.
This document discusses graphs and spanning trees. A graph is a data structure containing vertices and edges connecting the vertices. A spanning tree of a graph is a subgraph that connects all vertices without cycles. Spanning trees can be found using graph search algorithms like breadth-first search or depth-first search. Spanning trees have properties like containing no cycles, having the minimum number of edges to connect all vertices, and being uniquely defined up to the choice of starting vertex for the search algorithm.
Trees are hierarchical data structures that organize data in a recursive structure. Binary trees have nodes with at most two children. Tree traversal algorithms visit each node exactly once in a defined order, such as depth-first or breadth-first. Threaded binary trees make inorder traversal faster using node pointers instead of recursion. Multiway trees can be represented as binary trees by making the leftmost child the left child of its corresponding binary tree node.
A graph is a data structure consisting of vertices and edges. Graphs are used to represent real-world networks like social networks and road maps. There are two main representations of graphs: adjacency matrix and adjacency list. Adjacency matrix uses a 2D array to store edge information while adjacency list uses an array of lists. Graph traversal algorithms like depth-first search and breadth-first search are used to search graphs in a systematic way without loops.
Graph theory concepts complex networks presents-rouhollah nabatinabati
This document provides an introduction to network and social network analysis theory, including basic concepts of graph theory and network structures. It defines what a network and graph are, explains what network theory techniques are used for, and gives examples of real-world networks that can be represented as graphs. It also summarizes key graph theory concepts such as nodes, edges, walks, paths, cycles, connectedness, degree, and centrality measures.
This document provides an overview of graph theory concepts. It defines what a graph is consisting of vertices and edges. It describes different types of graphs such as directed vs undirected, simple vs complex graphs. It introduces common graph terminology like degree of a vertex, adjacent/incident vertices, and connectivity. Examples of applications are given such as transportation networks, web graphs, and scheduling problems. Special graph cases like complete graphs and cycles are also defined.
The document discusses graph theory and provides definitions and examples of various graph concepts. It defines what a graph is consisting of vertices and edges. It also defines different types of graphs such as simple graphs, multigraphs, digraphs and provides examples. It discusses graph terminology, models, degree of graphs, handshaking lemma, special graphs and applications. It also provides explanations of planar graphs, Euler's formula and graph coloring.
This document provides an overview of graph theory. It defines various graph types including simple graphs, multigraphs, pseudographs, directed graphs, and labeled graphs. It also defines key graph terminology such as vertices, edges, degree, adjacency, connectivity, and planar graphs. Graph theory has many applications in fields like transportation, computer networks, and chemistry for modeling relationships between objects.
1. A graph is a collection of objects called vertices that are connected by links called edges. Graphs can be represented as a pair of sets (V,E) where V is the set of vertices and E is the set of edges.
2. There are several important terms used to describe graphs including adjacent nodes, degree of a node, regular graphs, paths, cycles, connected graphs, and complete graphs. Graphs can be represented using adjacency matrices or adjacency lists.
3. There are two main techniques for traversing graphs - depth-first search (DFS) and breadth-first search (BFS). DFS uses a stack and traverses graphs in a depth-wise manner while BFS uses a
1) The document provides definitions and theorems related to graph theory, including definitions of graphs, degrees, paths, cycles, connectedness, trees, and colorings. 2) It proves theorems such as a graph with n vertices and at least n edges contains a cycle, trees have a unique path between vertices, and connected graphs contain spanning trees. 3) It discusses decompositions of graphs into cycles and proves a graph has such a decomposition if and only if every vertex has even degree. 4) It also covers graph colorings, proving for example the chromatic number of a cycle is 2 if even length and 3 if odd length.
This document provides an overview of wound healing, its functions, stages, mechanisms, factors affecting it, and complications.
A wound is a break in the integrity of the skin or tissues, which may be associated with disruption of the structure and function.
Healing is the body’s response to injury in an attempt to restore normal structure and functions.
Healing can occur in two ways: Regeneration and Repair
There are 4 phases of wound healing: hemostasis, inflammation, proliferation, and remodeling. This document also describes the mechanism of wound healing. Factors that affect healing include infection, uncontrolled diabetes, poor nutrition, age, anemia, the presence of foreign bodies, etc.
Complications of wound healing like infection, hyperpigmentation of scar, contractures, and keloid formation.
Strategies for Effective Upskilling is a presentation by Chinwendu Peace in a Your Skill Boost Masterclass organisation by the Excellence Foundation for South Sudan on 08th and 09th June 2024 from 1 PM to 3 PM on each day.
Gender and Mental Health - Counselling and Family Therapy Applications and In...PsychoTech Services
A proprietary approach developed by bringing together the best of learning theories from Psychology, design principles from the world of visualization, and pedagogical methods from over a decade of training experience, that enables you to: Learn better, faster!
हिंदी वर्णमाला पीपीटी, hindi alphabet PPT presentation, hindi varnamala PPT, Hindi Varnamala pdf, हिंदी स्वर, हिंदी व्यंजन, sikhiye hindi varnmala, dr. mulla adam ali, hindi language and literature, hindi alphabet with drawing, hindi alphabet pdf, hindi varnamala for childrens, hindi language, hindi varnamala practice for kids, https://www.drmullaadamali.com
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...PECB
Denis is a dynamic and results-driven Chief Information Officer (CIO) with a distinguished career spanning information systems analysis and technical project management. With a proven track record of spearheading the design and delivery of cutting-edge Information Management solutions, he has consistently elevated business operations, streamlined reporting functions, and maximized process efficiency.
Certified as an ISO/IEC 27001: Information Security Management Systems (ISMS) Lead Implementer, Data Protection Officer, and Cyber Risks Analyst, Denis brings a heightened focus on data security, privacy, and cyber resilience to every endeavor.
His expertise extends across a diverse spectrum of reporting, database, and web development applications, underpinned by an exceptional grasp of data storage and virtualization technologies. His proficiency in application testing, database administration, and data cleansing ensures seamless execution of complex projects.
What sets Denis apart is his comprehensive understanding of Business and Systems Analysis technologies, honed through involvement in all phases of the Software Development Lifecycle (SDLC). From meticulous requirements gathering to precise analysis, innovative design, rigorous development, thorough testing, and successful implementation, he has consistently delivered exceptional results.
Throughout his career, he has taken on multifaceted roles, from leading technical project management teams to owning solutions that drive operational excellence. His conscientious and proactive approach is unwavering, whether he is working independently or collaboratively within a team. His ability to connect with colleagues on a personal level underscores his commitment to fostering a harmonious and productive workplace environment.
Date: May 29, 2024
Tags: Information Security, ISO/IEC 27001, ISO/IEC 42001, Artificial Intelligence, GDPR
-------------------------------------------------------------------------------
Find out more about ISO training and certification services
Training: ISO/IEC 27001 Information Security Management System - EN | PECB
ISO/IEC 42001 Artificial Intelligence Management System - EN | PECB
General Data Protection Regulation (GDPR) - Training Courses - EN | PECB
Webinars: https://pecb.com/webinars
Article: https://pecb.com/article
-------------------------------------------------------------------------------
For more information about PECB:
Website: https://pecb.com/
LinkedIn: https://www.linkedin.com/company/pecb/
Facebook: https://www.facebook.com/PECBInternational/
Slideshare: http://www.slideshare.net/PECBCERTIFICATION
How to Make a Field Mandatory in Odoo 17Celine George
In Odoo, making a field required can be done through both Python code and XML views. When you set the required attribute to True in Python code, it makes the field required across all views where it's used. Conversely, when you set the required attribute in XML views, it makes the field required only in the context of that particular view.
Temple of Asclepius in Thrace. Excavation resultsKrassimira Luka
The temple and the sanctuary around were dedicated to Asklepios Zmidrenus. This name has been known since 1875 when an inscription dedicated to him was discovered in Rome. The inscription is dated in 227 AD and was left by soldiers originating from the city of Philippopolis (modern Plovdiv).
2. LEARNING OBJECTIVES
After completing this chapter, you will be able to:
1. Represent the graph using array and Linked list
2. Traverse the graph
3. Calculate minimum cost spanning tree
4. Calculate the shortest route from source to all
other nodes
3. GRAPHS
Graph is a collection of nodes or vertices connected
together through edges or arcs.
It is 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 E is the set of edges, connecting
the pairs of vertices.
Take a look at the following graph −
5. USES OF GRAPHS
Graphs are used to model electrical circuits,
chemical compounds, highway maps, and so on.
They are also used in the analysis of electrical
circuits, finding the shortest route, project
planning, linguistics, genetics, social science, and
so forth.
6. GRAPH DEFINITIONS AND NOTATIONS
A graph G is a pair, G = (V, E),
where V is a finite nonempty set, called the set of vertices of
G. E is called the set of edges.
Let V(G) denote the set of vertices, and E(G) denote the set
of edges of a graph G.
If the elements of E(G) are ordered pairs, G is called a
directed graph or digraph;,
otherwise, G is called an undirected graph. In an
undirected graph, the pairs (u, v) and (v, u) represent the
same edge.
7. CONT.…
Let G be a graph.
A graph H is called a sub-graph of G if V(H) ⊆
V(G) and E(H) ⊆ ^E(G);
that is, every vertex of H is a vertex of G, and
every edge in H is an edge in G.
8. CONT.….
A graph can be shown pictorially.
The vertices are drawn as circles, and a label
inside the circle represents the vertex.
1. In an undirected graph, the edges are drawn using
lines.
2. In a directed graph, the edges are drawn using
arrows.
10. GRAPH DATA STRUCTURE
Mathematical graphs can be represented in data-
structure.
We can represent a graph using an array of
vertices and a two dimensional array of edges
11. IMPORTANT GRAPH’S TERMS
Vertex − Each node of the graph is represented as a
vertex. In example given below, labeled circle represents
vertices.
So A to E are vertices. We can represent them using an array
as shown in image below. Here A can be identified by index
0. B can be identified using index 1 and so on.
Edge − Edge represents a path between two vertices or a
line between two vertices.
In example given below, lines from A to B, B to D and
so on represents edges..
12. CONT.…..
Adjacency − Two node or vertices are adjacent if they
are connected to each other through an edge. In
example given below, B is adjacent to A, D is adjacent to
B and so on.
Path − Path represents a sequence of edges between
two vertices. In example given below, ABDE represents a
path from A to E.
13. GRAPH REPRESENTATION
A graph can be represented in several
ways.
Two common ways:
1. adjacency matrices and
2. adjacency lists.
14. ADJACENCY MATRIX
Let G be a graph with n vertices, where n > 0.
Let V(G) = {v1, v2, ..., vn}.
The adjacency matrix AG is a two dimensional matrix n x
^n matrix such that the (i, j)th entry of AG is 1 if there is
an edge from vi to vj;
otherwise, the (i,j)th entry is zero.
16. ADJACENCY LISTS
An Adjacency List is a linked list of Vertices adjacent to a given
vertex
Let G be a graph with n vertices, where n > 0.
Let V(G) = {v1, v2, ..., vn}.
In the adjacency list representation, corresponding to each vertex,
v, there is a linked list such that each node of the linked list
contains the vertex u, such that (v, u) ⊆ E(G).
Because there are n nodes, we use an array, A, of size n, such that
A[i] is a reference variable pointing to the first node of the linked
list containing the vertices to which vi is adjacent. Each node has
two components, say vertex and link.
The component vertex contains the index of the vertex adjacent to
vertex i
18. OPERATIONS ON GRAPHS
Following are the basic primary operations of a Graph
1. Add Vertex − add a vertex to a graph.
2. Add Edge − add an edge between two vertices of a graph.
3. Display Vertex − display a vertex of a graph.
4. Create the graph. That is, store the graph in computer
memory using a particular graph representation.
5. Clear the graph. This operation makes the graph empty.
6. Determine whether the graph is empty.
7. Traverse the graph.
19. GRAPH TRAVERSALS
Processing a graph requires the ability to traverse the
graph. Traversing a graph is similar to traversing a binary
tree, except that traversing a graph is a bit more
complicated. Recall that a binary tree has no cycles.
Also, starting at the root node, we can traverse the entire
tree.
On the other hand, a graph might have cycles and we
might not be able to traverse the entire graph from a single
vertex (for example, if the graph is not connected).
Therefore, we must keep track of the vertices that have
been visited. We must also traverse the graph from each
vertex (that has not been visited) of the graph.
20. CONT.….
This ensures that the entire graph is traversed.
The two most common graph traversal
algorithms are:
1. Depth first traversal
2. Breadth first traversal
21. DEPTH FIRST TRAVERSAL
Depth First Search algorithm DFS traverses a graph in a depth
ward motion and uses a stack to remember to get the next
vertex to start a search when a dead end occurs in any
iteration.
Depth First Search- a search that begins by visiting vertex V,
an then recursively searches the unvisited vertices adjacent to V.
The depth first traversal is similar to the preorder traversal of a
binary tree.
An initial or source vertex is identified to start traversing, then
from that vertex any one vertex which is adjacent to the current
vertex is traversed i.e. only one adjacent vertex is traversed
from the vertex which had been traversed last.
23. DEPTH FIRST TRAVERSAL
As in example given above, DFS algorithm traverses from A to B
to C to D first then to E, then to F and lastly to G.
24. CONT…
It employs following rules.
Rule 1 − Visit adjacent unvisited vertex. Mark it visited.
Display it. Push it in a stack.
Rule 2 − If no adjacent vertex found, pop up a vertex
from stack.
Rule 3 − Repeat Rule 1 and Rule 2 until stack is empty.
31. CONT.…..
As C does not have any unvisited adjacent node so we keep popping the
stack until we find a node which has unvisited adjacent node. In this
case, there's none and we keep popping until stack is empty.
32. BREADTH FIRST TRAVERSAL
Breadth First Search algorithm BFS traverses a graph in a
breadth wards motion and uses a queue to remember to
get the next vertex to start a search when a dead end
occurs in any iteration.
Breadth-First search- A search that begins by visiting
vertex V, then visits the vertices adjacent to V, then visit the
vertices adjacent to each of V’s adjacent vertices, and so
on.
The breadth first traversal of a graph is similar to traversing
a binary tree level by level (the nodes at each level are
visited from left to right).All the nodes at any level, i, are
visited before visiting the nodes at level i + 1.
34. CONT.…
As in example given above, BFS algorithm traverses from A to B to E
to F first then to C and G lastly to D.
35. CONT…
It employs following rules.
Rule 1 − Visit adjacent unvisited vertex. Mark it visited.
Display it. Insert it in a queue.
Rule 2 − If no adjacent vertex found, remove the first
vertex from queue.
Rule 3 − Repeat Rule 1 and Rule 2 until queue is empty.
42. CONT.…..
At this stage we are left with no unmarked unvisited nodes. But as per
algorithm we keep on dequeuing in order to get all unvisited nodes.
When the queue gets emptied the program is over.
43. SHORTEST PATH ALGORITHM
Shortest path can be calculated only for the weighted
graphs.
The edges connecting two vertices can be assigned a
nonnegative real number, called the weight of the edge.
A graph with such weighted edges is called a weighted
graph.
Let G be a weighted graph. Let u and v be two vertices in
G, and let P be a path in G from u to v.
The weight of the path P is the sum of the weights of all
the edges on the path P, which is also called the weight of
v from u via P.
44. CONT.….
Let G be a weighted graph representing a highway
structure. Suppose that the weight of an edge represents
the travel time.
For example, to plan monthly business trips, a
salesperson wants to find the shortest path (that is, the
path with the smallest weight) from her or his city to
every other city in the graph. Many such problems exist in
which we want to find the shortest path from a given
vertex, called the source, to every other vertex in the
graph.
This section describes the shortest path algorithm, also
called the greedy algorithm, developed by Dijkstra.
45. SHORTEST PATH
Given a vertex, say vertex (that is, a source), this section
describes the shortest path algorithm.
The general algorithm is:
1. Initialize the array smallest Weight so that smallest
Weight[u]=weights[vertex, u].
2. Set smallest Weight[vertex] = 0.
3. Find the vertex, v, that is closest to vertex for which the shortest path has
not been determined.
4. Mark v as the (next) vertex for which the smallest weight is found.
5. For each vertex w in G, such that the shortest path from vertex to w has
not been determined and an edge (v, w) exists, if the weight of the path
to w via v is smaller than its current weight, update the weight of w to the
weight of v + the weight of the edge (v, w).
49. MINIMUM SPANNING TREES
A spanning tree of a graph, G, is a set of |V|-1 edges that connect all vertices
of the graph.
Suppose we have a group of islands that we wish to link with bridges so that
it is possible to travel from one island to any other in the group.
Further suppose that (as usual) our government wishes to spend the
absolute minimum amount on this project (because other factors like the
cost of using, maintaining, etc., these bridges will probably be the
responsibility of some future government). The engineers are able to
produce a cost for a bridge linking each possible pair of islands. The set of
bridges which will enable one to travel from any island to any other at
minimum capital cost to the government is the minimum spanning tree.
In general, it is possible to construct multiple spanning trees for a graph, G.
If a cost, cij, is associated with each edge, eij = (vi,vj), then the minimum
spanning tree is the set of edges, E span, forming a spanning tree, such that:
C = sum( cij | all eij in Espan ) is a minimum.
50. KRUSKAL'S ALGORITHM
This algorithm creates a forest of trees. Initially the
forest consists of n single node trees (and no edges). At
each step, we add one (the cheapest one) edge so that
it joins two trees together.
If it were to form a cycle, it would simply link two
nodes that were already part of a single connected tree,
so that this edge would not be needed.
57. SUMMARY
Graph is a collection of nodes Connected together using
edges.
Graph can be traversed using DFS or BFS
Shortest path for a vertex with other vertices can be
calculated using Dijkstra’s algorithm.
Spanning tree is an acyclic graph.
Minimum cost spanning trees can be derived using
Kruskal’s algorithm