Giter Site home page Giter Site logo

make-github-pseudonymous-again / js-algorithms Goto Github PK

View Code? Open in Web Editor NEW
37.0 3.0 3.0 1.85 MB

:rocket: Algorithms for JavaScript

License: GNU Affero General Public License v3.0

JavaScript 100.00%
algorithm js javascript algorithms agpl sorting computer-science searching

js-algorithms's Issues

explore other implementations of binomial heaps

  1. use a backreference to keep track of nodes instead of swapping childrens
    • faster because we only need to swap values and backreferences
    • additional memory used
  2. implementation only supporting push pop and merge

Karp-Luby sampling

Linear time measure approximation of a set union given oracles for uniform sampling on the multiset union and membership testing on the insertion-order labeled set union.

measure: |S| e.g. volume, cardinality, ...

set union: U_i S_i

uniform sampling on the multiset union: Sample (y, k) from U_i { (x, i) : x in S_i } uniformly at random.

membership testing on the union-order labeled set union: Test whether (y, k) belongs to U_i { (x, i) : x in S_i, x not in S_j for j < i }. Can be implemented as testing whether y belongs to { x in S_k : x not in S_j for j < k } in general.

References

  • 1983 Karp, Luby Monte-Carlo algorithms for enumeration and reliability problems
  • 1989 Karp, Luby, Madras Monte-Carlo approximation algorithms for enumeration problems

5-list-coloring of planar graphs

Reference

@Article{thomassen1994every,
title={Every planar graph is 5-choosable},
author={Thomassen, Carsten},
journal={Journal of Combinatorial Theory Series B},
volume={62},
number={1},
pages={180--181},
year={1994},
publisher={Academic Press, Inc. Orlando, FL, USA}
}

Algorithm

Input:
A triangulation T with outer boundary cycle C,
two adjacent vertices on C named u and v
and color assignment L for T such that
L(u) = {1},
L(v) = {2},
|L(o)| >= 3 for o in C - {u, v}, and
|L(i)| >= 5 for i in T - C.

Output: A proper coloring of T.

Steps:

  1. Color u with the color in L(u) and color v with the color in L(v).

  2. Base case: |T| = |C| = 3, color o in C - {u,v} with one of the colors in L(o) - L(u) - L(v).

  3. If there is a chord (s,t) of C then split C along this chord into two
    smaller cycles, given two strictly smaller triangulations A and B.
    Let A be the triangulation that contains (u,v).
    Recursively color B with L.
    This gives a color assigment to s and t of 1' and 2' respectively. Let L'(s) = 1'
    and L'(t) = 2' and L'(x) = L(x) for all other vertices in B.
    Recursively color B with L'.

  4. There is no chord. Let t != v be the other vertex of C that is adjacent to u.
    Let L'(t) = L(t) - L(u). L'(t) contains at least 2 colors {x,y}.
    For all vertices f adjacent to t that are in T - C let L'(f) = L(f) - {x,y}.
    For all other vertices x of T let L'(x) = L(x).
    Recursively color T - {t} with L'.
    Let s != u (could be v) be the other adjacent vertex of t on C and x be its
    assigned color without loss of generality. Extend the coloring of T - {t} to a coloring of T
    by coloring t with y.

Planar Separator

See "A Separator Theorem for Planar Graphs" by Lipton and Tarjan.

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.