473,396 Members | 1,671 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Java Breadth First Search problem

Hello lads i have a problem about the Breadth First Search . I need to do an implementation of a checking algorith that check from a Game Graph that i have create if every non-object node appears between 2 connection nodes
The code that i have done untill now is :
Can anyone helps

Expand|Select|Wrap|Line Numbers
  1.  
  2. public class StructurallyValidGraph extends GameGraph implements StructuralValidatorRules
  3. private ArrayList<Node>ToDo;
  4. private ArrayList<Node>visited;
  5.  
  6.  
  7.  
  8. public StructurallyValidGraph(String name,StartNode start,GoalNode goal) {
  9. super(name,start,goal);
  10.  
  11.  
  12. ToDo= new ArrayList<Node>();
  13. }
  14.  
  15. /**
  16. * Check that every non-object node (except perhaps the in node of the
  17. * start location and the out nodes of goal locations) appears between
  18. * two connection links.
  19. */
  20.  
  21.  
  22. public boolean nonObjectNodeValidation() throws NotImplemented {
  23. throw new NotImplemented();
  24.  
  25. return check();
  26.  
  27. }
  28.  
  29.  
  30.  
  31.  
  32. public boolean visit (Node ANode)
  33. {
  34. if(currentNode.ANode) // check if Already visited
  35. {
  36. return true;
  37. }
  38. visited.add(ANode);
  39. AllLinks =ANode.link();
  40. for ( i=0; i<AllLinks.size;i++)
  41. {
  42. Link OneLink =AllLinks.get(i);
  43. Node targetnode =OneLink.target();
  44. if (targetnode.getType()!="ObjectNode"&& OneLink.getType()!="ConnectionLink")
  45. {
  46. return false;
  47. }
  48. for ( i = 0; i<AllLinks.size(); i++)
  49. {
  50. ToDo.add((Node) AllLinks.get(i).target());
  51. }
  52. }
  53. }
  54.  
  55.  
  56. public boolean check()
  57. {
  58.  
  59. visited = new ArrayList<Node>();
  60. ToDo.add(start);
  61. while (ToDo.size()>0)
  62.  
  63.  
  64. ANode=ToDo.get(0);
  65. ToDo.remove(0);
  66. boolean pass = visit (ANode);
  67. if(pass==false)
  68. {
  69. return false;
  70. }
  71. return true;
  72. }
  73.  
Apr 2 '07 #1
1 5384
r035198x
13,262 8TB
Hello lads i have a problem about the Breadth First Search . I need to do an implementation of a checking algorith that check from a Game Graph that i have create if every non-object node appears between 2 connection nodes
The code that i have done untill now is :
Can anyone helps

Expand|Select|Wrap|Line Numbers
  1.  
  2. public class StructurallyValidGraph extends GameGraph implements StructuralValidatorRules
  3. private ArrayList<Node>ToDo;
  4. private ArrayList<Node>visited;
  5.  
  6.  
  7.  
  8. public StructurallyValidGraph(String name,StartNode start,GoalNode goal) {
  9. super(name,start,goal);
  10.  
  11.  
  12. ToDo= new ArrayList<Node>();
  13. }
  14.  
  15. /**
  16. * Check that every non-object node (except perhaps the in node of the
  17. * start location and the out nodes of goal locations) appears between
  18. * two connection links.
  19. */
  20.  
  21.  
  22. public boolean nonObjectNodeValidation() throws NotImplemented {
  23. throw new NotImplemented();
  24.  
  25. return check();
  26.  
  27. }
  28.  
  29.  
  30.  
  31.  
  32. public boolean visit (Node ANode)
  33. {
  34. if(currentNode.ANode) // check if Already visited
  35. {
  36. return true;
  37. }
  38. visited.add(ANode);
  39. AllLinks =ANode.link();
  40. for ( i=0; i<AllLinks.size;i++)
  41. {
  42. Link OneLink =AllLinks.get(i);
  43. Node targetnode =OneLink.target();
  44. if (targetnode.getType()!="ObjectNode"&& OneLink.getType()!="ConnectionLink")
  45. {
  46. return false;
  47. }
  48. for ( i = 0; i<AllLinks.size(); i++)
  49. {
  50. ToDo.add((Node) AllLinks.get(i).target());
  51. }
  52. }
  53. }
  54.  
  55.  
  56. public boolean check()
  57. {
  58.  
  59. visited = new ArrayList<Node>();
  60. ToDo.add(start);
  61. while (ToDo.size()>0)
  62.  
  63.  
  64. ANode=ToDo.get(0);
  65. ToDo.remove(0);
  66. boolean pass = visit (ANode);
  67. if(pass==false)
  68. {
  69. return false;
  70. }
  71. return true;
  72. }
  73.  
Where specifically do you need help and what steps have you taken so far?
Apr 2 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

45
by: Market Mutant | last post by:
I just wonder job selections, job openings and salary level of PHP programer or Perl programmer comparing to Java programmers. Is Java programmer's salary has a minimal of 60K in US? Are there...
8
by: slickn_sly | last post by:
Why am i getting an error? public void breadthFirst( TreeNode tNode) { Queue q = new Queue( ); if( q.isEmpty() ) { q.enqueue( this ); }
1
by: David Van D | last post by:
Hi there, A few weeks until I begin my journey towards a degree in Computer Science at Canterbury University in New Zealand, Anyway the course tutors are going to be teaching us JAVA wth bluej...
9
by: News | last post by:
I am new in using Python Anyone know how to implement breadth first search using Python? Can Python create list dynamically, I want to implement a program which will read data from a file and...
2
by: xandra | last post by:
i have 2 question in breadth-first traversal.your help will be appreciated. 1. what is the purpose of the queue in breath-first traversal? 2 suppose you had a function call displayAtDepthN which...
3
by: alaa123 | last post by:
hi plz do not ignore me I really neeed ur help I am working on a progarmme to implement First Search and Breadth Search I did the first search algorithm but I need help with implementing the...
0
by: varun aggarwal | last post by:
Hi i am doing the data structures in C++. I have seen the adjacency list implementation of depth first search/traversal that is using some recursive function to traverse the whole graph. but not...
3
by: javaboyjavaboy | last post by:
i need the coding of Breadth First Search program
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.