0% found this document useful (0 votes)
8 views21 pages

Graphs

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views21 pages

Graphs

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 21

GRAPHS

• Graph is a non linear data structure. A graph is


made up of sets of nodes and lines.
• Nodes are called vertices or point.
• Lines are called edges or arcs.
• An edge of graph is represented as
»e= [u,v]
• u and v denotes the start and end nodes of
edge e respectively.
• Tree data structures represents one to many
relation ship.
• Graph data structure represents many to
many relation ship.
• Graph can be used to represents any relation
ship.
• Graphs are used to study problems in a wide
variety of areas including computer science,
electrical engineering, chemistry etc.
• They are commonly used in study of transport
network, communication network and
electrical circuits.
Types of Graph
• Undirected Graphs
– An undirected graph has edges that have no
direction. An undirected graph is also called a
undigraph.
• Directed Graphs
a directed graph has edges that are
unidirectional. A directed graph is also called a
digraph.
Types of Graph (cont.)
• Weighted Graphs
– A graph which has a weight, or number, associated
with each edge is called weighted graph. Weight
of an edge is sometimes also called its cost.
• Degree of Node
– Number of edges a node contains
• Out degree and in degree
– Number of edges beginning from a node is called
out degree of the node. A node has no out degree
edge is called terminal node or leaf node and
others are called branch node.
– Number of edges ending at a node is called in
degree of the node.
• Source & Sink Nodes
– The node that has a positive out-degree but zero in-degree
is called source node.
– The node that has zero out-degree but a positive in-
degree is called sink node.
• Path & Length of Graph
– A list of nodes of a graph where each node has an edge from
it to the next node is called the path. It is written as sequence
of nodes u1, u2, u3, . . . , un
– The number of edges in a path of a graph is called length of
the graph. For a path consisting of n nodes then the path
length is n-1.
• Loop Edge
– An edge e is said to be a loop edge if it has the same
node at its tail and head.
• Multiple Edge
1. In an undirected graph: two or more edges connecting the
same pair of vertices;
2. and in a directed graph, two or more edges with both the same tail
vertex and the same head vertex.
• Complete Graph
– A graph is said to be a complete graph if there is an edge
between every pair of vertices.
• Cycle & Acycle
– A path which originates and ends at the same
node is called cycle. It is also known as the circuit.
– The directed graph that has no cycles is called
acyclic graph. A directed acyclic graph is also
referred to as DAG.
Dense vs Sparce
• Dense Graph : A dense graph is a graph in
which there is a large number of edges.
Typically in a dense graph, the number of
edges is close to the maximum number of
edges.
• Sparse Graph : A sparse graph is a graph in
which there is a small number of edges

You might also like