Code Monkey home page Code Monkey logo

csrt-ntua / algoplus Goto Github PK

View Code? Open in Web Editor NEW
149.0 5.0 20.0 10.85 MB

AlgoPlus is a C++17 library for complex data structures and algorithms

Home Page: https://csrt-ntua.github.io/AlgoPlus

License: Apache License 2.0

C++ 98.60% C 0.54% CMake 0.56% Shell 0.02% Python 0.28%
algorithms algorithms-and-data-structures computer-science cpp graph-algorithms mathematics tree tree-algorithms algorithms-interview-questions implementation-from-scratch implementation-of-algorithms implementation-of-data-structures interview-preparation interview-questions linked-list machine-learning machine-learning-algorithms machinelearning image-processing data-structures-and-algorithms

algoplus's Introduction

Algoplus{BETA Version}

AlgoPlus is a C++ library that includes ready-to-use complex data structures and algorithms.

Algoplus

Gitpod Ready-to-Code CodeQL CI codecov GitHub repo size

See the full documentation here

Join our Discord

Example:

#include <machine_learning/clustering/kmeans/kmeans.h>

// AlgoPlus now has Machine Learning classes!
int main(){
    std::vector<std::vector<double> > data;
    int CLUSTERS;
    kmeans a(data, CLUSTERS);
    ...
    // returns the cluster centers and assignments of the kmeans clustering
    std::pair<std::vector<std::vector<double> >, std::map<std::vector<double>, int64_t> > ans = a.fit();
}

#include <machine_learning/image/edge_detection/sobel_operator.h>

// As well as image processing algorithms!
int main(){
  ...
  std::vector<std::vector<int32_t> > img(data);

  // Performs edge detection on image img
  std::vector<std::vector<int32_t> > resulted = Sobel(img);
  ...
}


#include <graph.h>

// And of course, every data structure that you need!
int main(){
  weighted_graph<int> g("undirected");
  g.add_edge(1, 4, 2);
  g.add_edge(4, 5, 6);
  g.add_edge(5, 2, 9);
  g.add_edge(2, 8, 10);

  // returns the shortest path from 1 to 2.
  std::cout << g.shortest_path(1, 2) << '\n';
  g.visualize() // You can visualize almost any of our implemented data structures!
}

You can see more examples or follow the Tutorials.

Classes

Graphs

Trees

Lists

Other

Machine Learning(NEW!)

How to run test cases

We have unit tests for every function of our implemented algorithms & data structures. It is very important to make sure that your code works before making any pull requests!

Linux/MacOS

mkdir build && cd build
cmake ..
make
cd tests
./runUnitTests

Windows

mkdir build
cmake -S . -B build -G Ninja
cmake --build build
cd build/tests
./runUnitTests

Our contributors

How to contribute

  1. Povide new implementations on our already implemented data structures & algorithms.

  2. Implement new classes / algorithms.

  3. Contribute to unit testing by writting unit tests for our classes and algorithms.

  4. Create and contribute to APIs for other languages(Check AlgoPy branch).

  5. Promote the repository on your local workshop/seminar and get a shout-out.

See more here.

For any information or questions, please contact Spiros at [email protected]

Star History

Star History Chart

algoplus's People

Contributors

arthiondaena avatar aveldan avatar gpanaritis avatar kronocode avatar minageus avatar r-goc avatar sahilverma0696 avatar seekerrook avatar shu-afk avatar spirosmaggioros avatar stasinosntaveas avatar xoulios avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

algoplus's Issues

enrichment of examples folder

Except machine_learning folter, the examples for the other classes and algorithms are not that many. You can either solve problems with what is implemented or just do whatever you think will be useful as a reference for the implementation.

Improve examples

Examples folder can be used to show some real use of the algorithms and classes we have implemented. You can add some problems and the solutions to them, or in general whatever you all think is useful for someone to see.

Rename __min in min_heap

Only a problem in Windows (compilation is fine on linux)

There already exists a macro named __min

In file included from .\min_heap.cc:2:
.\../../src/classes/heap/min_heap.h:59:11: error: macro "__min" requires 2 arguments, but only 1 given
   T __min() {

New ML Classes/Algorithms implementations

There is a new "machine_learning" folder in the src directory that needs to be filled with machine learning algorithms.

We started with clustering algorithms, but there has to be some regressors and classifiers as well(i.e. KNearestNeighbors classifier, regressor, etc.)

**General contributions**

Please be free to contribute whatever you think is useful. Don't only feel the need to contribute if there are issues open :)

documentation enrichment

  1. Check documentation and see if any functions for the already implemented classes are missing
  2. Please add classes that are missing from the documentation in the tutorials folder and make sure the codestyle is the same as the other .md files in this folder
  3. create a pull request to finally merge

:)

Visualize for skip list

Hey @spirosmaggioros I was trying to create a visualize for skip list. I saw it was missing it.
I had a little bit of success but I am not sure how do I make the edges for same key nodes in different level to be perfectly vertical.

Below is the result from my trying.
Screenshot from 2024-07-05 16-43-59

You see the 0 from all different levels should be ideally vertical.
This is the dot file for the above image

