https://github.com/shahrzadabedi/currencyconverter
A currency converter that can be configured with different exchange rates and converts the currency symbols using a BFS algorithm
https://github.com/shahrzadabedi/currencyconverter
algorithms bfs-algorithm
Last synced: 4 months ago
JSON representation
A currency converter that can be configured with different exchange rates and converts the currency symbols using a BFS algorithm
- Host: GitHub
- URL: https://github.com/shahrzadabedi/currencyconverter
- Owner: shahrzadabedi
- Created: 2024-05-09T19:55:39.000Z (about 1 year ago)
- Default Branch: master
- Last Pushed: 2024-05-12T14:38:12.000Z (about 1 year ago)
- Last Synced: 2025-01-02T14:22:58.932Z (6 months ago)
- Topics: algorithms, bfs-algorithm
- Language: C#
- Homepage:
- Size: 36.1 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
In the Currency Converter project, we have an interface that lets us configure, convert and clear exchange rates:
```
public interface ICurrencyConverter
{
void ClearConfiguration();void UpdateConfiguration(IEnumerable> conversionRates);
double Convert(string fromCurrency, string toCurrency, double amount);
}
```I used BFS algorithm to traverse the graph. To represent the graph, I make an adjacency list for each vertex using BuildAdjacencyLists() method in
BfsShortestPathProvider class that implements IShortestPathProvider interface.* UpdateConfiguration method:
It adjusts and sets up adjacency lists for all vertices and also makes a vertices list for later check.
The Convert method first traverses the whole graph using BFS algorithm. Meanwhile it builds a dictionary that
keeps (the parent of each vertex, the cost to reach the parent, the cost to reach the current vertex).
After the whole graph is traversed it then uses this dictionary and starts from destination verex to finally reach the source vertex.* ClearConfiguration method:
This method clears all adjustments.* UpdateConfiguration method:
This method sets up the adjacency lists and the list of vertices for later traversal.