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

vfmt: change all '$expr' to '${expr}' (#16428)

This commit is contained in:
yuyi
2022-11-15 21:53:13 +08:00
committed by GitHub
parent 56239b4a23
commit 017ace6ea7
859 changed files with 7156 additions and 7135 deletions

View File

@ -45,7 +45,7 @@ fn print_sol(dist []int) {
n_vertex := dist.len
print('\n Vertex Distance from Source')
for i in 0 .. n_vertex {
print('\n $i --> ${dist[i]}')
print('\n ${i} --> ${dist[i]}')
}
}
@ -154,7 +154,7 @@ fn main() {
graph = g_value.clone() // graphs_sample[g].clone() // choice your SAMPLE
// allways starting by node 0
start_node := 0
println('\n\n Graph ${index + 1} using Bellman-Ford algorithm (source node: $start_node)')
println('\n\n Graph ${index + 1} using Bellman-Ford algorithm (source node: ${start_node})')
bellman_ford(graph, start_node)
}
println('\n BYE -- OK')

View File

@ -7,9 +7,9 @@ fn main() {
'E': ['B', 'F']
'F': ['C', 'E']
}
println('Graph: $graph')
println('Graph: ${graph}')
path := breadth_first_search_path(graph, 'A', 'F')
println('The shortest path from node A to node F is: $path')
println('The shortest path from node A to node F is: ${path}')
assert path == ['A', 'C', 'F']
}

View File

