-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/master'
- Loading branch information
Showing
15 changed files
with
169 additions
and
100 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package uni.bilkent.hai; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
import java.util.Stack; | ||
|
||
/** | ||
* Created by deniz on 09/03/17. | ||
*/ | ||
public class GraphTraverser | ||
{ | ||
public GraphTraverser() | ||
{ | ||
StateGenerator sg = new StateGenerator(); | ||
State start = sg.getStartState(); | ||
StateTree tree = new StateTree( start); | ||
|
||
Stack<State> path = new Stack<State>(); | ||
List<State> visited = new ArrayList<State>(); | ||
|
||
visited.add( start); | ||
path.add( start); | ||
|
||
while ( !path.isEmpty()) | ||
{ | ||
State cur = path.peek(); | ||
System.out.println( cur); | ||
List<State> neighborStates = cur.getNeighborStates(); | ||
boolean deadEnd = true; | ||
|
||
for ( State s : neighborStates) | ||
{ | ||
if ( !visited.contains( s)) | ||
{ | ||
path.push(s); | ||
visited.add( s); | ||
deadEnd = false; | ||
break; | ||
} | ||
} | ||
|
||
if ( deadEnd) | ||
path.pop(); | ||
} | ||
|
||
System.out.println( visited.size()); | ||
} | ||
|
||
public static void main( String[] args) | ||
{ | ||
GraphTraverser gt = new GraphTraverser(); | ||
} | ||
} |
6 changes: 1 addition & 5 deletions
6
.../java/uni/bilkent/hai/graph/GUI/Main.java → src/main/java/uni/bilkent/hai/Main.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,43 +1,44 @@ | ||
package uni.bilkent.hai; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
/** | ||
* Created by eliztekcan on 9.03.2017. | ||
*/ | ||
public class StateTree{ | ||
public class StateTree | ||
{ | ||
private Node root; | ||
|
||
public StateTree( State s){ | ||
root = new Node( s); | ||
} | ||
|
||
public Node getRoot() { | ||
return root; | ||
} | ||
|
||
public void setRoot(Node root) { | ||
public void setRoot( Node root) { | ||
this.root = root; | ||
} | ||
|
||
public StateTree(State s){ | ||
root = new Node(); | ||
} | ||
public static class Node { | ||
|
||
public static class Node{ | ||
private Node parent; | ||
private List<Node> children; | ||
private State state; | ||
|
||
public Node getParent() { | ||
return parent; | ||
public Node( State s) | ||
{ | ||
state = s; | ||
children = new ArrayList<Node>(); | ||
} | ||
|
||
public State getState() { return state; } | ||
|
||
public List<Node> getChildren() { | ||
return children; | ||
} | ||
|
||
public void setChildren(List<Node> children) { | ||
this.children = children; | ||
} | ||
|
||
public void setParent(Node parent) { | ||
this.parent = parent; | ||
} | ||
public void addChild( Node child) { children.add( child); }; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.