1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

examples: add new graph algorithms, make some minor corrections to the programs in examples/graphs (#14562)

This commit is contained in:
Claudio Cesar de Sá 2022-07-01 15:37:00 -03:00 committed by GitHub
parent dc9ff7cab2
commit 5b97ad15ad
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 5 additions and 15 deletions

View File

@ -8,7 +8,7 @@ https://www.geeksforgeeks.org/bellman-ford-algorithm-dp-23/
For Portugese reference For Portugese reference
http://rascunhointeligente.blogspot.com/2010/10/o-algoritmo-de-bellman-ford-um.html http://rascunhointeligente.blogspot.com/2010/10/o-algoritmo-de-bellman-ford-um.html
By CCS code by CCS
*/ */
const large = 999999 // almost inifinity const large = 999999 // almost inifinity
@ -159,5 +159,3 @@ fn main() {
} }
println('\n BYE -- OK') println('\n BYE -- OK')
} }
//=================================================

View File

@ -237,5 +237,3 @@ fn main() {
println('\n BYE -- OK') println('\n BYE -- OK')
} }
//********************************************************************

View File

@ -8,8 +8,9 @@ by CCS
PS: all the pre-requisites of Dijkstra are considered PS: all the pre-requisites of Dijkstra are considered
$ v run file_name.v $ v run file_name.v
Creating a executable Creating a executable
$ v run file_name.v -o an_executable.EXE $ v -o an_executable.EXE run file_name.v
$ ./an_executable.EXE $ ./an_executable.EXE
Code based from : Data Structures and Algorithms Made Easy: Data Structures and Algorithmic Puzzles, Fifth Edition (English Edition) Code based from : Data Structures and Algorithms Made Easy: Data Structures and Algorithmic Puzzles, Fifth Edition (English Edition)
@ -45,9 +46,7 @@ fn push_pq<T>(mut prior_queue []T, data int, priority int) {
temp << prior_queue[i] temp << prior_queue[i]
i++ i++
} }
prior_queue = temp.clone() prior_queue = temp.clone() // I am not sure if it the right way
// I am not sure if it the right way
// IS IT THE RIGHT WAY?
} }
// Change the priority of a value/node ... exist a value, change its priority // Change the priority of a value/node ... exist a value, change its priority
@ -193,9 +192,6 @@ fn main() {
| / \ | | / \ |
(3)-------(4) (3)-------(4)
9 9
*/
/*
Let us create following weighted graph Let us create following weighted graph
From https://www.geeksforgeeks.org/kruskals-minimum-spanning-tree-algorithm-greedy-algo-2/?ref=lbp From https://www.geeksforgeeks.org/kruskals-minimum-spanning-tree-algorithm-greedy-algo-2/?ref=lbp
10 10
@ -226,5 +222,3 @@ fn main() {
} }
println('\n BYE -- OK') println('\n BYE -- OK')
} }
//********************************************************************