Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/eliahkagan/graph
C# local functions example: graph DFS
https://github.com/eliahkagan/graph
Last synced: about 24 hours ago
JSON representation
C# local functions example: graph DFS
- Host: GitHub
- URL: https://github.com/eliahkagan/graph
- Owner: EliahKagan
- License: 0bsd
- Created: 2021-05-01T21:10:26.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2023-12-15T09:04:58.000Z (11 months ago)
- Last Synced: 2024-04-16T01:55:47.538Z (7 months ago)
- Language: C#
- Size: 40 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Graph - C# local functions example: graph DFS
This is an example of local functions in C#, showing a use in implementing
depth-first traversal of a directed graph.## Contents
`GraphBasic/Program.cs` (or `graph-basic.linq`) is the clearer example.
`Graph/Program.cs` (or `graph.linq`) shows it with a `Graph` class.
## Notes
If one implements `VerticesReachableFrom` as part of one’s `Graph` class,
one could still benefit from using a local function to capture the visitation
list and results sink. But I figured the example was more compelling this way.(Also, there is a design argument for implementing `VerticesReachableFrom` in
such a way that a bug in it cannot cause any invariant of `Graph` to be
violated.)## License
The contents of this repository were written in 2020 by Eliah Kagan (with minor
updates in 2021 and 2023). They are offered under
[0BSD](https://spdx.org/licenses/0BSD.html), a [“public-domain
equivalent”](https://en.wikipedia.org/wiki/Public-domain-equivalent_license)
license. See [**`LICENSE`**](LICENSE).## See also
`GraphBasic/Program.cs` and `Graph/Program.cs` may also be viewed in the gist
[C# local functions
example](https://gist.github.com/EliahKagan/ca7277a9a20e5631af7ee6a222ecd443),
where they are named `GraphBasic.cs` and `Graph.cs`, respectively.