From 620569c4ea9daa0bda183987f657edf311b3c8db Mon Sep 17 00:00:00 2001 From: Alexandre Tolstenko Date: Fri, 5 Apr 2024 12:06:57 -0400 Subject: [PATCH] fix: mst typings --- docs/algorithms/12-mst/README.md | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/docs/algorithms/12-mst/README.md b/docs/algorithms/12-mst/README.md index 48142f75..67462c6c 100644 --- a/docs/algorithms/12-mst/README.md +++ b/docs/algorithms/12-mst/README.md @@ -571,8 +571,14 @@ There are many implementations for the Minimum Spanning Tree algorithm, here goe #include using namespace std; +// rename optional> to edge +typedef optional> Edge; + +// rename unordered_map> to Graph +typedef unordered_map> Graph; + // source, destination, weight -optional> findMinEdge(const unordered_map>& graph, const unordered_map>& mst){ +Edge findMinEdge(const Graph& graph, const Graph& mst){ if(graph.empty()) return nullopt; if(mst.empty()){ @@ -622,8 +628,8 @@ optional> findMinEdge(const unordered_map weight -int MSP(unordered_map> graph){ - unordered_map> mst; +int MSP(const Graph& graph){ + Graph mst; int accumulatedWeight = 0; while(true){ auto edge = findMinEdge(graph, mst);