@ -10,9 +10,9 @@ fn main() {
'E': ['B', 'F']
'F': ['C', 'E']
}
println('Graph: $graph')
println('Graph: ${graph}')
path := breadth_first_search_path(graph, 'A', 'F')
println('\n The shortest path from node A to node F is: $path.reverse()')
println('\n The shortest path from node A to node F is: ${path.reverse()}')
}
// Breadth-First Search (BFS) allows you to find the shortest distance between two nodes in the graph.
@ -35,7 +35,7 @@ fn breadth_first_search_path(graph map[string][]string, start string, target str
return path
}
// Expansion of node removed from queue
print('\n Expansion of node $node (true/false): ${graph[node]}')
print('\n Expansion of node ${node} (true/false): ${graph[node]}')
// take all nodes from the node
for vertex in graph[node] { // println("\n ...${vertex}")
// not explored yet
@ -43,7 +43,7 @@ fn breadth_first_search_path(graph map[string][]string, start string, target str
queue << vertex
}
}
print('\n QUEUE: $queue (only not visited) \n Visited: $visited')
print('\n QUEUE: ${queue} (only not visited) \n Visited: ${visited}')
}
}
path = ['Path not found, problem in the Graph, start or end nodes! ']
@ -70,7 +70,7 @@ fn visited_init(a_graph map[string][]string) map[string]bool {
// Based in the current node that is final, search for its parent, already visited, up to the root or start node
fn build_path_reverse(graph map[string][]string, start string, final string, visited map[string]bool) []string {
print('\n\n Nodes visited (true) or no (false): $visited')
print('\n\n Nodes visited (true) or no (false): ${visited}')
array_of_nodes := graph.keys()
mut current := final
mut path := []string{}

View File

@ -25,9 +25,9 @@ fn main() {
}
// println('Graph: $graph')
path_01 := depth_first_search_path(graph_01, 'A', 'F')
println('\n Graph_01: a first path from node A to node F is: $path_01.reverse()')
println('\n Graph_01: a first path from node A to node F is: ${path_01.reverse()}')
path_02 := depth_first_search_path(graph_02, 'A', 'H')
println('\n Graph_02: a first path from node A to node F is: $path_02.reverse()')
println('\n Graph_02: a first path from node A to node F is: ${path_02.reverse()}')
}
// Depth-First Search (BFS) allows you to find a path between two nodes in the graph.
@ -51,7 +51,7 @@ fn depth_first_search_path(graph map[string][]string, start string, target strin
return path
}
// Exploring of node removed from stack and add its relatives
print('\n Exploring of node $node (true/false): ${graph[node]}')
print('\n Exploring of node ${node} (true/false): ${graph[node]}')
// graph[node].reverse() take a classical choice for DFS
// at most os left in this case.
// use vertex in graph[node] the choice is right
@ -64,7 +64,7 @@ fn depth_first_search_path(graph map[string][]string, start string, target strin
stack << vertex
}
}
print('\n Stack: $stack (only not visited) \n Visited: $visited')
print('\n Stack: ${stack} (only not visited) \n Visited: ${visited}')
}
}
path = ['Path not found, problem in the Graph, start or end nodes! ']
@ -84,7 +84,7 @@ fn visited_init(a_graph map[string][]string) map[string]bool {
// Based in the current node that is final, search for his parent, that is already visited, up to the root or start node
fn build_path_reverse(graph map[string][]string, start string, final string, visited map[string]bool) []string {
print('\n\n Nodes visited (true) or no (false): $visited')
print('\n\n Nodes visited (true) or no (false): ${visited}')
array_of_nodes := graph.keys()
mut current := final
mut path := []string{}

View File

@ -69,7 +69,7 @@ fn updating_priority<T>(mut prior_queue []T, search_data int, new_priority int)
i++
// all the list was examined
if i >= lenght_pq {
print('\n This data $search_data does exist ... PRIORITY QUEUE problem\n')
print('\n This data ${search_data} does exist ... PRIORITY QUEUE problem\n')
exit(1) // panic(s string)
}
} // end for
@ -98,7 +98,7 @@ fn all_adjacents<T>(g [][]T, v int) []int {
fn print_solution<T>(dist []T) {
print('Vertex \tDistance from Source')
for node in 0 .. (dist.len) {
print('\n $node ==> \t ${dist[node]}')
print('\n ${node} ==> \t ${dist[node]}')
}
}
@ -107,7 +107,7 @@ fn print_paths_dist<T>(path []T, dist []T) {
print('\n Read the nodes from right to left (a path): \n')
for node in 1 .. (path.len) {
print('\n $node ')
print('\n ${node} ')
mut i := node
for path[i] != -1 {
print(' <= ${path[i]} ')
@ -231,7 +231,7 @@ fn main() {
graph = g_value.clone() // graphs_sample[g].clone() // choice your SAMPLE
// allways starting by node 0
start_node := 0
println('\n\n Graph ${index + 1} using Dijkstra algorithm (source node: $start_node)')
println('\n\n Graph ${index + 1} using Dijkstra algorithm (source node: ${start_node})')
dijkstra(graph, start_node)
}

View File

@ -100,13 +100,13 @@ fn print_solution(path []int, g [][]int) {
mut sum := 0
for node in 0 .. (path.len) {
if path[node] == -1 {
print('\n $node <== reference or start node')
print('\n ${node} <== reference or start node')
} else {
print('\n $node <--> ${path[node]} \t${g[node][path[node]]}')
print('\n ${node} <--> ${path[node]} \t${g[node][path[node]]}')
sum += g[node][path[node]]
}
}
print('\n Minimum Cost Spanning Tree: $sum\n\n')
print('\n Minimum Cost Spanning Tree: ${sum}\n\n')
}
// check structure from: https://www.geeksforgeeks.org/dijkstras-shortest-path-algorithm-greedy-algo-7/

View File

@ -9,7 +9,7 @@
// THE DFS RECURSIVE .... classical searchig for leaves nodes
// the arguments are used in the function to avoid global variables....
fn dfs_recursive(u string, mut visited map[string]bool, graph map[string][]string, mut top_sorting []string) {
print(' Visiting: $u -> ')
print(' Visiting: ${u} -> ')
visited[u] = true
for v in graph[u] {
@ -67,7 +67,7 @@ fn main() {
mut graph := map[string][]string{} // the graph: adjacency matrix
for index, g_value in [graph_01, graph_02, graph_03] {
println('Topological sorting for the graph $index using a DFS recursive')
println('Topological sorting for the graph ${index} using a DFS recursive')
graph = g_value.clone() // graphs_sample[g].clone() // choice your SAMPLE
// mut n_nodes := graph.len
@ -82,7 +82,7 @@ fn main() {
}
}
print('\n A topological sorting of graph $index : ')
print('\n A topological sorting of graph ${index} : ')
// println(g_value)
println(top_sorting.reverse())
println('')

View File

@ -25,7 +25,7 @@ fn topog_sort_greedy(graph map[string][]string) []string {
Maybe it seems the Kahn's algorithm
*/
mut v_degree := in_degree(graph) // return: map [string] int
print('V Degree $v_degree')
print('V Degree ${v_degree}')
mut small_degree := min_degree(v_degree)
mut new_graph := remove_node_from_graph(small_degree, graph)
top_order << small_degree
@ -33,7 +33,7 @@ fn topog_sort_greedy(graph map[string][]string) []string {
for (count < n_nodes) {
v_degree = in_degree(new_graph) // return: map [string] int
print('\nV Degree $v_degree')
print('\nV Degree ${v_degree}')
small_degree = min_degree(v_degree)
new_graph = remove_node_from_graph(small_degree, new_graph)