digraph list {
rankdir=LR;
node [shape=record;]
k0l2 [label="{<f0> 0 | <f1> } | <f2> "];
k12l2 [label="{<f0> 12 | <f1> } | <f2> "];
k0l2:f1 -> k12l2:f0;
k0l1 [label="{<f0> 0 | <f1> } | <f2> "];
k0l2:f2 -> k0l1:f0;
k6l1 [label="{<f0> 6 | <f1> } | <f2> "];
k0l1:f1 -> k6l1:f0;
k12l1 [label="{<f0> 12 | <f1> } | <f2> "];
k6l1:f1 -> k12l1:f0;
k12l2:f2 -> k12l1:f0;
k0l0 [label="{<f0> 0 | <f1> } | <f2> "];
k0l1:f2 -> k0l0:f0 [rankdir=TB];
k3l0 [label="{<f0> 3 | <f1> } | <f2> "];
k0l0:f1 -> k3l0:f0;
k6l0 [label="{<f0> 6 | <f1> } | <f2> "];
k3l0:f1 -> k6l0:f0;
k6l1:f2 -> k6l0:f0;
k7l0 [label="{<f0> 7 | <f1> } | <f2> "];
k6l0:f1 -> k7l0:f0;
k9l0 [label="{<f0> 9 | <f1> } | <f2> "];
k7l0:f1 -> k9l0:f0;
k12l0 [label="{<f0> 12 | <f1> } | <f2> "];
k9l0:f1 -> k12l0:f0;
k12l1:f2 -> k12l0:f0;
}

Here in the dot file I am naming the nodes as k<key>l<level> so k6l0 [label="{<f0> 6 | <f1> } | <f2> "]; means node with key 6 in 0th level.

I have tried adding something like [rankdir=TB] in front of relevant edges.
Also tried something like

subgraph cluster_0 {
        rankdir=TB;
        00:f2 -> 00:f0;
    }

But they don't work.
You have any idea how to make it happen help me. I am not very much familiar with the dot file structure.

better CMake integration

Each folder should have a CMakeLists txt and then integrate them to the main CMakeLists.txt in root dir.

Add algorithms to Mat1d<T, SIZE> class

I proposed a new class(more will come) that will be useful for linear algebra. In general i need new contributors to implement some algorithms that are used in advanced linear algebra. Feel free to implement whatever you feel will be useful.

Same namespace "visualization" in tree and list

When I try to include "algoplus.h" I get the following:

In file included from include/../classes/tree/avl_tree.h:6,
                 from include/algoplus.h:28,
                 from try.cc:2:
include/../classes/tree/../../visualization/tree_visual/tree_visualization.h:20:13: error: redefinition of ‘void visualization::visualize(std::string&, std::string)’
   20 | inline void visualize(std::string &__generate,
      |             ^~~~~~~~~
In file included from include/../classes/list/circular_linked_list.h:6,
                 from include/algoplus.h:22,
                 from try.cc:2:
include/../classes/list/../../visualization/list_visual/linked_list_visualization.h:20:13: note: ‘void visualization::visualize(std::string&, std::string)’ previously defined here
   20 | inline void visualize(std::string &__generate,

clang-tidy support is needed

We currently need a clang-tidy support to check codestyle and typical errors in the code. It is suggested by a lot of people, i have a problem with actually adding build + run of clang-tidy in a .yml file to run automatically for every push.

Check libraries in each class

Some files may contain libraries that are not needed, and some times in some OS's there are compilation errors if some libraries are not included (for example in macos with c++ -std=c++17 compilation #include <memory> is not needed for std::shared_ptr<T> but in Windows with g++ -std=c++17 there are compilation errors).

If you don't have a mac, please make sure everything works as it should, otherwise report that with an issue or solve it by adding/removing the needed library.

Implement new algorithms

Algorithms folder looks empty. There are plenty of algorithms to add and we are happy to see new contributors do that!
You can also add test cases and comments for the algorithms.

Fix "include/algoplus.h" (Redefinition of const)

When trying to include "algoplus.h" you get the following (many times for many different consts):

In file included from .\../include/../classes/tree/bst.h:5,
                 from .\../include/algoplus.h:29,
                 from .\try.cc:22:
.\../include/../classes/tree/../../visualization/tree_visual/tree_visualization.h:16:13: error: redefinition of 'const char* visualization::reset'
 const char *reset = "\033[0m";
             ^~~~~
In file included from .\../include/../classes/tree/avl_tree.h:5,
                 from .\../include/algoplus.h:28,
                 from .\try.cc:22:
.\../include/../classes/tree/../../visualization/tree_visual/tree_visualization.h:16:13: note: 'const char* visualization::reset' previously defined here
 const char *reset = "\033[0m";

Check that every header exist in algoplus.h include header

At src/include/ we have algoplus.h to help users include all the headers that he have.
In this PR, new contributors can help with making sure that every header from src/ is included at algoplus.h.
If there are headers that are not included. Please, include them just like the others.

Visualization generator missing from tree.h header

the simple tree(tree.h header) was lately added and lacks a visualization generator function.
You can take the other tree headers as reference to create the generator function(to generate the string) and then to add a simple visualize() function in the class to perform the visualization using the returning string. The graphviz visualization function is ready at vizualization folder, you only need to implement the string generator.

Red Black tree class

We do not have red black tree structure as of yet. It is a self balancing binary search tree data structure.

Concept

WiKi

Thing to impliment

  • Structure of the class (including methods like search, remove and traversal)
  • Iterator class
  • Visualize
  • Tests
  • Examples

No support for building on windows without MinGW

i tried building with clang, and it mostly works. However, one of the graph test cases fails. When it gets weird though is when I try to include the library in another C file, and then i get an error for the use of an undeclared identifier arc4random, which does make sense. However, how I'm able to build the library I don't know.
Is there any reason for the use of platform specific code here?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.