Online Education eLearning Website HTML CSS Free Download

How to create a completely responsive Online Education – eLearning Website Design – Using HTML & CSS. Online Education eLearning Website HTML CSS Free Download

Find out which nodes are associated with a node:

Suppose you want the number of all nodes connected to node 1, you would loop up to the size of edges[1] like this:

size=edges[1].size();

for(int i=0; i < size ; i++)

printf(“%d “,edges[1][i]);

1 >> 0 1 0 0 0 1 1 0 It will take less time to go around 1 >> 2,6,7 than to go around the whole, right? 🙂

When is adjacency matrix more convenient than list?

If a problem asks you to check if there is an edge between your u, v nodes, then if you use list, you have to check by looping, but in matrix, just by checking matrix[u][v] index, you can tell if there is connection between them.

Exercise:

If you have understood so far, you are ready to learn basic algorithms like bfs, dfs. Do a short exercise before reading the next text. Write a code that, given the above input, does the following:

Online Education eLearning Website HTML CSS Free Download

1. Creates an adjacency list. (Assume the graph is directed, not bidirectional)

2. Prints how many nodes are connected to which node, what the nodes are.

3. indegree is how many nodes enter a node, outdegree is just the opposite. Print the outdegree and indegree of each node.

Hands on Graph Theory – 2 (Graph Store in Variables-1)

In the previous post we saw what graph theory is useful for, and learned some elementary terms. Now we’ll delve a little deeper. First we need to know how to store a graph with inputs. Among the many methods, two are very common:

1. Adjacency matrix

2. Adjacency List

Adjacent means “next to something”. For example, your next door neighbors are your adjuncts. In graph language, if one node is connected to another node, the 2nd node is adjacent to the first one. In this post we will see how to store which nodes are adjacent i.e. which nodes have edges with the help of matrix. Matrix here just means 2-D array, so don’t panic!

You can see a table next to Raf. This is our adjacency matrix. Cell [i][j] of the matrix contains 1 if there is an edge from i to j, 0 otherwise

sit down

Edges can be weighted, for example an edge from Dhaka to Chittagong can say the distance between the two cities is 300 km. Then you have to put weights in the matrix as well.

The above graph is bidirectional or undirected, i.e. if you can go from 1 to 2, you can also go from 2 to 1. If the graph were directed then there would be arrows between the edges. We can still store in the matrix as before. The following figure shows an example of the adjacency matrix of a directed weighted graph.

Nodes that have no edges inside them are shown here with infinity or a much larger number.

Note that if the graph is undirected, the matrix becomes symmetric, i.e. mat[i][j]=mat[j][i].

A short exercise:

Imagine a graph that has 3 nodes with edge number 3, and all edges are bidirectional. The edges are 1-2 (cost 5), 2-3 (cost 8), 1-3 (cost 3). How will its adjacency matrix?

Quickly try to put it in the notebook yourself and match it with the answer below:

  0 5 3

  5 0 8

  3 8 0

Hope you understand how to understand the matrix. If you don’t understand, read the above part again.

The graph input will be given as:

The matrix just above can be given as input to a programming problem, initially just stating the number of nodes. Note that we do not need to know the number of edges to input this matrix. We need one variable to input the number of nodes, another 2-D array to input the matrix.

int N;

int matrix[100][100]; // This maximum 100 node graph can be stored.

// After declaring it’s time to take input. Very simple task:

scanf(“%d”,&N);

for(int i=1;i<=N;i++)

for(int j=1;j<=N;j++)

scanf(“%d” ,&matrix[i][j]);

Without directly giving the matrix, the number of nodes and the number of edges can tell what the edges are, like this:

  3 3 //3 nodes and 3 edges

  1 2 5 //node1-node2-cost

  2 3 8

  1 3 3

It will be input like this:

int Node,Edge;

int matrix[100][100];

scanf(“%d%d”,&Node,&Edge);

for(i=0;i<Edge;i++)

{

int n1,n2,cost;

scanf(“%d%d%d”,&n1,&n2,&cost);

matrix[n1][n2]=cost;

matrix[n2][n1]=cost;

}

Graphs can provide input to problems in many other ways. Node numbers can be random, eg 3 nodes can be identified as 100,10000,400 instead of 1,2,3. In that case we have to do mapping. In other words, we will map 100 with 1, meaning 100 will mean 1,10000 will mean 2. Keep an array called index and mark it as index[100]=1;index[100000]=2; After inputting the node number will extract the given number from my index. This is called array compression, if you want to know the details you can see my post sometime later.

Online Education eLearning Website HTML CSS Free Download

Problems with using adjacency matrix:

Memory is a huge problem, no matter how many edges you have N∗N

size matrix where N is the number of nodes. 10000 nodes is N∗Nmatrix size will be 4∗1000∗1000 bytes or about 381

megabytes! It’s a huge waste of memory if the edge is low.

Any node u

To find out which node can go from to, we have N

To check all the nodes, a huge waste of time!

Advantages of using adjacency matrix:

u–v

Whether there is a connection between the nodes or how much the cost is very easily mat[u][v]

I can check and find out.

The adjacency list will eliminate these problems, as well as introduce some new problems! You will learn that in the next episode. Before that you need to learn one thing, that is Standard Template Library (STL) of C++. We will work with STL vectors because it is very easy to use. You can learn very easily with the help of the following two links:

1: http://sites.google.com/site/smilitude/stl This is Fahim Bhai’s blog link, his tutorials are unique.

2: http://www.cplusplus.com/reference/stl/ is the best site to learn the working of various functions of STL.

Before Download

You must Join our Facebook Group and Subscribe YouTube Channel

All Links in Below:






Join Our FreeWebsiteCreate Facebook Group to get an instant update for projects, templates, design resources, and solutions.

Join Our YouTube Channel & Subscribe with Bell Icon for New Video:

Join Our Official Facebook Page For the Latest updates All Code Projects are Free:

Visit our service page to get premium services.

Free Website Create – HTML CSS, PHP, JavaScript Programming Projects For Free

Follow Us

Thank You,

Stay with FreeWebsiteCreate.net

Share the post if necessary.

Before Download

You must Join our Facebook Group and Subscribe YouTube Channel




FreeWebsiteCreate.net tries to provide HTML, CSS, SCSS, JavaScript, React, Android Studio, Java, PHP, Laravel, Python, Django, C#(C Sharp), and ASP.net-related projects 100% free. We try to make learning easier. Free Website Create always tries to give free projects to new learners. Free projects and source code will help to learn quickly.

They can save time and learn more. In this post, we share a free portfolio project website code with HTML and CSS. This free code portfolio contains a single landing page with a responsive design. In this post, we get a free best carpenter and craftsman service website designed by FreeWebsiteCreate with HTML, CSS, Bootstrap, and JavaScript.

To get a free website project code,

Keep bookmarking our website, Save categories links, Follow Social Media, Follow the youtube channel Join Facebook groups.

Stay with FreeWebsiteCreate.net

Share the post if necessary.

Leave a Comment