Everything About Graph – Graph, Types of Graph, Representation of Graph

Everything About Graph – Graph, Types of Graph, Representation of Graph

What is Graph?

In computer science, a graph is an abstract data type that is meant to implement the undirected graph and directed graph concepts from the field of graph theory within mathematics.

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.

Elements of Graph

  1. Vertices: Also known as node. The point where edges connect.
  2. Edge: The line which connects Nodes.
  3. Weight: Length of edge.
  4. Direction: Tells about an edge where it is from and where to.

Types of Graph

Types of Graphs Respective to Direction of Edge

  1. Directed Graph
  2. Undirected Graph

What is Directed Graph?

A directed graph is a graph where each edge is directed. In a directed graph every edge has a starting a ending. Every edge is known as from a source and to a destination. For example in the below directed graph there is edge form 1 to 4.

Directed Graph
Directed Graph

What is Undirected Graph?

An undirected graph is that where the edges are not directed specifically. If there is an edge in an undirected graph from A to B then that can be said also there is a edge from B to A.

Undirected Graph
Undirected Graph

Types of Graph Respective to Weight of Edge

  1. Weighted Graph
  2. Unweighted Graph

What is Weighted Graph?

A graph is said to be weighted if each edge of the graph has a value which represents the distance from the starting node to ending node. We can find shortest path as well as a strongly connected graph in weighted graph.

Weighted Graph
Weighted Graph

What is Unweighted Graph?

A graph is said to be unweighted if edges are not specified with a weight. These type of graph tells us only that is a node connected to other or not. We can find strongly connected graph from an unweighted graph but not a shortest path.

Other Types of Graph

What is Bipartite Graph?

A graph is said to be bipartite if its vertices can be partitioned into two subsets and such that each edge of connects a vertex of to a vertex of N.

Bipartite Graph
Bipartite Graph

What is Multigraph?

In graph theory, a multigraph is a graph which is permitted to have multiple edges (also called parallel edges), that is, edges that have the same end nodes. Thus two vertices may be connected by more than one edge.

Multigraph

What is Complete Graph?

In graph theory, a complete graph is a simple undirected graph in which every pair of distinct vertices is connected by a unique edge.

A graph is said to be complete if each node have exactly one edge to each of the other nodes. The complete graph with 3 edges is known as K3, with 4 edges is known as K4 and so on.

K7 - Complete Graph
K7 – Complete Graph

What is Planner Graph?

A graph or multigraph which can be drawn in the plane so that its edges do not cross is said to be planar graph. K2, K3, K4 are common example of planner graph.

There are two question about K4 graph.

Is K4 a Planner Graph?

Why K4 is a Planner Graph?

The answer is simple. In normal sense it may be assumed that two edge crosses one other. But it is wrong. They are completely in different way. That is seems for your drawing. We can put an edge which is crossing another by a bypass way. See the three graphs below.

K4 - Planner Graph
K4 – Planner Graph

What is Homeomorphic Graph?

Two graphs and G* are said to homeomorphic if they can be obtained from the same graph or isomorphic graphs by dividing an edge of with additional vertices. For Example H and H’.

Isomorphic Graph
Homeomorphic Graph

What is Isomorphic Graph?

Graphs G(V,E) and G*(V*,E*are said to be isomorphic if there exists a one-to-one correspondence → V* such that {u, v} is an edge of if and only if {f (u), f (v)} is an edge of G*. For Example, G and G’.

Isomorphic Graph
Isomorphic Graph

Special Terms in Graph

Distance of Two Node

The distance between vertices and in G, written d(u, v), is the length of the shortest path between and v. For example in the graph below d(A,D)=2.

Diameter of Two Node

The diameter of G, written diam(G), is the maximum distance between any two points in G. For example in the graph below diam(A,D)=3.

Adjacent Nodes

If e = (u, v) where u and v are endpoints of an edge e then u and v are called Adjacent Nodes. In the below graph A and B are adjacent nodes.

Cycle

A cycle is a closed simple path with length 3 or more. In the below graph A>B>C or C>B>A is a cycle.

Distance vs Diameter
Distance vs Diameter Graph

Degree of Node

The degree of a node is the number of connections that it has to other nodes in the network. In a social network if you have 100 friends then the node that represents you has a degree of 100. In the below example the degree of node 1, 2, 3 and 4 is 2, 0, 2, 1 respectively.

Isolated Node

A node u is said to be isolated if there is no edge from u to anywhere. These nodes can be considered as the end of the graph. In the below graph node 2 is an isolated node. There is no edge from node 2.

Path

A path from a node u to a node v is the set of all edges need to fetch to travel from u to v. A path P of length n from a node u to a node v is defined as a sequence of n+1 nodes. In the below node a path from 4 to 2 is 4>3>2.

Graph Terms
Graph Terms

Representation of Graph

  1. Linked Representation
  2. Matrix Representation

Linked Representation

In which representation a graph is represented by a list of it’s nodes and the neighbor nodes to which there is an edge from current node is known as linked representation.

In the table bellow shows each node in a graph G followed by its adjacency list, which is its adjacency nodes.

NodeAdjacency
AE, G
BC
CF
DC
EH
FA, B
GB, C, E
HD

Drawing a Graph from Linked Representation

For the above representation the graph will be:

Linked Representation
Graph For Linked Representation

Matrix Representation

In which representation a graph is represented by a matrix where an element of row m and column n represent the edge from node m to node n. If the value is 0 that means there is no edge. If it’s non-zero then there is a edge. For adjacency matrix these values are 1 in path matrix these values are the length of the path.

Matrix Representation

Drawing a Graph from Matrix Representation

For the above representation the graph will be:

Matrix Representation
Graph for Matrix Representation

Leave a Reply

Your email address will not be published. Required fields are marked *