How to Find a lexicographic breadth first search ordering.

So I was asked the following problem :

Let G be the nine-vertex grid graph with vertices a, b, c, d, e, f, g, h, i and edges ab, bc, de, ef, gh, hi, ad, dg, be, eh, cf, and fi. Find a lexicographic breadth first search ordering for G, starting from vertex a.

The issue is that I don't understand how to obtain a lexicographic breadth first ordering.

According to the wiki (http://en.wikipedia.org/wiki/Lexicographic_breadth-first_search) the first steps are to "Initialize a sequence Σ of sets, to contain a single set containing all vertices", but I'm not sure what this means :(

I'd appreciate any help at all. Thanks! :)

👍︎ 2
💬︎
👤︎ u/frickit
📅︎ Jun 03 2011
🚨︎ report
Breadth First Search Algorithm to find minimum knight moves in Chess - Python code youtu.be/MjFjmwLbrk8
👍︎ 10
💬︎
📅︎ Jan 07 2022
🚨︎ report
Minimum Knight moves in Python - Breadth First Search algorithm youtu.be/MjFjmwLbrk8
👍︎ 4
💬︎
📅︎ Jan 10 2022
🚨︎ report
Breadth First Search Algorithm to find minimum moves by Knight in Python youtu.be/MjFjmwLbrk8
👍︎ 16
💬︎
📅︎ Jan 07 2022
🚨︎ report
Minimum Knight moves to destination based on Breadth First Search Algorithm in Python youtu.be/MjFjmwLbrk8
👍︎ 18
💬︎
📅︎ Jan 07 2022
🚨︎ report
Breadth-First Search Algorithm v.redd.it/9y53te55lis71
👍︎ 1k
💬︎
👤︎ u/quarkstuff
📅︎ Oct 10 2021
🚨︎ report
Minimum Knight Moves using Breadth First Search Algorithm in Python youtu.be/MjFjmwLbrk8
👍︎ 3
💬︎
📅︎ Jan 11 2022
🚨︎ report
Breadth First Search Algorithm for finding minimum knight moves in Python youtu.be/MjFjmwLbrk8
👍︎ 4
💬︎
📅︎ Jan 07 2022
🚨︎ report
Minimum Knight Moves using Breadth First Search Algorithm in Python youtu.be/MjFjmwLbrk8
👍︎ 3
💬︎
📅︎ Jan 11 2022
🚨︎ report
Minimum Knight moves using Breadth First Search Algorithm in Python youtu.be/MjFjmwLbrk8
👍︎ 6
💬︎
📅︎ Jan 10 2022
🚨︎ report
Would you only really use breadth and depth first search on tree data structure problems?

I had a problem where I had to search a 2D array and was wondering if BFS and DFS would make sense with that kind of data structure.

👍︎ 2
💬︎
👤︎ u/gtrman571
📅︎ Dec 08 2021
🚨︎ report
Depth-first search for pathfinding VS breadth-first search VS ...?

I want an AI to be able to move between isolated node graphs, essentially platforms. I already have A* for movement within the platforms, but between them is where I'm stuck. To move between two platforms, the AI would have do specific things corresponding to the environment around the two platforms, not simply physically jump from one to another. I don't want to optimize the distance traveled, just the number of crossings done. The platforms can take on any shape, size, and distance from one another. Not all platforms can go to all others.

So I did some searching and found depth-first searching and breadth-first searching but I just want an opinion on the best way to proceed, which is faster, etc.

👍︎ 2
💬︎
👤︎ u/Pinsplash
📅︎ Dec 23 2021
🚨︎ report
Ramesh Traveling Purchaser Problem (TPP) Lexicographic Search Algorithm

Hey guys, how you doing?

Im here to ask for you help. Im writing my bachelor paper as an implementation/review of the TPP algorithms out there. Almost every paper that I read references the Ramesh algorithm, that returns an exact solution for TPP problems, but I just can't find the algorithm, not even a high level description that I could use to implement my own version.

Does someone know how to implement it? I would be grateful with even a high level description.

There's other two approaches out there that I would be grateful to have access: the branch-and-bound algorithm of Singh and Van Oudheusden, and the branch-and-cut algorithm of Laporte. If someone know how to implement or something like that, please share with me.

In these two papers, you can find the actual references:

- https://ir.nctu.edu.tw/bitstream/11536/31784/1/000075284000001.pdf

- https://www.fsa.ulaval.ca/personnel/renaudj/pdf/Recherche/tpp(purchaser)%20COR.pdf

If you don't what's the TPP, please see this link: https://en.wikipedia.org/wiki/Traveling_purchaser_problem before answering

Guys, I know that this is an NP-HARD problem, and that it's always best to use Heuristic Algorithms instead of exact ones for larger instances, but I still want to study the exact ones.

Thanks! Any help is very welcome.

👍︎ 6
💬︎
📅︎ Dec 18 2021
🚨︎ report
Used breadth first search to find yo mommas place
👍︎ 2k
💬︎
📅︎ Jul 16 2021
🚨︎ report
Pathfinding Visualizer: A*, Dijkstra, Bidirectional Search, Breadth First josephprichard.github.io/…
👍︎ 165
💬︎
👤︎ u/SpeedDart1
📅︎ Jun 14 2021
🚨︎ report
Why am I getting an "Access violation writing location" error on my Breadth-First-Search visualizer?

Just to mention, the program runs with the help of the OLCPixelGameEngine library for convenience sake thus I will post the github repository to make it easier for people to test.

Source: https://github.com/xGainzMan555x/Breadth-First-Search-visualizer

All the details are listen in the README file.

In short the error happens when adding an obstacle to a certain part of the grid or when the key for the start of the algorithm is pressed and the start and end nodes are added.

I will also paste the code here if anyone wants to look at it here first.

#define OLC_PGE_APPLICATION
#include "olcPixelGameEngine.h"
#include <iostream>
#include <queue>
class BreadthFirstSearch : public olc::PixelGameEngine
{
	struct Node
	{
		int x;
		int y;
	};

	Node *node = nullptr;
	Node* rootNode = nullptr;
	Node* endNode = nullptr;
	int gap = 30; // gap is gotten by dividing the screen width (or height since both are 600 pixels) by the number of rows or columns (both of which are 20)


public:
	BreadthFirstSearch()
	{
		sAppName = "Breadth-First search visualizer";
	}

public:
	bool OnUserCreate() override
	{
		Clear(olc::WHITE);
		node = new Node[400]; // This is a 20x20 grid so in total there are 400 members
		for (int x = 0; x < 20; x++)
		{
			for (int y = 0; y < 20; y++)
			{
				DrawLine(x, y * gap, 600, y * gap, olc::BLACK); // Draw rows
				DrawLine(x * gap, y, x * gap, 600, olc::BLACK); // Draw columns
				// Saving the coordinates for the nodes
				node[y * 20 + x].x = x;  
				node[y * 20 + x].y = y;
			}
		}
		return true;
	}

	bool OnUserUpdate(float fElapsedTime) override
	{
		// Gets the coordinates for the mouse position.
		int mouseX = (GetMouseX() / gap) * gap;
		int mouseY = (GetMouseY() / gap) * gap;
		// Variables for storing the coordinates
		int startingRow;
		int startingColumn;
		int endRow{};
		int endColumn{};
		// Bool variables for checking the validity of the node
		bool reachedEnd = false;
		bool obstacle[20][20];
		bool visited[20][20];
		// This is used when searching for neighbours of a node (top, bottom, right, left)
		int directionRow[4] = { +1, -1, 0, 0 };
		int directionColumn[4] = { 0, 0, +1 ,-1 };
		// Queues f
... keep reading on reddit ➡

👍︎ 2
💬︎
👤︎ u/niggz555
📅︎ Aug 08 2021
🚨︎ report
Breadth-First Search episode is seriously my favorite episode from David vs Goliath: Check the comments for what makes this episode my favorite!
👍︎ 116
💬︎
📅︎ Feb 17 2021
🚨︎ report
Breadth First Search in prod
👍︎ 37
💬︎
📅︎ May 14 2021
🚨︎ report
[OC] Breadth-first search through the recommendations of a website
👍︎ 13
💬︎
👤︎ u/RandomBane
📅︎ Jun 07 2021
🚨︎ report
Breadth-first search with Python code - I think you will like this one. youtube.com/watch?v=-yF6k…
👍︎ 6
💬︎
📅︎ Jul 09 2021
🚨︎ report
Novel Uses of Breadth-First Search

I'm trying to create an exercise that showcases a societal use of breadth-first search? That is an application of breadth-first search that benefits society: breadth-first search helps people find transplant donors, something like that, for instance. And it can't be too obvious, like finding the optimal route from A to B or something.

I haven't been able to come up with anything satisfactory despite my numerous Google searches. I would really appreciate any suggestions.

👍︎ 4
💬︎
📅︎ Feb 25 2021
🚨︎ report
How does breadth first search work?

I understand DFS, but BFS is just really hard for me to wrap my head around. I know that it kind of moves out across a tree like a ripple effect, but how would that be coded? DFS is just going left till you get to the end then moving right, I think. But how could you move an entire level down at one time?

👍︎ 16
💬︎
👤︎ u/WiggWamm
📅︎ Jan 06 2021
🚨︎ report
Breadth-first search visualization v.redd.it/8lc2lgakxn241
👍︎ 4k
💬︎
👤︎ u/pedrovhb
📅︎ Dec 04 2019
🚨︎ report
How does Breadth-First Search find the shortest path from the source vertex to the destination vertex?

My professor mentioned how BFS can give you the shortest path from the source vertex to the destination vertex, which makes sense since you traverse the adjacent nodes. However, I do not see how that is guaranteed to happen always. Nowhere in the BFS pseudocode logic do I see to pick the correct adjacent node to guarantee to have the shortest path. BFS could pick any random adjacent node and end up with the longer path from the source vertex to the destination vertex. Then how does BFS give the shortest path from the source vertex to the destination vertex?

For example:

Let's say I ran BFS on the below graph: could it not find the path from S to Y to be to S to W to T to X to U to Y, which would not be the shortest path?

https://app.sketchtogether.com/s/sketch/Hv32T.3.1/

👍︎ 21
💬︎
👤︎ u/wildguy57
📅︎ Nov 29 2020
🚨︎ report
Breadth-first search (code critique request)

I was doing more leetcode when I realized I was rusty on BFS, so I set out to implement it in Racket. Here is my implementation. It takes an adjacency list (a list where each element is a list of the connected nodes for that node index) and the start/source node as input and returns the predecessor array. The queue is something I implemented based on Okasaki's Purely Functional Data Structures (minus the laziness, I'm still figuring out laziness in Racket by reading through code in the pfds collection).

(define (breadth-first-search g s)
  (let* ([n (length g)]
         [gvec (list->vector g)]
         [color (make-vector n 0)]
         [d (make-vector n -1)]
         [p (make-vector n -1)]
         [q (make-queue)])
    (vector-set! color s 1)
    (vector-set! d s 0)
    (queue-push q s)
    (do ([u (queue-head q) (queue-head q)])
        ((queue-empty? q)
         p)
      (for-each (lambda (v)
                  (when (zero? (vector-ref color v))
                    (vector-set! color v 1)
                    (vector-set! d v (add1 (vector-ref d u)))
                    (vector-set! p v u)
                    (queue-push q v)))
                (vector-ref gvec u))
      (queue-pop q)
      (vector-set! color u 2))))

This code works, but it feels very imperative to me. This is partly because of the vectors that I used since I wanted O(1) access to vector elements. The do also feels weird, though I have don't know of a better way to iterate when the iteration is not over a sequence. Is there a way to convert something like a queue into a sequence? It feels like that might be connected to laziness. Lastly, I mentioned the pfds collection above, is there something that prevents me from using typed Racket in a normal Racket program, i.e. are types an all-or-none proposition?

👍︎ 8
💬︎
👤︎ u/_chococat_
📅︎ Apr 08 2021
🚨︎ report
Breadth First Search (BFS) - Common in Silver?

I know that DFS is one of the most important topics in silver but what about BFS? Does that show up too often?

Side question: Will I need to know dynamic programming in Silver?

Thank you!

👍︎ 11
💬︎
👤︎ u/dhruvmk
📅︎ Dec 29 2020
🚨︎ report
Breadth-first search with Python code youtube.com/watch?v=-yF6k…
👍︎ 18
💬︎
📅︎ Feb 26 2021
🚨︎ report
Breadth-First Search v.redd.it/yyl26mgwwiv41
👍︎ 417
💬︎
👤︎ u/jainm
📅︎ Apr 28 2020
🚨︎ report
Why am I getting an "Acces violation writing location" error on my Breadth-First-Search visualizer?

Just to mention, the program runs with the help of the OLCPixelGameEngine library for convenience sake thus I will post the github repository to make it easier for people to test.

Source: https://github.com/xGainzMan555x/Breadth-First-Search-visualizer

All the details are listen in the README file.

The errors happen when 1.) Obstacle nodes are being added and a certain part of the grid is passed 2.) When the start and end nodes are placed (without barriers) and the space button is pressed for the algorithm to begin. I have no clue why this happens since it seems to me that everything is initialized. What is actually supposed to happen is that, when the alogrithm starts, it checks the neighbours of the start node first before checking the neighbour of the neighbour etc. After checking the neighbour if the node is not visited or an obstacle it is colored blue and marked as visited. This, of course, does not work for now but the code for it is added.

