Skip to content

SIPL Grapher

Thomas Konstantinovsky edited this page Dec 29, 2019 · 2 revisions

How To Work With SIPL-Grapher

First of all an example of a main with a basic usage of Grapher:

   #include "Graphs_Ut.h"

    int main(void) {
Graph test(5);
Interval_Graph testB;

test.Add_Edge(0, 1);
test.Add_Edge(0, 2);
test.Add_Edge(1, 1);
test.Add_Edge(4, 1);

testB.Add_Interval(1, 5);
testB.Add_Interval(2, 5);
testB.Add_Interval(1, 3);
testB.Add_Interval(1, 9);

testB.Print_Graph_Intervals();
testB.Output_Graph_Image();


test.Export_Graph_Image("Comp");




system("Graph_Output.jpg");
return(1);

The Basics of working with Grapher

Grapher currently supports regular graph theory graphs , which can be initiated by creating an object of class "Graph" and interval graphs which can be initiated by creating an object of class "Interval_Graph" each one of the class possess a set of methods for adding and calculating graph information as well as a method which will output a corresponding image , if using an object of type "Graph" the output image will be a illustration of a graph with differently colored vertices and edges connect them as specified by user.

The "Interval_Class" will output an image which will display an illustration of the interval graph itself on a Cartesian coordinate system , along with all the information calculated using the graph data , information like the number of edges in the interval graph ,the maximum degree , the minimum degree, chromatic number of the interval graph and the same information for the graphs compliment.

An image created of an Interval Graph made from intervals loaded to Interval_Graph class. Alt text

A Regular Graph Illustration:

  • Example of a graph G made from 4 vertices and 4 edges between {V0-V1,V0-V3,V1-V2,V1-V3};

Alt text

  • the method also allows the user to choose if to out put the regular graph or its complement ,here is the complement of the above example :

Alt text

List Of Methods

  • Graph class methods:

    void Add_Edge(int const &Vr, int const &Vl);

    void Print_Edges();

    void Export_Graph_Image(const char *type);

  • Interval_Graph class methods:

    void Add_Interval(int left, int right);

    void Print_Graph_Intervals()const;

    void Run_Analysis();

    void Print_Adjacency_Matirx();

    void Print_Graph_Stats();

    void Output_Graph_Image();

Usage Guidelines "Graph":

  • Create an object of class Graph(for you convenience set the number of vertices by passing the amount to the constructor)

Graph MyGraph(5)

this will create a graph with 5 vertices (V0,V1,V2,V3,V4)

  • Connecting vertices with edges

MyGraph.Add_Edge(0,4)

the following will created an edge between V0 and V4. Please keep in mind that that there are maximum (n*(n-1))/2 edge in any graph ,where n is the number of vertices.

  • Reviewing edges ,printing to console

MyGraph.Print_Edges();

the following will print to console all currently loaded edges.

  • Creating an illustration of the graph:

MyGraph.Export_Graph_Image("SelectedName");

Usage Guidelines "Interval_Graph":

  • Create an object of class Interval_Graph

Interval_Graph Interval(5)

the following will initiate an object that can hold up to 5 intervals , please specify via constructor the maximum amount of edges you are interested to load into memory.

  • Adding intervals:

Interval.Add_Interval(4,9);

the following will add an interval to objects memory ,keep in mind that after passing the maximum amount that was set in the objects constructor this operation will do nothing in order to avoid compilation errors.

  • Reviewing Loaded Intervals:

Interval.Print_Graph_Intervals()

the following will print to console all currently loaded intervals in the method calling object.

  • Updating/Registering objects graph information

Interval.Run_Analysis()

the following method needs to be called at list ones in order to register all the information about the graph in the object ,before calling this method all the values of graphs attributes are zero, after calling this method calculation will be done and all the attributes will be updated accordingly, if after first call of this method more vertices are added ,graphs attributes may change ,so its recommended after any change in vertices to run this method once more in order to update the attribute values.

  • Printing Adjacency Matrix :

Interval.Print_Adjacency_Matrix()

the following method will print to console the adjacency matrix of currently loaded graph in the object.

  • Printing Graph Attributes

Interval.Print_Graph_Stats();

the following method will print to console current status of objects attributes.

  • Creating an illustration of the interval graph:

Interval.Output_Graph_Image();

the following method will create an Illustration of the graph loaded in the object by drawing the intervals on a Cartesian coordinate system along with all the graphs attributes .

Clone this wiki locally