Giter Site home page Giter Site logo

remylau / gsparse Goto Github PK

View Code? Open in Web Editor NEW

This project forked from as-12/gsparse

0.0 0.0 0.0 35.14 MB

gSparse: C++ Library for Graph Sparsification

License: MIT License

C++ 6.90% CMake 0.71% Shell 0.02% Python 0.83% C 0.03% Jupyter Notebook 91.46% Starlark 0.04%

gsparse's Introduction

gSparse

Build Status codecov Documentation License: MIT

gSparse: C++ Library for Graph Sparsification

Intro

gSparse is a C++ library for Graph Sparsification. It is built on top of Eigen, an open source linear algebra library.

Sparsification Algorithm(s)

gSparse currently supports the following algorithm(s).

Installation

gSparse is implemented as a header-only C++ library, whose only dependency, Eigen, is also header-only.

When compiling gSparse, the compiler must be able to find the gSparse and Eigen header files. This can be done by specifying compiler's include path to Eigen and gSparse source directories.

gSparse requires Compiler with C++11 support or above.

Parallelization

As gSparse utilizes Eigen3 for its matrix operations, it is possible to enable multi-threading on these operations by simply setting compiler's option. See Eigen and multi-threading.

Relation to FastEffectiveResistance

FastER is a software written in MATLAB for calculating Graph Effective Resistance. gSparse leverages the algorithm of FastER for Spectral Sparsification in C++. However, gSparse is not a direct port of FastER because it provides a different interface and it does not depend on CMG Solver.

Examples

Below is an example that demonstrates the gSparse to sparsify a graph from CSV files

#include <gSparse/gSparse.hpp>
#include <iostream>

int main()
{
    // Create a CSV Reader and specify the file location
    gSparse::GraphReader csvReader = std::make_shared<gSparse::GraphCSVReader>("edgeList.csv", "weightList.csv",",");
    // Create an Undirected Graph. gSparse::Graph object is a shared_ptr.
    gSparse::Graph graph = std::make_shared<gSparse::UndirectedGraph>(csvReader);

    // Display original edge count
    std::cout<<"Original Edge Count: " << graph->GetEdgeCount() << std::endl;

    // Creating Sparsifier Object
    gSparse::SpectralSparsifier::ERSampling sparsifier(graph);
    // Set Hyper-parameters
    // Approximate the Effective Weight Resistance (Faster)
    // C = 4 and Epsilon = 0.5
    sparsifier.SetERPolicy(gSparse::SpectralSparsifier::APPROXIMATE_ER);
    sparsifier.SetC(4.0);
    sparsifier.SetEpsilon(0.5);
    // Compute Effective Weight Resistance
    sparsifier.Compute();
    // Perform Sparsification 
    auto sparseGraph1 = sparsifier.GetSparsifiedGraph();
    std::cout<<"Sparised Edge Count (ApproxER): " << sparseGraph1->GetEdgeCount() << std::endl;
    return EXIT_SUCCESS;
}

Documentation

The API reference page contains the documentation of gSparse generated by Doxygen, including all the background knowledge, example code and class APIs.

License

gSparse is an open source project licensed under MIT License.

gsparse's People

Contributors

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