-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/main'
- Loading branch information
Showing
14 changed files
with
800 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
--- | ||
name: Bug report | ||
about: Create a report to help us improve | ||
title: '' | ||
labels: '' | ||
assignees: '' | ||
|
||
--- | ||
|
||
**Describe the bug** | ||
A clear and concise description of what the bug is. | ||
|
||
**To Reproduce** | ||
Steps to reproduce the behavior: | ||
1. Go to '...' | ||
2. Click on '....' | ||
3. Scroll down to '....' | ||
4. See error | ||
|
||
**Expected behavior** | ||
A clear and concise description of what you expected to happen. | ||
|
||
**Screenshots** | ||
If applicable, add screenshots to help explain your problem. | ||
|
||
**Desktop (please complete the following information):** | ||
- OS: [e.g. iOS] | ||
- Browser [e.g. chrome, safari] | ||
- Version [e.g. 22] | ||
|
||
**Smartphone (please complete the following information):** | ||
- Device: [e.g. iPhone6] | ||
- OS: [e.g. iOS8.1] | ||
- Browser [e.g. stock browser, safari] | ||
- Version [e.g. 22] | ||
|
||
**Additional context** | ||
Add any other context about the problem here. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
--- | ||
name: Custom issue template | ||
about: Describe this issue template's purpose here. | ||
title: '' | ||
labels: '' | ||
assignees: '' | ||
|
||
--- | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
--- | ||
name: Feature request | ||
about: Suggest an idea for this project | ||
title: '' | ||
labels: '' | ||
assignees: '' | ||
|
||
--- | ||
|
||
**Is your feature request related to a problem? Please describe.** | ||
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] | ||
|
||
**Describe the solution you'd like** | ||
A clear and concise description of what you want to happen. | ||
|
||
**Describe alternatives you've considered** | ||
A clear and concise description of any alternative solutions or features you've considered. | ||
|
||
**Additional context** | ||
Add any other context or screenshots about the feature request here. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
# AStarSearch<T> Class | ||
|
||
**A* Search algorithm implementation for finding the shortest path in a weighted graph.** | ||
|
||
## AStarSearch<T> Class Members | ||
|
||
```csharp | ||
SearchAStar( | ||
Dictionary<T, List<(T, int)>> graph, | ||
T start, | ||
T goal, | ||
Func<T, T, int> heuristic) | ||
``` | ||
|
||
Performs A* search on a weighted graph to find the shortest path from the start to the goal. | ||
|
||
## Parameters | ||
|
||
- `graph` (Type: `Dictionary<T, List<(T, int)>>`): The weighted graph represented as a dictionary. | ||
- `start` (Type: `T`): The starting node. | ||
- `goal` (Type: `T`): The goal node. | ||
- `heuristic` (Type: `Func<T, T, int>`): Heuristic function estimating the cost from a node to the goal. | ||
|
||
## Returns | ||
|
||
- Type: `List<T>` | ||
- Description: The shortest path from the start to the goal. | ||
|
||
## Example | ||
|
||
```csharp | ||
using NetPlus.Algorithms.Search; | ||
|
||
// Example weighted graph represented as a dictionary | ||
var weightedGraph = new Dictionary<int, List<(int, int)>> | ||
{ | ||
{ 0, new List<(int, int)> { (1, 5), (2, 3) } }, | ||
{ 1, new List<(int, int)> { (3, 7) } }, | ||
{ 2, new List<(int, int)> { (4, 2) } }, | ||
{ 3, new List<(int, int)> { (5, 1) } }, | ||
{ 4, new List<(int, int)> { (5, 5) } }, | ||
{ 5, new List<(int, int)> { } } | ||
}; | ||
|
||
// Heuristic function (Euclidean distance in this case) | ||
Func<int, int, int> euclideanHeuristic = (node, goal) => | ||
{ | ||
// Implement your heuristic function here | ||
return Math.Abs(node - goal); | ||
}; | ||
|
||
// Performing A* search | ||
var shortestPath = AStarSearch<int>.SearchAStar(weightedGraph, 0, 5, euclideanHeuristic); | ||
|
||
// Displaying the shortest path | ||
Console.WriteLine(string.Join(" -> ", shortestPath)); | ||
``` | ||
|
||
## Usage | ||
|
||
To use the AStarSearch<T> class, simply call the `SearchAStar` method with the appropriate parameters. | ||
|
||
```csharp | ||
// Example usage | ||
var shortestPath = AStarSearch<int>.SearchAStar(weightedGraph, startNode, goalNode, heuristicFunction); | ||
``` | ||
|
||
## Remarks | ||
|
||
The `AStarSearch<T>` class uses the A* Search algorithm to find the shortest path in a weighted graph. It requires a heuristic function to estimate the cost from a node to the goal. | ||
|
||
```csharp | ||
// Example of a custom heuristic function | ||
Func<int, int, int> customHeuristic = (node, goal) => | ||
{ | ||
// Implement your custom heuristic function here | ||
return Math.Abs(node - goal) * 2; | ||
}; | ||
|
||
// Performing A* search with a custom heuristic function | ||
var customShortestPath = AStarSearch<int>.SearchAStar(weightedGraph, 0, 5, customHeuristic); | ||
``` | ||
|
||
In the above example, a custom heuristic function is used to perform A* search with a different estimation of the cost from a node to the goal. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
# BinarySearch Class | ||
|
||
**A static class containing the implementation of Binary Search algorithm.** | ||
|
||
## BinarySearch Class Members | ||
|
||
```csharp | ||
SearchBinary<T>(this T[] array, T value) where T : IComparable<T> | ||
``` | ||
|
||
Performs binary search on a sorted array to find the index of a specific value. | ||
|
||
## Parameters | ||
|
||
- `array` (Type: `T[]`): The sorted array to search. | ||
- `value` (Type: `T`): The value to search for. | ||
|
||
## Returns | ||
|
||
- Type: `int` | ||
- Description: The index of the value in the array, or -1 if not found. | ||
|
||
## Example | ||
|
||
```csharp | ||
using NetPlus.Algorithms.Search; | ||
|
||
// Example sorted array | ||
var sortedArray = new int[] { 1, 2, 3, 4, 5, 6, 7, 8, 9 }; | ||
|
||
// Using BinarySearch to find the index of a value | ||
var index = sortedArray.SearchBinary(5); | ||
|
||
// Displaying the result | ||
Console.WriteLine("Index of 5: " + index); | ||
``` | ||
|
||
## Usage | ||
|
||
To use the BinarySearch class, call the `SearchBinary` method on your sorted array. | ||
|
||
```csharp | ||
// Example usage | ||
var index = sortedArray.SearchBinary(targetValue); | ||
``` | ||
|
||
## Remarks | ||
|
||
The BinarySearch class provides a static method for performing binary search on a sorted array to find the index of a specific value. It utilizes a recursive approach to divide the search range until the value is found or the range becomes empty. | ||
|
||
```csharp | ||
// Example of usage with a custom array type | ||
var customArray = new CustomType[] { /* initialize your custom array */ }; | ||
var customIndex = customArray.SearchBinary(customValue); | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
# BubbleSort Class | ||
|
||
Provides methods for performing Bubble Sort on arrays. | ||
|
||
## BubbleSort Class Members | ||
|
||
```csharp | ||
ExecuteBubbleSort<T>(this T[] array) where T : IComparable<T> | ||
``` | ||
|
||
Sorts an array using the Bubble Sort algorithm in ascending order. | ||
|
||
## Parameters | ||
|
||
- `array` (Type: `T[]`): The array to be sorted. | ||
|
||
## Returns | ||
|
||
- Type: `T[]` | ||
- Description: The sorted array in ascending order. | ||
|
||
## Example | ||
|
||
```csharp | ||
using NetPlus.Algorithms.Sorting; | ||
|
||
// Example array | ||
int[] myArray = { 4, 2, 7, 1, 9 }; | ||
|
||
// Sorting the array using Bubble Sort | ||
var sortedArray = myArray.ExecuteBubbleSort(); | ||
|
||
// Displaying the sorted array | ||
Console.WriteLine(string.Join(", ", sortedArray)); | ||
``` | ||
|
||
## Usage | ||
|
||
To use the BubbleSort class, simply call the ExecuteBubbleSort method on your array. | ||
|
||
```csharp | ||
int[] myArray = { 4, 2, 7, 1, 9 }; | ||
var sortedArray = BubbleSort.ExecuteBubbleSort(myArray); | ||
``` | ||
|
||
## Remarks | ||
|
||
The BubbleSort class uses the Bubble Sort algorithm to sort arrays in ascending order. | ||
It is an in-place sorting algorithm. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
# HeapSort Class | ||
|
||
**Provides methods for performing Heap Sort on arrays.** | ||
|
||
## HeapSort Class Members | ||
|
||
```csharp | ||
Sort<T>(this T[] array) where T : IComparable<T> | ||
``` | ||
|
||
Sorts an array using the Heap Sort algorithm. | ||
|
||
## Parameters | ||
|
||
- `array` (Type: `T[]`): The array to be sorted. | ||
|
||
## Returns | ||
|
||
- Type: `T[]` | ||
- Description: The sorted array. | ||
|
||
## Example | ||
|
||
```csharp | ||
using NetPlus.Algorithms.Sorting; | ||
|
||
// Example array | ||
int[] myArray = { 4, 2, 7, 1, 9 }; | ||
|
||
// Sorting the array using Heap Sort | ||
var sortedArray = myArray.ExecuteHeapSort(); | ||
|
||
// Displaying the sorted array | ||
Console.WriteLine(string.Join(", ", sortedArray)); | ||
``` | ||
|
||
## Usage | ||
|
||
To use the HeapSort class, simply call the `ExecuteHeapSort` method on your array. | ||
|
||
```csharp | ||
int[] myArray = { 4, 2, 7, 1, 9 }; | ||
var sortedArray = HeapSort.ExecuteHeapSort(myArray); | ||
``` | ||
|
||
## Remarks | ||
|
||
The `HeapSort` class uses the Heap Sort algorithm to sort arrays. It is an in-place sorting algorithm. |
Oops, something went wrong.