Commit ccd0442a authored by Gerion Entrup's avatar Gerion Entrup
Browse files

qwViz: add sourcecode

source: http://cpc.cs.qub.ac.uk/summaries/AEJN_v1_0.html
parent 49b69232
This diff is collapsed.
qwViz 1.0 - Visualisation of quantum walks on graphs
------------------------------------------------------------
Standard installation instructions:
----------------------------------
1. In the qwViz directory, type the commands:
cd src
cp Makefile_Linux Makefile (or "cp Makefile_Mac Makefile" for Mac users)
make
2. To remove the object files after compiling, type the command:
make clean
3. It may be useful to add the bin directory to your default path:
If you have installed qwViz in your home directory (~/qwViz) then you
need to do the following.
In the bash shell, you need to edit ~/.bash_profile or ~/.bashrc to
include the lines:
PATH=$PATH:~/qwViz/bin
export PATH
For csh or tcsh, you can add the following line to ~/.cshrc:
set PATH = ( ~/qwViz/bin $PATH )
4. To test the install, examples in qwViz/examples can be executed using
qwViz infile.adj or qwViz infile.qwml
******************************
IMPORTANT: GRAPHVIZ DEPENDENCY:
******************************
qwViz depends on Graphviz libraries, which are freely avaliable and licenced
on an open source basis (www.graphviz.org). A standard install of
Graphviz 2.26 from source code places the required libraries in /usr/local/lib
and header files in /usr/local/include/graphviz.
Mac users can also use MacPorts to install Graphviz, in which case the required
libraries will be installed in /opt/local/lib and header files in
/opt/local/include/graphviz.
Using either of these standard Graphviz installations will allow the required
libraries to be automatically linked at compile time.
Non-standard Graphviz installation:
-----------------------------------
If for some reason, you do install the Graphviz libraries and header files
in these standard locations, you will need to modify the Makefile in to link
the libraries and include the headers at compile time.
It will be useful to know that:
The Graphviz header file required is "gvc.h"
The Graphviz libraries to be linked are "graph", "cdt", "gvc", "pathplan"
qwViz 1.0 - Visualisation of quantum walks on graphs
------------------------------------------------------------
1) THIS software has the following structure of directories:
/bin - contains the executable file
/src - contains the source code
/include - contains the header files
/obj - contains the object files generated after make
/examples - some examples that can be run after installation
/qwml - contains functions for writing QWML
2) OTHER files in the qwViz directory are:
README - this file
INSTALL - installation instructions
COPYING - the licence agreement
3) AFTER running make we have in bin directory:
The executable binary:
qwViz
4) IN src directory:
Makefile_Mac
Makefile_Linux
Main program file:
qwViz.c
Specific quantum walk and graph layout files:
qw_compute.c
qw_graphlayout.c
qw_malloc.c
qw_readfiles.c
qw_render.c
qw_writefiles.c
OpenGL and generic functions:
bitmap.c
pauls.c
6) AFTER running make we have in obj directory:
object files ending with .o
7) IN include directory, we have:
qwViz.h
bitmap.h
pauls.h
interfacestring.h
optionstring.h
8) IN examples directory, we have
Several examples of ADJ, QWML input files.
An example of a PROB output file.
9) IN qwml directory, we have
Functions for writing QWML:
writeQWML.c
writeQWML.f90
XML Schema for QWML:
qwml.xsd
3-Cay1ey Tree (gen 3)
0111000000000000000000
1000110000000000000000
1000001100000000000000
1000000011000000000000
0100000000110000000000
0100000000001100000000
0010000000000011000000
0010000000000000110000
0001000000000000001100
0001000000000000000011
0000100000000000000000
0000100000000000000000
0000010000000000000000
0000010000000000000000
0000001000000000000000
0000001000000000000000
0000000100000000000000
0000000100000000000000
0000000010000000000000
0000000010000000000000
0000000001000000000000
0000000001000000000000
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Sierpinski Gasket (gen 3)
010000000100000000000000000000000000000000
101000000110000000000000000000000000000000
010100000011000000000000000000000000000000
001010000001100000000000000000000000000000
000101000000110000000000000000000000000000
000010100000011000000000000000000000000000
000001010000001100000000000000000000000000
000000101000000110000000000000000000000000
000000010000000010000000000000000000000000
110000000010000001000000000000000000000000
011000000100000001000000000000000000000000
001100000000100000010000000000000000000000
000110000001000000010000000000000000000000
000011000000001000001000000000000000000000
000001100000010000001000000000000000000000
000000110000000010000010000000000000000000
000000011000000100000010000000000000000000
000000000110000000100001000000000000000000
000000000000000001010001100000000000000000
000000000001100000100000100000000000000000
000000000000011000000100010000000000000000
000000000000000000001010011000000000000000
000000000000000110000100001000000000000000
000000000000000001100000100100000000000000
000000000000000000110001000100000000000000
000000000000000000001100001000010000000000
000000000000000000000110010000010000000000
000000000000000000000001100010001000000000
000000000000000000000000000101001100000000
000000000000000000000000000010100110000000
000000000000000000000000000001010011000000
000000000000000000000000011000100001000000
000000000000000000000000000110000100100000
000000000000000000000000000011001000100000
000000000000000000000000000001100001001000
000000000000000000000000000000110010001000
000000000000000000000000000000001100010100
000000000000000000000000000000000000101110
000000000000000000000000000000000011010010
000000000000000000000000000000000000110011
000000000000000000000000000000000000011101
000000000000000000000000000000000000000110
This diff is collapsed.
/*=======================================================================
qwViz - OpenGL visualisation of quantum walks on graphs
-----------------------------------------------------------------------
Copyright (C) 2011 Scott D. Berry
Contact: scottdberry 'at' gmail
This file is part of qwViz.
qwViz is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
qwViz is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with qwViz. If not, see <http://www.gnu.org/licenses/>.
========================================================================*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include "pauls.h"
#ifndef BITMAPLIB_H
#define BITMAPLIB_H
typedef struct {
unsigned char r,g,b,a;
} BITMAP4;
typedef struct {
unsigned char r,g,b;
} BITMAP3;
/* 18 bytes long */
typedef struct {
unsigned char idlength;
char colourmaptype;
char datatypecode;
short int colourmaporigin;
short int colourmaplength;
char colourmapdepth;
short int x_origin;
short int y_origin;
short int width;
short int height;
char bitsperpixel;
char imagedescriptor;
} TGAHEADER;
BITMAP4 *Create_Bitmap(int,int);
void Destroy_Bitmap(BITMAP4 *);
void Write_Bitmap(FILE *,BITMAP4 *,int,int,int);
void Erase_Bitmap(BITMAP4 *,int,int,BITMAP4);
void GaussianScale(BITMAP4 *,int,int,BITMAP4 *,int,int,double);
void BiCubicScale(BITMAP4 *,int,int,BITMAP4 *,int,int);
double BiCubicR(double);
int Draw_Pixel(BITMAP4 *,int,int,int,int,BITMAP4);
BITMAP4 Get_Pixel(BITMAP4 *,int,int,int,int);
void Draw_Line(BITMAP4 *,int,int,int,int,int,int,BITMAP4);
BITMAP4 Scale_Pixel(BITMAP4,double);
void Flip_Bitmap(BITMAP4 *,int,int,int);
int Same_BitmapPixel(BITMAP4,BITMAP4);
BITMAP4 YUV_to_Bitmap(int,int,int);
void BM_WriteLongInt(FILE *,char *,long);
void BM_WriteHexString(FILE *,char *);
void TGA_Info(FILE *,int *,int *,int *);
int TGA_Read(FILE *,BITMAP4 *,int *,int *);
void TGA_MergeBytes(BITMAP4 *,unsigned char *,int);
void WriteTGACompressedRow(FILE *,BITMAP4 *,int,int);
#endif /* BITMAPLIB_H */
/*=======================================================================
qwViz - OpenGL visualisation of quantum walks on graphs
-----------------------------------------------------------------------
Copyright (C) 2011 Scott D. Berry
Contact: scottdberry 'at' gmail
This file is part of qwViz.
qwViz is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
qwViz is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with qwViz. If not, see <http://www.gnu.org/licenses/>.
========================================================================*/
char *interfacestring = "Interface\n\
Right mouse button Popup menus\n\
[ ] Roll camera\n\
Left mouse button Rotate camera\n\
Arrow keys Rotate camera\n\
Left mouse button + shift Pan camera\n\
Arrow keys + shift Pan camera\n\
< > Move camera forward or backward\n\
+ - Zoom in/out by changing aperture\n\
a A (z) Automatic rotation (stop)\n\
f1 ... f6 Special camera views\n\
x Return camera to initial position\n\
p Toggle play/paused\n\
n b Next/Back: increment or decrement the time by one step\n\
u d Up/Down: adjust the scale for the plotted data\n\
s f Slow/Fast: adjust the speed of the simulation\n\
/ Return to t = 0\n\
c v Increase/decrease the radius of the cylinders\n\
j Toggle vertex identification arrow on/off\n\
k l Increment vertex identification arrow\n\
w Window dump (default is TGA file)\n\
r Record: Toggle continuous window dump (Use with care)\n\
h Help: display interface information\n\
i Info: display scale and time step information\n\
q esc Quit";
/*=======================================================================
qwViz - OpenGL visualisation of quantum walks on graphs
-----------------------------------------------------------------------
Copyright (C) 2011 Scott D. Berry
Contact: scottdberry 'at' gmail
This file is part of qwViz.
qwViz is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
qwViz is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with qwViz. If not, see <http://www.gnu.org/licenses/>.
========================================================================*/
char *optionstring = "Options\n\
-h This text\n\
-d Debug/verbose mode\n\
-f Full screen\n\
-s Active stereo\n\
-ss Dual screen stereo\n\
-bg r g b Background colour\n\
-cs i Colour scheme\n\
-circo Layout the vertices in a circle\n\
-fdp Use the Fruchterman-Reingold force-based graph layout algorithm\n\
-tiff Change image export format to TIFF\n\
-i [int] Linearly interpolate probability distribution [smoothness]\n\
\n\
Quantum walk options (.adj input required)\n\
-start [int] Quantum walk starting from vertex [start position]\n\
-search [int] Quantum-walk-based search procedure [marked vertex]\n\
-steps [int] [Number] of steps in the walk\n\
-o [char] Write data to a file, .qwml or .prob extension determines output format\n\
";
/*=======================================================================
qwViz - OpenGL visualisation of quantum walks on graphs
-----------------------------------------------------------------------
Copyright (C) 2011 Scott D. Berry
Contact: scottdberry 'at' gmail
This file is part of qwViz.
qwViz is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
qwViz is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with qwViz. If not, see <http://www.gnu.org/licenses/>.
========================================================================*/
#ifndef PAULSLIB_H
#define PAULSLIB_H
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <sys/time.h>
#include <sys/resource.h>
#include <termios.h>
#include <unistd.h>
#define ABS(x) (x < 0 ? -(x) : (x))
#define CROSSPROD(p1,p2,p3) \
p3.x = p1.y*p2.z - p1.z*p2.y; \
p3.y = p1.z*p2.x - p1.x*p2.z; \
p3.z = p1.x*p2.y - p1.y*p2.x
#define YES 1
#define NO 0
#ifndef TRUE
#define TRUE 1
#define FALSE 0
#endif
#define CLOCKWISE 1
#define ANTICLOCKWISE (-1)
#define COUNTERCLOCKWISE (-1)
#define CONVEX 1
#define CONCAVE (-1)
#define ESC 27
#define THREEPI 9.424777960769379715387930
#define EPSILON 0.00000001
#define EPS 0.00001
#define DTOR 0.0174532925
#define RTOD 57.2957795
#define TWOPI 6.283185307179586476925287
#define PI 3.141592653589793238462643
#define PID2 1.570796326794896619231322
#define PID3 1.047197551196397746154214
#define PID4 0.7853981633974483096156608
#define PIPI 9.869604401089358618834491
#define E 2.718281828459045235360287
#define GAMMA 0.5772156649015328606065120
#define LOG2 0.3010299956639811952137389
#define LOG3 0.4772112547196624372950279
#define LOGPI 0.4971498726941338543512683
#define LOGE 0.4342944819032518276511289
#define LOG2E 1.4426950408889634073
#define LN2 0.6931471805599453094172321
#define LN3 1.098612288668109691395245
#define LNPI 1.144729885849400174143427
#define LNSQRT2 0.3465735902799726547
#define LNGAMMA -0.549539293981644822337662
#define SQRT2 1.4142135623730950488
#define SQRT3 1.7320508075688772935
#define SQRT5 2.2360679774997896964
#define SQRT7 2.6457513110645905905
#define SQRTPI 1.772453850905516027298167
typedef struct {
double r,g,b;
} COLOUR;
typedef struct {
double x,y,z;
} XYZ;
void Normalise(XYZ *);
XYZ ArbitraryRotate(XYZ,double,XYZ);
COLOUR GetColour(double,double,double,int);
double GetRunTime(void);
double VectorLength(XYZ,XYZ);
#endif /* PAULSLIB_H */
#ifndef OPENGLLIB_H
#define OPENGLLIB_H
typedef struct {
int id;
char name[128];
} PANELITEM;
typedef struct {
int id;
int nitems;
PANELITEM *items;
} PANEL;
int WindowDump(char *,int,int,int,int);
void CreateDisk(XYZ,XYZ,double,double,int,double,double);
void CreateCone(XYZ,XYZ,double,double,int,double,double);
void DrawGLText(int,int,char *);
#endif /* OPENGLLIB_H */
/*=======================================================================
qwViz - OpenGL visualisation of quantum walks on graphs
-----------------------------------------------------------------------
Copyright (C) 2011 Scott D. Berry
Contact: scottdberry 'at' gmail
This file is part of qwViz.
qwViz is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
qwViz is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with qwViz. If not, see <http://www.gnu.org/licenses/>.
========================================================================*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <gvc.h>
#include <ctype.h>
#if defined(__linux__)
#include <GL/glut.h>
#elif defined(__APPLE__)
#include <GLUT/glut.h>
#else
#warning "Not sure where to find glut.h"
#endif
#include "pauls.h"
#include "bitmap.h"
/** Typedefs for all subprograms : */
typedef struct {
XYZ vp; /** View position */
XYZ vd; /** View direction vector */
XYZ vu; /** View up direction */
XYZ pr; /** Point to rotate about */
double focallength; /** Focal Length along vd */
double aperture; /** Camera aperture */
double eyesep; /** Eye separation */
double near,far; /** Cutting plane distances */
int stereo; /** Are we in stereo mode */
int screenwidth; /** Screen dimensions */
int screenheight;
} CAMERA;
typedef struct {
int debug; /** Debug mode */
int record; /** Movie recording mode */
int windowdump; /** Image recording modes */
int exporttiff; /** Export Tiff */
int fullscreen; /** Game mode or not */
double targetfps; /** Target frame rate */
int rendermode; /** Shading type */
int showinfo; /** Display model info */
int showhelp; /** Display help info */
int showconstr; /** Display construction */
int autorotate; /** Spin automatically */
COLOUR bgcolour; /** Background colour */
int texturetype;
int showarrow;
int labelledvertex;
int subframes;
int colourscheme;
} OPTIONS;
typedef struct {
int button;
int shift;
int mouseh;
int mousev;
double framerate; /** Rate at which the integer time steps pass */
int paused; /** Is the movie playing or paused */
int currenttime; /** The current integer timestep */
int currentsubframe; /** The current integer sub-timestep */
} INTERFACESTATE;
typedef struct {
int nodes;
int **adj;
double *Xcoord;
double *Ycoord;
char* name;
float noderadius;
int graphvizlayout;
char* layoutalgorithm;
int firstrender;
} GRAPH;
typedef struct {
int compute;
int steps;
double **prob;
char* comment;
float maxprob;
float scalemax;
} QWDATA;
typedef struct {
char procedure;
int marked;
int start;
int write;
} QWPARAM;