Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
gs-algo
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
graphstream
gs-algo
Commits
86d05e5c
Commit
86d05e5c
authored
May 30, 2012
by
sbalev
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of github.com:graphstream/gs-algo
parents
332fae9d
c443c9ee
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
7 deletions
+11
-7
src/org/graphstream/algorithm/AStar.java
src/org/graphstream/algorithm/AStar.java
+11
-7
No files found.
src/org/graphstream/algorithm/AStar.java
View file @
86d05e5c
...
@@ -194,10 +194,10 @@ public class AStar implements Algorithm {
...
@@ -194,10 +194,10 @@ public class AStar implements Algorithm {
protected
Path
result
;
protected
Path
result
;
/**
/**
* Set to
tru
e if the algorithm ran, but did not found any path from the
* Set to
fals
e if the algorithm ran, but did not found any path from the
* source to the target.
* source to the target
, or if the algorithm did not run yet
.
*/
*/
protected
boolean
noPathFound
;
protected
boolean
pathFound
=
false
;
/**
/**
* New A* algorithm.
* New A* algorithm.
...
@@ -313,13 +313,14 @@ public class AStar implements Algorithm {
...
@@ -313,13 +313,14 @@ public class AStar implements Algorithm {
* {@link #compute(String, String)}, if the {@link #getShortestPath()}
* {@link #compute(String, String)}, if the {@link #getShortestPath()}
* returns null, or this method return true, there is no path from the given
* returns null, or this method return true, there is no path from the given
* source node to the given target node. In other words, the graph has
* source node to the given target node. In other words, the graph has
* several connected components.
* several connected components. It also return true if the algorithm did
* not run.
*
*
* @return True if there is no possible path from the source to the
* @return True if there is no possible path from the source to the
* destination.
* destination
or if the algorithm did not run
.
*/
*/
public
boolean
noPathFound
()
{
public
boolean
noPathFound
()
{
return
noPathFound
;
return
(!
pathFound
)
;
}
}
/**
/**
...
@@ -385,7 +386,7 @@ public class AStar implements Algorithm {
...
@@ -385,7 +386,7 @@ public class AStar implements Algorithm {
closed
.
clear
();
closed
.
clear
();
result
=
null
;
result
=
null
;
noP
athFound
=
false
;
p
athFound
=
false
;
}
}
/**
/**
...
@@ -403,6 +404,8 @@ public class AStar implements Algorithm {
...
@@ -403,6 +404,8 @@ public class AStar implements Algorithm {
new
AStarNode
(
sourceNode
,
null
,
null
,
0
,
costs
.
heuristic
(
new
AStarNode
(
sourceNode
,
null
,
null
,
0
,
costs
.
heuristic
(
sourceNode
,
targetNode
)));
sourceNode
,
targetNode
)));
pathFound
=
false
;
while
(!
open
.
isEmpty
())
{
while
(!
open
.
isEmpty
())
{
AStarNode
current
=
getNextBetterNode
();
AStarNode
current
=
getNextBetterNode
();
...
@@ -411,6 +414,7 @@ public class AStar implements Algorithm {
...
@@ -411,6 +414,7 @@ public class AStar implements Algorithm {
if
(
current
.
node
==
targetNode
)
{
if
(
current
.
node
==
targetNode
)
{
// We found it !
// We found it !
assert
current
.
edge
!=
null
;
assert
current
.
edge
!=
null
;
pathFound
=
true
;
result
=
buildPath
(
current
);
result
=
buildPath
(
current
);
return
;
return
;
}
else
{
}
else
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment