Skip to main content

Featured Post

How to use Tabs in ASP.NET CORE

I want to show Components in a tabs , so first of all create few components. In this project we have three components, First View Component  public class AllViewComponent : ViewComponent     {         private readonly UserManager<ApplicationUser> _userManager;         public AllViewComponent(UserManager<ApplicationUser> userManager)         {             _userManager = userManager;         }         public async Task<IViewComponentResult> InvokeAsync()         {             List<StudentViewModel> allUsers = new List<StudentViewModel>();             var items = await _userManager.Users.ToListAsync();             foreach (var item in items)             {                 allUsers.Add(new StudentViewModel {Id=item.Id, EnrollmentNo = item.EnrollmentNo, FatherName = item.FatherName, Name = item.Name, Age = item.Age, Birthdate = item.Birthdate, Address = item.Address, Gender = item.Gender, Email = item.Email });             }            

Adjacency matrix representation in Graph

Pictorially it is very the graph can be represented very easily and analysis can be done quite normally. But there is no direct pictorial data structure available to represent the graph. The basic data structure serve the purpose to store the graph in the memory. The data structures two-dimensional array and linked list most commonly used to represent the graphs. If the graph is represented using two dimensional array then the representational is called as "adjacency matrix representation" and if the linked list is used to represent the graph then the representation is called as "adjacency list representation".

Adjacency Matrix Representation:

A two dimensional array of size nxn can be used to represent the graph where 'n' is the number of vertices of the graph. 'n' number of rows are used to represent the vertices and 'n' number of columns are used for each vertex. The matrix entries depend on the type of graph. If the graph is undirected or directed then each row for the respective vertex contains the number of direct paths to each vertex is entered in the matrix. If the graph is weighted graph then the matrix entries for each row will be the weight of the edge to other vertices is entered as matrix entry. Consider the following undirected graph:

Adjacency matrix representation in Graph


In the given graph, the node 2, 4 and 6 are adjacent to 1(there exist a direct path). So, in the adjacency matrix the row entry for vertex 1 contains '1' for each column representing vertices 2, 4 and 6 and rest of the entries will be 0 for that row. Similarly the row for vertex 2 contains entry '1' for column 1 and 5, '0' for 2, 4 and 6. You can note that 1 and 5 are adjacent nodes of vertex 2. In our all discussions node and vertex are synonyms. The complete adjacency matrix is:

Adjacency matrix representation in Graph


In the above adjacency matrix each row is used for each node and each column is used for each node. Adj ij entry will be 1 if node 'i' is adjacent to 'j' otherwise it is 0 where 'Adj' is adjacency matrix, 'i' represents rows for nodes 1,2,3,4,5,6 and 'j' represents columns for nodes 1,2,4,5,6.

Consider the following digraph:

directed graph with adjacency

Nodes 2 and 6 are adjacent nodes of 1. Node 5 is the only adjacent node of 2. Nodes 1 and 5 are adjacent node 4. Node 6 is the adjacent node of 5. There are no adjacent nodes of node 6 it means it is not possible to move from node 6 to any other nodes of the graph (no direct path). So, the adjacency matrix is:

Adjacency matrix representation in Graph


The adjacency matrix of a directed graph is not always symmetric whereas the adjacency matrix of an undirected graph is always symmetric. So, determination of only upper triangle of the adjacency matrix is more than enough for an undirected graph.

Consider the following weighted graph:

Consider the following weighted graph

In the adjacency matrix of the above weighted graph the entries are the respective weight of the edges of the adjacent nodes if any exists otherwise it will be '∞' (unknown weight). So, the adjacency matrix is:
Adjacency matrix representation in Graph

Comments

Popular Post

Polynomial representation using Linked List for Data Structure in 'C'

Polynomial representation using Linked List The linked list can be used to represent a polynomial of any degree. Simply the information field is changed according to the number of variables used in the polynomial. If a single variable is used in the polynomial the information field of the node contains two parts: one for coefficient of variable and the other for degree of variable. Let us consider an example to represent a polynomial using linked list as follows: Polynomial:      3x 3 -4x 2 +2x-9 Linked List: In the above linked list, the external pointer ‘ROOT’ point to the first node of the linked list. The first node of the linked list contains the information about the variable with the highest degree. The first node points to the next node with next lowest degree of the variable. Representation of a polynomial using the linked list is beneficial when the operations on the polynomial like addition and subtractions are performed. The resulting polynomial can also

How to use Tabs in ASP.NET CORE

I want to show Components in a tabs , so first of all create few components. In this project we have three components, First View Component  public class AllViewComponent : ViewComponent     {         private readonly UserManager<ApplicationUser> _userManager;         public AllViewComponent(UserManager<ApplicationUser> userManager)         {             _userManager = userManager;         }         public async Task<IViewComponentResult> InvokeAsync()         {             List<StudentViewModel> allUsers = new List<StudentViewModel>();             var items = await _userManager.Users.ToListAsync();             foreach (var item in items)             {                 allUsers.Add(new StudentViewModel {Id=item.Id, EnrollmentNo = item.EnrollmentNo, FatherName = item.FatherName, Name = item.Name, Age = item.Age, Birthdate = item.Birthdate, Address = item.Address, Gender = item.Gender, Email = item.Email });             }            

Memory representation of Linked List Data Structures in C Language

                                 Memory representation of Linked List              In memory the linked list is stored in scattered cells (locations).The memory for each node is allocated dynamically means as and when required. So the Linked List can increase as per the user wish and the size is not fixed, it can vary.                Suppose first node of linked list is allocated with an address 1008. Its graphical representation looks like the figure shown below:       Suppose next node is allocated at an address 506, so the list becomes,   Suppose next node is allocated with an address with an address 10,s the list become, The other way to represent the linked list is as shown below:  In the above representation the data stored in the linked list is “INDIA”, the information part of each node contains one character. The external pointer root points to first node’s address 1005. The link part of the node containing information I contains 1007, the address of