1.
What is a Graph?
A graph is a nonlinear data structure. A graph data structure consists of a finite set of ordered
pairs, called edges or arcs, of certain entities called
nodes or vertices.
The size of a graph is the number of elements in its vertex set.
Figure shows a simple graph (V, E) of size 4. Its vertex set is
V = {a, b, c, d}, and its edge set is E = {ab, ac, ad, bd, cd}. This
graph has four vertices and five edges.
Types of Graph:
There are two types of graphs:
i. Undirected Graphs
ii. Directed Graphs
Undirected Graph: A graph that entail edges with ordered pair of vertices, however it does not
have direction define.
Directed Graph: A graph that entail edges with ordered pair of vertices and has direction
indicated with an arrow.
Degree
_ In an undirected graph, the degree of a vertex u is the number of edges connected to u. E.g; in
the above figure the degree of vertex 5 is two.
_ In a directed graph, the out-degree of a vertex u is the number edges leaving u, and its in-
degree is the number of edges ending at u. E.g; in the above figure the in-degree of vertex 5 is
two and the out-degree is null.
2.
Complete Graph
Figure shows the complete graph on the set V = {a, b, c, d}. Its edge
set E is E = {ab, ac, ad, bc, bd, cd}. The number of edges in the
complete graph on n vertices is n(n–1)/2.
Subgraph
Vertex and edge sets are subsets of
those of G
A supergraph of a graph G is a graph
that contains G as a subgraph.
Null graph
A graph G=(V,E) where E=0 is said to be Null or Empty graph
Trivial Graph:
A graph with One vertex and no edge is called as a trivial graph.
MultiGraph(Without Self Edge):
The term multigraph refers to a graph
in which multiple edges between vertices
are permitted. A multigraph G = (V, E)
asa
sa
V1
3.
is a graph which has the set of vetrices and multiple edges between vertices.
MultiGraph(With Self Edge):
A multidigraph is a directed graph which is
permitted to have multiple edges, i.e., edges
with the own,source and target vertices.
Isomorphic graphs
• Isomorphism
– Two graphs are isomorphic, if they are structurally identical, Which means that
they correspond in all structural details.
– Formal vertex-to-vertex and edge –to-edge correspondence is called
isomorphism.
• Two graph are said to be isomorphic if
– They have the same no of vertices.
– They have the same number of edges.
– They have an equal number of vertices with a given degree.
4.
Graph Traversal
• Problem: Search for a certain node or traverse all nodes in the graph
• Depth First Traversal
– Once a possible path is found, continue the search until the end of the path
• Breadth First Traversal
– Start several paths at a time, and advance in each one step at a time
5.
Depth First traversal:
When a graph is traversed by visiting the nodes in
the forward (deeper) direction as long as possible,
the traversal is called depth-first traversal. For
example, for the graph shown in Figure, the depth-
first traversal starting at the vertex 0 visits the
node in the orders:
0 1 2 6 7 8 5 3 4
0 4 3 5 8 6 7 2 1
Breadth first traversal
When a graph is traversed by
visiting all the adjacent
nodes/vertices of a node/vertex
first, the traversal is called
breadth-first traversal. For
example, for a graph in which
the breadth-first traversal starts
at vertex v1, visits to the nodes
take place in the order shown in
Figure
Clipping is a handy way to collect and organize the most important slides from a presentation. You can keep your great finds in clipboards organized around topics.
Be the first to comment