I will also paste the code here if anyone wants to look at it here first.

#define OLC_PGE_APPLICATION
#include "olcPixelGameEngine.h"
#include <iostream>
#include <queue>
class BreadthFirstSearch : public olc::PixelGameEngine
{
	struct Node
	{
		int x;
		int y;
	};

	Node *node = nullptr;
	Node* rootNode = nullptr;
	Node* endNode = nullptr;
	int gap = 30; // gap is gotten by dividing the screen width (or height since both are 600 pixels) by the number of rows or columns (both of which are 20)


public:
	BreadthFirstSearch()
	{
		sAppName = "Breadth-First search visualizer";
	}

public:
	bool OnUserCreate() override
	{
		Clear(olc::WHITE);
		node = new Node[400]; // This is a 20x20 grid so in total there are 400 members
		for (int x = 0; x < 20; x++)
		{
			for (int y = 0; y < 20; y++)
			{
				DrawLine(x, y * gap, 600, y * gap, olc::BLACK); // Draw rows
				DrawLine(x * gap, y, x * gap, 600, olc::BLACK); // Draw columns
				// Saving the coordinates for the nodes
				node[y * 20 + x].x = x;  
				node[y * 20 + x].y = y;
			}
		}
		return true;
	}

	bool OnUserUpdate(float fElapsedTime) override
	{
		// Gets the coordinates for the mouse position.
		int mouseX = (GetMouseX() / gap) * gap;
		int mouseY = (GetMouseY() / gap) * gap;
... keep reading on reddit ➡

👍︎ 2
💬︎
👤︎ u/niggz555
📅︎ Aug 08 2021
🚨︎ report

Please note that this site uses cookies to personalise content and adverts, to provide social media features, and to analyse web traffic. Click here for more information.