Giter Club home page Giter Club logo

distance_oracles's Introduction

Instructions to run main.cpp

The file main.cpp has to be compiled first usign the following command:

g++ main.cpp

The generated file will be named a.out by default. To run this file, the following command has to be executed:

./a.out <graph-file>

The graph-file is the name of the file where the graph is stored.

Important

The program only recognizes the graph file if it is in a specific format, which is mentioned below:

  • The first line of the file is ignored, and it may contain a comment describing the graph, or may even be empty.
  • The seocnd line of the file should contain the number of nodes (n) and the number of edges (m) in the graph, separated by a space.
  • The following m lines should contain at least two integers a and b (separated by a space), which represents that there is an edge between nodes a and b in the graph. Note that a and b both must be less than n for the program to work correctly.

A sample graph-file has been attached for reference.

Output format

The first two lines of output contains the number of nodes and the number of edges in the graph (separated by a space).

The following line contains the time (in seconds) taken by the distance oracle for the pre-computation The next line contains the time (in seconds) taken by the Floyd-Warshall algorithm for pre-computing the distances between all pairs of nodes in the graph.

Testing the validity of the oracle

A certain portion of the code (commented at the end) confirms the validity of the distnace oracle. It asserts that the answer given by the distance oracle is stretched by at most 2k - 1 times the actual shortest path computed by the Floyd Warshall algorithm.

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.