[Java – Algorithm] Simulation Dijkstra's algorithm to find the shortest path
About algorithm, You can view the article in Find the shortest path Dijkstra, Floyd. This article I will introduce you to the simulation program Dijkstra's algorithm with graphics on Java, This is also the subject of their practice facility.
Update Date 23/05/2015: Fix icon on windows loaded.
The program allows users to draw graphs quickly and easily, Points can drag and pull, erase, tri repair costs (weight), … or you can use the graphs available in the demo. And when run will show the way on the graph below and share Log. At the bottom there is a table to describe the work done by hand when we need to do to find the shortest path. It also allows us to keep the graph, open graph Saved. In fact, it says it is long, I would say the functionality of the program in the long video 7 minutes following.
Note * want to run jar files you need to install the JDK for PC.
Download the source code and jar files of the program
All inquiries, suggestions please connected directly to your Email.
Refer: My Products
Thank you!
You ask yourself is the code of the program, what is the function implementing Dijkstra's algorithm?
Apologies are due to code inexperienced and did not fit in the code annotations.
You may notice in Class MyDijkstra 2 Dijkstra function and dijkstraStep. It is 2 function algorithm that practice and perform stepwise algorithm. 2 the corresponding function is tracePathStep tracepath and trace the path and trace the path step by step.
e question is a bit of guidance on how chtrinh sir j?
They do show that you. You can download it at the end of the article.
It has to apply his greedy algorithm?
This is where Dijkstra
Dijkstra là dựa trên “greedy algorithm” mà bạn. Bản chất là thế, chẳng qua nó áp dụng cho graph thôi. Mình thấy bạn kia hỏi có sai gì đâu. Thuật toán Floyd-Warshall thì dựa vào “dynamic programming” but.
a dear. e are working on Dijkstra's algorithm in c . e was running but running to insert code matrix .txt file to read way. e now want to draw a graph as they do, sir tn?
If you use C should understand it, the new graphics do.
You can refer to this post, or read the documentation at the end of it all graphics in C
https://www.cachhoc.net/2013/10/03/cc-do-hoa-trong-dev-c/
a dear. but made e c . visual motor running. tn do sir?
This is clearly not alone and. I do not ever use it all :3
I have simulated using C # does not he?
Mình không có demo trên C# bạn ah 🙂
you can link down please e jdk is not, e have installed several times, but could not open his demos, em toàn học C# nên gà khoảng java này quá 😀
Ban vao day: http://www.oracle.com/technetwork/java/javase/downloads/index.html
Waiter, you install java finish, when open java, existing java control panel board, e to do next so a?
So now you want to do? :in
Dijkstra.jar his run down the file but not, not illustrated
You see the watch has successfully installed jdk nhá, to make sure you watch the video instructions:
a ơi cho em hỏi làm sao để chạy được file này khi em đả cài jdk và eclipse rồi a.
Sao lại không chạy được ah. Bạn thử xem chương trình có báo lỗi gì không?
nó báo lỗi unable to access jarfile này ah.e mở file dijkstra.jar không được anh. help e with. e đang cần làm báo cáo ạ
bạn liên hệ face mình nhé. mình teamview cho.
fb.com/nguyenvanquan7826
I would like to link to e hoa hoc java.nhu by baj tren a blue whale !
e cam on..
Their learning in school curricula do not know what to google only, also bookmark days ago 2,3 link Graphical simple but lost then reinstall machine. Bạn chịu khó google là được mà 😀
My brother and download the JDK, His program then downloads, how to open his show here, you do not know how to open, the file you downloaded unzip pharmacy 1 Dijkstra folder named with 1 rar file named Dijkstra.rar
He flashed his quick reply, This is what you need to fold!
Download the extract you will be 1 directory and 1 file like this. The directory is a source, you can import into eclipse to see, repair, developmental. File .jar file that can run. Want to run you need to install jdk. Còn việc chạy hay cài thế nào bạn google nhá 😉
Note that you will not be able to plant now, but it still is a file extension 1 directory and 1 run as image files offline.
jar file that you want to open it in any way, Bro, double-click is à, he is spending à ubuntu OS, are your windows 7, ubuntu is open the Bro
Win or so is that ubuntu :3
a..minh found this roi..ban Oh please yourself with the flowchart algorithm is not :((
Flowchart algorithm???
You understand it is carved draw, this is also drawn to her again, then….
we learn that bad programming damage ..ve di..nan felt that his Dum ..:((
my friend…giúp mình đi mà cho mình cái lưu đồ đi 🙁
You see right here
http://vi.wikipedia.org/wiki/Th%E1%BA%A3o_lu%E1%BA%ADn_Th%C3%A0nh_vi%C3%AAn:Ilen.khtn#L.C6.B0u_.C4.91.E1.BB.93_thu.E1.BA.ADt_to.C3.A1n.5B1.5D
Search google a lot that
oh thank .cam ,thank you,,thanks so much more original finish invite you nhe..bac Report 1 flanking fruit beams offline :))
Oh finished, where t know where you are going to eat here =))
sdt you then you have to invite your ma..nhat 1 chau..ma you in anyway :))
Mình trên Thái Nguyên 😉
He asked for the file ending with e dij why he created it so. Kids learn hum h without understanding
thế thì xa quá ha 🙁
Oh you yourself ask your voi..cai this article is limited to how many nodes that anyway? his examples from node 1 to 5 the time it faster 1 next 10 on.If not be the answer to his early nha..cam thank you much,hi
Unlimited offline, with some classic at the time no gap, points more likely to lag slightly.
bạn có thể cho mình địa chỉ facebook or đại loại gì không cho mình địa chỉ để mình hỏi vài điều chút 😀
Bạn có thể hỏi trực tiếp ở đây mà 🙂
Waiter, anh có nguồn download phần mềm này không ạ? anh có thể cho em được không ạ! cảm ơn anh trước!
Mã nguồn ở cuối bài viết đó bạn
My friends have ctrinh run b equals c khong.cho consult their
You see here nhá https://cachhoc.net/2013/10/13/thuat-toan-tim-duong-di-ngan-nhat-dijkstra-floyd/
Cho mình xin mã nguồn được không ạ, down theo link trên chỉ có phần file thực thi 😀
Powered in below in your.
Offers you yourself know your article page https://www.cachhoc.net/2014/06/14/java-thuat-toan-mo-phong-thuat-toan-dijkstra-tim-duong-di-ngan-nhat/
Can you help me this problem is not. when I rename your package in soude nguyenvanquan7826 into AI code is not readable file demo(announcement is Erro read demo file). you can help yourself is not. Change yourself into demo.dat file nguyenvanquan7826 -> AI and still not be. Hope you help,thank you . you can send an email to nguyenhaidang200291@gmail.com their only remedy is not
Answered you in the mail offline.
What you need without opening the jar file, you very Properties – Permissions. Built-in “Allow executing file as program” is run carefree ^^
Thank you.
If you want to add 1 Prev button – back 1 Steps + 1 Auto follow button custom speed must write how events that he ? A Java newbie questions ^^!
This one you see in the code will see a step function k. You click the up or down next pre k is đk.
So also want the program to run automatically according to speed and can stick Pause again how he must?
You also rely on that mode.
You can demo samples so you have a better idea is not? I was too chicken dim -_- Tks him before ^^
I'm just suggesting to you that's all multiple account names, but now I do not remember all đk code in which to see and do it again. A few years before that…
So I need to create a method runPrev(), drawPrev(),… similar runStep() not?
It's up to you. You program it deems necessary or not because you.
If you want from this project develop smallest Find spanning tree, he may suggest you are not making ?
Minimum spanning tree has not made himself ever so do not promise you is
Did Prev, thank you for suggestions ^^ . That process will be hit next run continuously, how to button Next Play it yourself that you do not need so click Next? I see 1 Some examples using thead to sleep but to adjust the speed of your code does not use @@ Thread!
I write for the spanning tree algorithm smallest = Kruskal then how to apply his myDraw to draw on this graph ?
public class MyMSTKruskal {
private ArrayList arrLineA = new ArrayList();
private ArrayList arrLineE = new ArrayList();
private ArrayList arrMyPoint = new ArrayList();
int p[];
int sodinh, chiso = 0;
int TongTS =0;
int socanh;
private boolean mapType = false;
public void input()
{
sodinh = arrMyPoint.size()-1;
socanh = arrLineE.size()-1;
for(int i=0;in<socanh;i )
arrLineA.add(null);
p = new int[sodinh + 1];
System.out.println("so dinh : "+sodinh);
for(int i =0;in<sodinh;i )
{
p[in] = I;
}
System.out.println("so canh : "+socanh);
for(int i=0;in<socanh;i )
{
System.out.println("nhap u : "+arrLineE.get(i 1).getIndexPointA());
System.out.println("nhap v : "+arrLineE.get(i 1).getIndexPointB());
System.out.println("nhap trong so : "+arrLineE.get(i 1).getCost());
}
}
public void sort()
{
Collections.sort(arrLineE, new MyLineComparator());
// for(MyLine emp : arrLineE){
// System.out.println(emp);
// }
}
public void kruskal()
{
sort();
for (int i = 0; in < socanh; i )
if(p[arrLineE.get(i 1).getIndexPointA()]!=p[arrLineE.get(i 1).getIndexPointB()])
{
arrLineA.set(chiso ++, arrLineE.get(i 1));
System.out.println(arrLineA.get(in));
int t=max(p[arrLineE.get(i 1).getIndexPointA()],p[arrLineE.get(i 1).getIndexPointB()]);
int k=min(p[arrLineE.get(i 1).getIndexPointA()],p[arrLineE.get(i 1).getIndexPointB()]);
p[arrLineE.get(i 1).getIndexPointA()]=p[arrLineE.get(i 1).getIndexPointB()]=k;
for(int j = 0;j<sodinh;j )
if(p[j]==t)
p[j]=k;
}
}
public void output()
{
System.out.println("cac canh can chon : ");
for(int i=0;ib) return a;
else return b;
}
public int min(int a, int b)
{
if(the<b) return a;
else return b;
}
This is the art of thinking and gradually. You only have to think.
he has made the A * algorithm does not apply to me sir
a ơi phần khởi tạo khi hiển thị kết quả giống các bước trong giáo trình sao tất cả lại là vô cùng ạ? thanks a!
Waiter, a có source code tìm đường đi chu trình euler k cho e ới
Anh không có 🙂
Anh ơi cho e hỏi đây có phải là đề tài đồ án giải thuật và lập trình không ạ , và đồ án là mình phải làm một chương trình có giao diện sử dụng như phần mềm của a vậy hả ? 🙂 , e chưa hiểu về đồ án cho lắm
Có thể coi là vậy, nhưng tùy cái mà có cần chương trình không. 🙂
A ơi Em đang làm về thuật toán này mà dùng matlab. A hỗ trợ em được k ạ
Matlab mình ko rõ nên không giúp được bạn rồi. Bạn cố gắng dựa vào tư tưởng để chuyển về code matlab nhé.
còn cái phần mềm trên là anh tự viết hay sao ạ
ukm 🙂
Anh ơi theo bài anh thì khi vẽ các đỉnh các đỉnh sẽ được gán theo thứ tự 1-2-3,.. nhưng bây giờ em muốn thay đổi các đỉnh theo thứ tự là A-B-C,…. v có được hk. Nếu được thì làm như nào v ạ.
Anh ơi em xem thuật toán, các biến, các hàm trong class MyDijkstra mà hk hiểu. Can you explain to me each function as well as command line hk sir. I needed. What if there is a mail e dkien sir
Open how to view code sir
You downloaded to extract nhé.
darling children running faulty download
Error chose points or don’t Update graph to choé points
You have no start or end point, Whether or not to click the sync button to generate the graph after drawing or selecting demo.
my friend how I download so no jar file
You unzip will see nhé.
Waiter….What are the limitations and direction of development of dijkstra's algorithm a
You understand it and find out for yourself.
May I ask how can I put the weight graph into the running interface?