Algorithm Question

Started by
9 comments, last by CottonCandyRandy 13 years, 3 months ago
So thanks to Wikipedia, I've come up with the following:

private void bfs(List<Room> rooms, Room room, Pen pen, Rectangle rectangle, Graphics graphics)        {            Queue<Room> q = new Queue<Room>();            q.Enqueue(room);            room.visited = true;            Console.WriteLine(room.name);            graphics.DrawRectangle(pen, rectangle);            while (q.Count != 0)            {                Room v = q.Dequeue();                Console.WriteLine("v: " + v.name);                foreach (Room edge in v.getExits())                {                    if (!edge.visited)                    {                        edge.visited = true;                        Console.WriteLine("edge: " + edge.name);                        q.Enqueue(edge);                    }                }            }


This code appears to successfully traverse the graph. Now, the difficulty is deciding where to set the rectangle position and where to draw it. The physical drawing of the graph will be very logical and grid-like since there are only N,S,E and W exits (also, IN and OUT which I'll deal with later). Each room will be 100 pixels from it's connecting room. Of course this also introduces the problem of overlapping rooms...
Done > Perfect

This topic is closed to new replies.

Advertisement