Coder Social home page Coder Social logo

cs5130_project's Introduction

CS5130_Project

Minimal Span Trees

See the demo

This project visualizes the differences in how the Prims algorithm creates MST, vs the Kruskals algorithm.

A random graph is generated and traversed by the 2 algorithms, updating the display during traversal. The normal edges are displayed in gray, the MST edges are displayed in red, and the edges being searched are displayed in black.

The input box controls the number of vertices in the graph. Clicking 'Go' will create a new graph, and start traversing.

While the demo is running, all of the edges are displayed. As you can see, these graphs are DENSE as each vertex has an edge to all other vertices.

Once the MST is complete, the edges are removed so that only the edges in the MST are displayed in red.

The runtime of Prim's algorithm is O(|V|2), while Kruskal's algorithm is O(log(|V|)); so it would appear that Prim's would be slower are nodes grow.

Prim's runs faster on dense graphs. Since these graphs are dense, Prim's appears to be a superior algorithm; however, that might not be the case if the graphs were more sparse.

In the future, I may add an option to reduce the density. (generating random graphs is an algorithm in itself ๐Ÿ˜‰)


This project is written in Javascript, using the P5JS library for graphics.
Each graph runs in it's own iframe, so there is complete separation between the code for the 2 algorithms. (ie, alot easier to code).

cs5130_project's People

Contributors

kilgorjn 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.