Giter Site home page Giter Site logo

clusterdetection's Introduction

ClusterDetection

Find the largest square cluster in a matrix.

example matrix

Exercise

1. Create the matrix

  • The matrix should be a 2D array consisting of two randomly distributed values or characters, e.g. 'X' and 'O'.
  • Being able to change the ratio of the values could be advantageous.

2. Find the clusters

  • Find the positions and sizes of all square submatrices of a certain minimum size that only contain one of the characters.
  • Ideally, clusters should not intersect.

3. Print the result

  • Print the matrix and highlight the largest cluster by changing the text color.
  • If more than one cluster of that size is present, highlight all of them.
  • Optionally printing a summary would make sense.

4. Performance test [optional]

  • Measure the runtime of each function.
  • Test the functions with different parameters and see how well they scale.

My solution

Starting the program you will be greeted with a small menu.

menu

Menu options

Run once: Creates one random matrix, finds square clusters and prints the results.

Performance test: Executes a set of test cases, calculates the average runtimes and prints out the timings.

Quit: Ends the program.

Function Parameters

Run once:

  • Size of the matrix
  • Enable highlighting all clusters
  • Enable overlapping
  • Minimum cluster size to be recognized
  • Factors to vary the probability of both matrix elements

Performance test:

  • Amount of test cases
  • Runs per case
  • Size of the matrix at the start
  • Size increment for every new case

Examples

Multiple large clusters

example largest clusters

Show all clusters

example show all clusters

Overlap enabled (largest clusters only)

example overlap

Overlap enabled (all clusters)

example overlap

clusterdetection's People

Contributors

anonymoux47 avatar celltec avatar

Stargazers

 avatar

Watchers

 avatar

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.