# Insertion Deletion of Vertices and Edges in Graph using Adjacency list

By | 13.05.2017

## Insertion Deletion of Vertices and Edges in Graph

Write a C Program for Insertion Deletion of Vertices and Edges in Directed Graph using Adjacency list. Here’s simple Program for Insertion Deletion of Vertices and Edges in Graph using Adjacency list in C Programming Language.

Adjacency Matrix is a 2D array of size V x V where V is the number of vertices in a graph. Let the 2D array be adj[][], a slot adj[i][j] = 1 indicates that there is an edge from vertex i to vertex j.

Adjacency matrix for undirected graph is always symmetric. Adjacency Matrix is also used to represent weighted graphs. If adj[i][j] = w, then there is an edge from vertex i to vertex j with weight w.

Pros: Representation is easier to implement and follow. Removing an edge takes O(1) time. Queries like whether there is an edge from vertex ‘u’ to vertex ‘v’ are efficient and can be done O(1).

Cons: Consumes more space O(V^2). Even if the graph is sparse(contains less number of edges), it consumes the same space. Adding a vertex is O(V^2) time.

Also Check : : C Program for Creation of Adjacency Matrix

Below is the source code for C Program for Insertion Deletion of Vertices and Edges in Graph using Adjacency list which is successfully compiled and run on Windows System to produce desired output as shown below :

### OUTPUT : :

If you found any error or any queries related to the above program or any questions or reviews , you wanna to ask from us ,you may Contact Us through our contact Page or you can also comment below in the comment section.We will try our best to reach up to you in short interval. 