Hypercube logo



Hypercube is designed to be easily extensible to handle additional input/output file formats. To add an extension (provider), the following steps must be done:

  1. Implement the provider and add the source/header files to the Hypercube project files hypercube.pro and hypercube-cli.pro.
  2. Append the provider to the inputProviders or outputProviders array in IO/modules.cpp
  3. Recompile Hypercube

Input providers

#include "IO/io.h"

class MyInputProvider: public InputProvider
    virtual Error readGraph(Graph *graph, const char *fileName) = 0;
    virtual void setInputEncoding(Encoding *encoding);

The input provider interface consists of a single required method - readGraph() and a optional method, setInputEncoding(). The readGraph() implementation has to construct the graph graph from the input file fileName.

Adding vertexes and edges to the graph is done using the addVertex() and addEdge() methods of the Graph class. For setting vertex/edge attributes see the Vertex and Edge classes.

The optional setInputEncoding() method sets the input file encoding given by the user (intended for formats without encoding info).

Output providers

#include "IO/io.h"

class MyOutputProvider: public OutputProvider
    virtual Error writeGraph(Graph *graph, const char *fileName) = 0;
    virtual const char* type() = 0;
    virtual const char* description() = 0;

The type() and description() methods describe the output provider for the user. For example for a PDF output provider, type() would return "pdf" and description() "Portable Document Format".

The writeGraph() method implements the graph export itself. See the Graph class for how to iterate through the vertexes/edges and the Vertex and Edge classes for available vertex/edge attributes.