Git Product home page Git Product logo

fib_heap's Introduction

fib_heap

Fibonacci Heap Implementation for C++

References: Fibonacci Heaps and Their Uses in Improved Network Optimization Algorithms - Fredman, et al.

#Notes This was primarily implemented for use in Prim's Algorithm. Graph vertecies are stored in the heap, and ordered by an edge weight associated with each vertex. As such, each node in this implementation takes a vertex integer and weight integer and the heap uses the weight property for organization.

struct node
{
    int rank;
    char mark;
    
    int vertex;
    int weight;
    
    node* parent;
    node* child;
    node* left;
    node* right;
};

#Heap Operations This section will detail how to implement common heap operations using this library, and lists the amortized running time for each as described in Fredman, et al. ####Creating a Heap

FibonacciHeap F;

####Extract Min O(log(n))

node* h = F.Extract_Min();

####Insert O(1) Returns a pointer to that node so that you can directly reference it later for Decrease_Key() operations.

node* h = F.Insert(int weight,int vertex);

####Decrease Key O(1) Weight is set to new value for given node, and heap is reshuffled if the new weight violates the heap.

F.Decrease_Key(node* h, int weight); 

####Display Heap (Only use on small heaps, ~100 nodes) Publishes tree to fib.json, open fib.html to view this in D3.

Sample Graph

F.Display_Heap();

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.