Skip to content

Commit

Permalink
Prepare release 0.21.0
Browse files Browse the repository at this point in the history
  • Loading branch information
dominikbraun committed May 18, 2023
1 parent e486dc2 commit 4cbb2a1
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,14 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project
adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [0.21.0] - 2023-05-18

### Added
* Added the `BFSWithDepth` function for performing a BFS with depth information.

### Fixed
* Fixed false positives of `ErrVertexHasEdges` when removing a vertex.

## [0.20.0] - 2023-05-01

**Release post: [graph Version 0.20 Is Out](https://dominikbraun.io/blog/graph-version-0.20-is-out/)**
Expand Down
11 changes: 11 additions & 0 deletions traversal.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,17 @@ func BFS[K comparable, T any](g Graph[K, T], start K, visit func(K) bool) error
return BFSWithDepth(g, start, ignoreDepth)
}

// BFSWithDepth works just as BFS and performs a breadth-first search on the graph, but its
// visit function is passed the current depth level as a second argument. Consequently, the
// current depth and be used for deciding whether or not to proceed past a certain depth.
//
// _ = graph.BFSWithDepth(g, 1, func(value int, depth int) bool {
// fmt.Println(value)
// return depth > 3
// })
//
// With the visit function from the example, the BFS traversal will stop once a depth greater
// than 3 is reached.
func BFSWithDepth[K comparable, T any](g Graph[K, T], start K, visit func(K, int) bool) error {
adjacencyMap, err := g.AdjacencyMap()
if err != nil {
Expand Down

0 comments on commit 4cbb2a1

Please sign in to comment.