diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 00000000..800e7f1f Binary files /dev/null and b/.DS_Store differ diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 00000000..70e34ecb --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "C_Cpp.errorSquiggles": "disabled" +} \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt index 3d04ce27..643100f0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -16,4 +16,18 @@ message( ${CMAKE_CXX_FLAGS} ) foreach( appsourcefile ${APP_SOURCES} ) get_filename_component( demo_name ${appsourcefile} NAME_WE ) add_executable( ${demo_name} ${appsourcefile} ) -endforeach( appsourcefile ${APP_SOURCES} ) \ No newline at end of file +endforeach( appsourcefile ${APP_SOURCES} ) + + +/** + + +Assignment Requirements for the Algorithms project. +1. I need to make something that shows a nice DEMO. Demonstration. -> The way I can do this is by doing the following: + 1. I can start. + 2. I can try to figure out how to properly do dependency management (*Decompress a Directed Acyclic Graph -> DAG RFC. With Autocomplete.) + + +Dependency Management is likely the future. The reason; (We - I, etc.) say this is because proper surveys' can make OR break a companies routine etc. There's a lot of beauty to be able to be seen within this System. +Systems assignment for COE 379L (P.I. -> Marcus.) +**/ \ No newline at end of file diff --git a/include/bellman_ford.h b/include/bellman_ford.h index 40771ae4..acc485a8 100644 --- a/include/bellman_ford.h +++ b/include/bellman_ford.h @@ -1,9 +1,9 @@ /******************************************************************************* * DANIEL'S ALGORITHM IMPLEMENTAIONS * - * /\ | _ _ ._ o _|_ |_ ._ _ _ - * /--\ | (_| (_) | | |_ | | | | | _> - * _| + * /\ | _ _ ._ o _|_ |_ ._ _ _ + * /--\ | (_| (_) | | |_ | | | | | _> + * _| * * BELLMAN-FORD ALGORITHM * @@ -39,9 +39,9 @@ * v := uv.destination * if u.distance + uv.weight < v.distance: * error "Graph contains a negative-weight cycle" - * + * * http://en.wikipedia.org/wiki/Bellman%E2%80%93Ford_algorithm - * + * ******************************************************************************/ #ifndef ALGO_BELLMAN_FORD_H__ @@ -59,73 +59,85 @@ // define UNDEFINED previous vertex. #define UNDEFINED -1 -namespace alg { - class BellmanFord { - private: - HashTable dist; // hash table for distance. - bool has_neg_cycle; // negative weighted cycle mark. - const Graph & g; - public: - BellmanFord(const Graph & graph): - dist(graph.vertex_count()),g(graph) { } - - /** - * Bellman-Ford algorithm - */ - HashTable * run(uint32_t source) { - // hash table for previous vertex - HashTable * previous = new HashTable(g.vertex_count()); - // source vertex - dist[source] = 0; - - // other vertices - Graph::Adjacent * a; - list_for_each_entry(a, &g.list(), a_node){ - if (source != a->v.id) { - dist[a->v.id] = INT_MAX; - } - (*previous)[a->v.id] = UNDEFINED; +namespace alg +{ + class BellmanFord + { + private: + HashTable dist; // hash table for distance. + bool has_neg_cycle; // negative weighted cycle mark. + const Graph &g; + + public: + BellmanFord(const Graph &graph) : dist(graph.vertex_count()), g(graph) {} + + /** + * Bellman-Ford algorithm + */ + HashTable *run(uint32_t source) + { + // hash table for previous vertex + HashTable *previous = new HashTable(g.vertex_count()); + // source vertex + dist[source] = 0; + + // other vertices + Graph::Adjacent *a; + list_for_each_entry(a, &g.list(), a_node) + { + if (source != a->v.id) + { + dist[a->v.id] = INT_MAX; } + (*previous)[a->v.id] = UNDEFINED; + } - has_neg_cycle = false; // negative cycle mark set to 'false'. + has_neg_cycle = false; // negative cycle mark set to 'false'. - // relax edges repeatedly - Graph::Adjacent * u; - for (uint32_t i=0;iv.id]; + // relax edges repeatedly + Graph::Adjacent *u; + for (uint32_t i = 0; i < g.vertex_count() - 1; i++) + { // loop |V| -1 times + list_for_each_entry(u, &g.list(), a_node) + { // for each eage(u,v) in edges + int32_t dist_u = dist[u->v.id]; - Graph::Vertex * v; - list_for_each_entry(v, &u->v_head, v_node){ - int32_t dist_v = dist[v->id]; + Graph::Vertex *v; + list_for_each_entry(v, &u->v_head, v_node) + { + int32_t dist_v = dist[v->id]; - if (dist_u + v->weight < dist_v) { - dist[v->id] = dist_u + v->weight; - (*previous)[v->id] = u->v.id; - } + if (dist_u + v->weight < dist_v) + { + dist[v->id] = dist_u + v->weight; + (*previous)[v->id] = u->v.id; } } } + } - // check for negative-weight cycles - list_for_each_entry(u, &g.list(), a_node) { - int32_t dist_u = dist[u->v.id]; + // check for negative-weight cycles + list_for_each_entry(u, &g.list(), a_node) + { + int32_t dist_u = dist[u->v.id]; - Graph::Vertex * v; - list_for_each_entry(v, &u->v_head, v_node){ - int32_t dist_v = dist[v->id]; + Graph::Vertex *v; + list_for_each_entry(v, &u->v_head, v_node) + { + int32_t dist_v = dist[v->id]; - if (dist_u + v->weight < dist_v) { - has_neg_cycle = true; // graph contains a negative-weight cycle - return previous; - } - } + if (dist_u + v->weight < dist_v) + { + has_neg_cycle = true; // graph contains a negative-weight cycle + return previous; + } } - - return previous; } - inline bool has_negative_cycle() { return has_neg_cycle; } + return previous; + } + + inline bool has_negative_cycle() { return has_neg_cycle; } }; } diff --git a/include/heap.h b/include/heap.h index d793cdab..bf8cf983 100644 --- a/include/heap.h +++ b/include/heap.h @@ -99,7 +99,8 @@ namespace alg { * clear the heap */ inline void clear() { m_size = 0; } - + + // @feat? bin search bool contains(const T & data) { for(int i=0;i The way I can do this is by doing the following: + 1. I can start. + 2. I can try to figure out how to properly do dependency management (*Decompress a Directed Acyclic Graph -> DAG RFC. With Autocomplete.) + +Today, I will be making the world's first. (Probably not first) + -> Realtime Dependency manamgment/cross-platform/Nop(Not an Operation.) +*/ + +#ifndef _SIDDHANT_SINGH___ +#include +#include + +namespace alg { + /* + M.J. plays in the background. (this is a Micheal Jackson Song.) + */ + template + class V { + private: + public: + + }; + /*T: 00:30:08. pre-Bound2.*/ + /*Look At m_hash e data uhash_init S T rand T M S I rand E T namespace I walking I S we wheather if I A qq aaaa A aaaaa aaaaa A -> don't blink. +}; + +#endif //-> although I don't know magic. I can learn it. (Santa's Little Helper.) \ No newline at end of file diff --git a/msvc/me_v_solver.h b/msvc/me_v_solver.h new file mode 100644 index 00000000..c6cc59ed --- /dev/null +++ b/msvc/me_v_solver.h @@ -0,0 +1,19 @@ +/* +Dependency Management is likely the future. +| + +\ + \ + + + | + + v + + + The reason; (We - I, etc.) say this is because proper surveys' can make OR break a companies routine etc. There's a lot of beauty to be able to be seen within this System. +Systems assignment for COE 379L (P.I. -> Marcus.) + + +*/ + diff --git a/src/siddhant-singh_demo.cpp b/src/siddhant-singh_demo.cpp new file mode 100644 index 00000000..e69de29b