Package: pygrid-graph
Some tools for manipulating nearest-neighbors graphs defined on regular gridsC++ routines.Parallelization with OpenMP.Mex interfaces for GNU Octave or Matlab.Extension module for Python.A grid graph in dimensionDis defined by the following parameters:D- the number of dimensionsshape- array of lengthD, giving the grid size in each dimensionconnectivity- defines the neighboring relationship;corresponds to the square of the maximum Euclidean distance between two
neighbors;
if less than 4, it defines the number of coordinates allowed
to simultaneously vary (+1 or -1) to define a neighbor; (in that case,
each level ℓ of connectivity in dimensionDadds
CℓD⨯ 2ℓneighbors).Corresponding number of neighbors forD= 2 and 3:connectivity1232D48(8)3D61826Note that a connectivity of 4 or more includes neighbors whose
coordinates might differ by 2 or more from the coordinates of the
considered vertex.
In that sense, in dimension 4 or more, including all immediately
surrounding vertices (that is, all vertices for which each coordinate
differ by 1 or less) would then also include vertices from a more
distant surround: the neighborv+ (2, 0, 0, 0) is at the same
distance as the neighborv+ (1, 1, 1, 1).A graph withVvertices andEedges is represented either as edge list
(array ofEedges given as ordered pair of vertices), or as forward-star,
where edges are numeroted (from 0 toE− 1) so that all edges originating
from a same vertex are consecutive, and represented by the following
parameters:first_edge- array of lengthV+ 1, indicating for each vertex, the
first edge starting from the vertex (or, if there are none, starting from
the next vertex); the last value is always the total number of edgesadj_vertices- array of lengthE, indicating for each edge, its ending
vertexVertices of the grid are indexed incolumn-majororder, that is indices
increase first along the first dimension specified in the 'shape' array
(in the usual convention in 2D, this corresponds to columns), and then along
the second dimension, and so on up to the last dimension.
Indexing inrow-majororder (indices increase first along the last
dimension and so on up to the first) can be obtained by simply reverting
the order of the grid dimensions in the shape array (in 2D, this amounts to
transposition).Work possibly in parallel with OpenMP APIDirectory tree.   
├── include/      C++ headers, with some doc  
├── octave/       GNU Octave or Matlab code  
│   ├── doc/      some documentation  
│   └── mex/      MEX C++ interfaces
├── python/       Python code  
│   └── cpython/  C Python interface  
└── src/          C++ sourcesC++ documentationRequiresC++11.Be sure to have OpenMP enabled with your compiler to enjoy parallelization. Note that, as of 2020, MSVC still does not support OpenMP 3.0 (published in 2008); consider switching to a decent compiler.The C++ classes are documented within the corresponding headers ininclude/.Python extension moduleRequiresnumpypackage.Requiresnumpypackage.See the scriptsetup.pyfor compiling modules withsetuptools; it can be run simply by usingpipe.g.python -m pip install .. pre compiled binaries for Windows and Linux will soon be available on `PyPIOnce compiled, see the documentation with thehelp()python utility.GNU Octave or MatlabSee the scriptcompile_mex.mfor typical compilation commands; it can be run directly from the GNU Octave interpreter, but Matlab users must set compilation flags directly on the command lineCXXFLAGS = ...andLDFLAGS = ....Extensive documention of the MEX interfaces can be found within dedicated.mfiles inoctave/doc/.References and licenseThis software is under the GPLv3 license.Hugo Raguet 2019, 2020