mirror of
https://github.com/krahets/hello-algo.git
synced 2026-08-30 20:07:14 +00:00
Add ru version (#1865)
* Add Russian docs site baseline * Add Russian localized codebase * Polish Russian code wording * Update ru code translation. * Update code translation and chapter covers. * Fix pythontutor extraction. * Add README and landing page. * placeholder of profiles * Use figures of English version * Remove chapter paperbook
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
// File: graph_bfs_test.go
|
||||
// Created Time: 2023-02-18
|
||||
// Author: Reanon (793584285@qq.com)
|
||||
|
||||
package chapter_graph
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"testing"
|
||||
|
||||
. "github.com/krahets/hello-algo/pkg"
|
||||
)
|
||||
|
||||
func TestGraphBFS(t *testing.T) {
|
||||
/* Инициализация неориентированного графа */
|
||||
vets := ValsToVets([]int{0, 1, 2, 3, 4, 5, 6, 7, 8, 9})
|
||||
edges := [][]Vertex{
|
||||
{vets[0], vets[1]}, {vets[0], vets[3]}, {vets[1], vets[2]}, {vets[1], vets[4]},
|
||||
{vets[2], vets[5]}, {vets[3], vets[4]}, {vets[3], vets[6]}, {vets[4], vets[5]},
|
||||
{vets[4], vets[7]}, {vets[5], vets[8]}, {vets[6], vets[7]}, {vets[7], vets[8]}}
|
||||
graph := newGraphAdjList(edges)
|
||||
fmt.Println("Граф после инициализации:")
|
||||
graph.print()
|
||||
|
||||
/* Обход в ширину */
|
||||
res := graphBFS(graph, vets[0])
|
||||
fmt.Println("Последовательность вершин при обходе в ширину (BFS):")
|
||||
PrintSlice(VetsToVals(res))
|
||||
}
|
||||
Reference in New Issue
Block a user