Physical properties of Gaussian beams - waist beam
During a traversal, it is important that you track which vertices have been visited. The most common way of tracking vertices is to mark them.
3 -> 0 -> 2 -> 4 edges[ 3 ][ 0 ].first = 0 , edges[ 3 ][ 0 ].second = 0 edges[ 3 ][ 2 ].first = 2 , edges[ 3 ][ 2 ].second = 0 edges[ 3 ][ 3 ].first = 4 , edges[ 3 ][ 3 ].second = 0
N for glassuses
In the earlier diagram, start traversing from 0 and visit its child nodes 1, 2, and 3. Store them in the order in which they are visited. This will allow you to visit the child nodes of 1 first (i.e. 4 and 5), then of 2 (i.e. 6 and 7), and then of 3 (i.e. 7) etc.
If you use the BFS algorithm, the result will be incorrect because it will show you the optimal distance between s and node 1 and s and node 2 as 1 respectively. This is because it visits the children of s and calculates the distance between s and its children, which is 1. The actual optimal distance is 0 in both cases.
In this approach, a boolean array is not used to mark the node because the condition of the optimal distance will be checked when you visit each node. A double-ended queue is used to store the node. In 0-1 BFS, if the weight of the edge = 0, then the node is pushed to the front of the dequeue. If the weight of the edge = 1, then the node is pushed to the back of the dequeue.
N for glassmeaning
To make this process easy, use a queue to store the node and mark it as 'visited' until all its neighbours (vertices that are directly connected to it) are marked. The queue follows the First In First Out (FIFO) queuing method, and therefore, the neigbors of the node will be visited in the order in which they were inserted in the node i.e. the node that was inserted first will be visited first, and so on.
Q is a double-ended queue. The distance is an array where, distance[ v ] will contain the distance from the start node to v node. Initially the distance defined from the source node to each node is infinity.
BFS is a traversing algorithm where you should start traversing from a selected node (source or starting node) and traverse the graph layerwise thus exploring the neighbour nodes (nodes which are directly connected to source node). You must then move towards the next-level neighbour nodes.
N for glasspdf
In this code, while you visit each node, the level of that node is set with an increment in the level of its parent node. This is how the level of each node is determined.
0 -> 1 -> 3 -> 2 edges[ 0 ][ 0 ].first = 1 , edges[ 0 ][ 0 ].second = 1 edges[ 0 ][ 1 ].first = 3 , edges[ 0 ][ 1 ].second = 0 edges[ 0 ][ 2 ].first = 2 , edges[ 0 ][ 2 ].second = 1
Starting from the source node, i.e 0, it will move towards 1, 2, and 3. Since the edge weight between 0 and 1 and 0 and 2 is 1 respectively, 1 and 2 will be pushed to the back of the queue. However, since the edge weight between 0 and 3 is 0, 3 will pushed to the front of the queue. The distance will be maintained in distance array accordingly.
N for glassprice
N for glasstest
Here, edges[ v ] [ i ] is an adjacency list that exists in the form of pairs i.e. edges[ v ][ i ].first will contain the node to which v is connected and edges[ v ][ i ].second will contain the distance between v and edges[ v ][ i ].first.
1 -> 0 -> 4 edges[ 1 ][ 0 ].first = 0 , edges[ 1 ][ 0 ].second = 1 edges[ 1 ][ 1 ].first = 4 , edges[ 1 ][ 1 ].second = 0
N for glassformula
As in this diagram, start from the source node, to find the distance between the source node and node 1. If you do not follow the BFS algorithm, you can go from the source node to node 2 and then to node 1. This approach will calculate the distance between the source node and node 1 as 2, whereas, the minimum distance is actually 1. The minimum distance can be calculated correctly by using the BFS algorithm.
Note: The Optical Glass Cross Reference Table shows that the glass codes for the three companies are either identical or nearly identical. However the actual glass composition is not necessarily identical.
N glassPhysics
If all the edges in a graph are of the same weight, then BFS can also be used to find the minimum distance between the nodes in a graph.
Graph traversal means visiting every vertex and edge exactly once in a well-defined order. While using certain graph algorithms, you must ensure that each vertex of the graph is visited exactly once. The order in which the vertices are visited are important and may depend upon the algorithm or question that you are solving.
The distance between the nodes in layer 1 is comparitively lesser than the distance between the nodes in layer 2. Therefore, in BFS, you must traverse all the nodes in layer 1 before you move to the nodes in layer 2.
N for glassrefraction
A graph can contain cycles, which may bring you to the same node again while traversing the graph. To avoid processing of same node again, use a boolean array which marks the node after it is processed. While visiting the nodes in the layer of a graph, store them in a manner such that you can traverse the corresponding child nodes in a similar order.
This type of BFS is used to find the shortest distance between two nodes in a graph provided that the edges in the graph have the weights 0 or 1. If you apply the BFS explained earlier in this article, you will get an incorrect result for the optimal distance between 2 nodes.
The table shows the codes and equivalent glass-types names for HOYA, SCHOTT, OHARA, HIKARI, SUMITA and CDGM.The codes are given in six digits. The first three digits are the refractive index (nd), and the last three digits are the Abbe-number (νd).
4 -> 1 -> 3 edges[ 4 ][ 0 ].first = 1 , edges[ 4 ][ 0 ].second = 0 edges[ 4 ][ 1 ].first = 3 , edges[ 4 ][ 1 ].second = 0
2 -> 0 -> 3 edges[ 2 ][ 0 ].first = 0 , edges[ 2 ][ 0 ].second = 0 edges[ 2 ][ 1 ].first = 3 , edges[ 2 ][ 1 ].second = 0