Results 1 to 12 of 12
- 03-22-2009, 10:07 PM #1
Member
- Join Date
- Mar 2009
- Posts
- 13
- Rep Power
- 0
help ... i have a problem withe dijkstra algorthim
:)hi all;
I have the code of the static dijkestra algorithm and i want to converted to be dynamic, but i really got stuck . i have the layout code but i didn't understand it. So any one who has experiance in the Dijkstra algorithm can help me.
this is the static dijkstra algorithm java source:
package DijkstraAlgorithm.src.graphs;
import java.util.Hashtable;
/**
* @author vsutskever
*
*/
public class Dijkstra {
private Graph graph;
//priority queue stores all of the nodes, reachable from the start node
//The queue is sorted by the node.distance
private GraphNodePriorityQueue priorityQ = new GraphNodePriorityQueue();
private Hashtable <GraphNode,Integer> distance = new Hashtable<GraphNode, Integer>();
//1. needs to get the list of all nodes in the graph
//2. need to initialize distance vector to infinity
//3. Need Edge Cost function
public Dijkstra (Graph g){
this.graph = g;
this.graph.getStartNode().setDistance(0);
this.priorityQ.add(this.graph.getAllNodes());
}
/**
* Actual algorithm
*/
public void go(){
while (this.priorityQ.hasMore()){
GraphNode n = this.priorityQ.remove();
for (Edge e: n.getOutGoingEdges()){
GraphNode adjNode = e.getNode();
Integer newPossiblePathCost = e.getCost()+n.getDistance();
if (newPossiblePathCost<adjNode.getDistance()){
adjNode.setDistance(newPossiblePathCost);
this.priorityQ.updateGraphNodeDistance(adjNode);
}
}
}
}
/**
*
*/
public void PrintStatusOfPriorityQ(){
this.priorityQ.PrintContents();
}
}
and this is the layout code for the dynamic:
Dijkstra_Double_Bucket:
INPUTS:
V, the set of nodes in the network
E, the set of arcs in the network
C, max(||e||), "eÎE
s, the source node, sÎV
B, a constant used to determine number of buckets
e.g. largest power of 2 <ÖC
OUTPUTS:
P, the set of parent nodes on shortest paths to nearest
source
VARIABLES:
High, an array of Lists
Low, an array of Lists
let source sÎV have d(s)¬0, S(s)¬labelled
let all other nodes vÎV have d(s)¬¥, S(s)¬unreached
Num¬é(C+1)/Bù
Low: array [0..B] of List
High: array [0..Num] of List
Insert(Low[0],s)
for L in 0 to Num loop
for P in 0 to B loop
while ØEmpty(Low[P]) loop
Scan(Head(Low[P]))
for all {w|(Head(Low[P]),w) Î E Ù S(w)=labelled} loop
if d(w)>((L+1)B - 1) then
/* INSERT IN UPPER BINS */
Insert(High[ëd(w)/Bû],w)
else
/* INSERT IN LOWER BINS */
Insert(Low[d(w) - LB], w)
end if
end loop
Remove(Low[L], Head(Low[L]))
end loop
end loop
end loop
So can any one help me please.....:p
- 03-23-2009, 08:30 AM #2
Member
- Join Date
- Mar 2009
- Posts
- 13
- Rep Power
- 0
i am sad
17 views .... and no one help me:confused:...
- 03-24-2009, 09:35 PM #3
Member
- Join Date
- Mar 2009
- Posts
- 13
- Rep Power
- 0
38 views .... and no one help me...
i really need the help.. no one of you have an experiance in dijkstra.....
- 03-24-2009, 10:23 PM #4
1. Can't really read the code. There are lots of strange characters and you should use CODE tags.
2. What have you tried? What is the specific problem? We're not here to do coding work for free.
- 03-24-2009, 10:54 PM #5
Member
- Join Date
- Mar 2009
- Posts
- 13
- Rep Power
- 0
i didn't ask you for coding...
I face a problem with my code and i want a proffisional one in Dijkstra to solve it....
- 03-25-2009, 02:06 AM #6
I would be happy to help but the code you have provided is very difficult to read. It looks like you have tried to copy and paste text with non-ASCII characters in it and it hasn't worked properly.
What is the source of the "layout code" that you have and what exactly do you want to achieve by making the code "dynamic"?
- 03-26-2009, 06:51 PM #7
Member
- Join Date
- Mar 2009
- Posts
- 13
- Rep Power
- 0
hello OrangeDog...
I want to change the static to dynamic for my project..
it seems that iwas wrong since this layout fro static not dynamic...
thanks for trying to help , i really appreciate it...
i will try to search for another layout to help me to write the right code for dynamic...
thanks a gain^^
- 03-26-2009, 10:06 PM #8
What do you mean by dynamic? Is it just a different implementation of a priority queue? For the largest connected data sets, a Fibonacci Heap is the best current data structure.
- 03-27-2009, 06:45 PM #9
Member
- Join Date
- Mar 2009
- Posts
- 13
- Rep Power
- 0
yes you are right i was mistaken...
i face this problem now when i tried to run the project...
log4j:WARN No appenders could be found for logger (graphs).
log4j:WARN Please initialize the log4j system properly.
it seems that there is a problem with the log4j file...
do you know how to solve it??
- 03-27-2009, 06:57 PM #10
Don't know what a log4j file is. Presumably you're using some kind of library you haven't told us about. I would suggest looking at its documentation.
- 03-27-2009, 07:03 PM #11
Member
- Join Date
- Mar 2009
- Posts
- 13
- Rep Power
- 0
it is a very huge documentation ... so i can't posted....
Log4j is an open source tool developed for putting log statements into your application. It was developed by the good people at Apache's Jakarta Project. It's speed and flexibility allows log statements to remain in shipped code while giving the user the ability to enable logging at runtime without modifying any of the application binary. All of this while not incurring a high performance cost.
^^
- 03-29-2009, 06:43 PM #12


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks