To create to positions of a hexagonal lattice is simple. This algorithm can be used to connect these hexagonal lattice points and create a honey comb pattern.

#include 
#include 
#include 

double vx[100][100];
double vy[100][100];




double posX(int x,int y)
{
  return x-(y%2)*0.5+vx[x][y]*0.7;
}

double posY(int x,int y)
{
  return y*0.866+vy[x][y]*0.7;
}

int setKnod(int x,int y, double a)
{  printf("\n",posX(x,y)*a,posY(x,y)*a);
}


int setCon(int x1,int y1, int x2, int y2,double a)
{
 printf (" \n",x2,y2);
}

main()
{
int x,y;

double a= 20;
double da= a*0.866;

int Ny=10;
int Nx=10;

srand(time(NULL));

for (y=0;y<=Ny;y=y+1)
   {
   for (x=0;x<=Nx;x=x+1)
     {
	 if (((x%3==0) && (y%2==0)) || ((x%3==2) && (y%2==1))  )
       {
	      //printf ("%.3f\t%.3f\n",x-(y%2)*a/2,y*da);
	      
		  vx[x][y]= (float)rand()/RAND_MAX;
		  vy[x][y]= (float)rand()/RAND_MAX;
		  setKnod(x,y,a);

		  vx[x+1][y]= (float)rand()/RAND_MAX;
		  vy[x+1][y]= (float)rand()/RAND_MAX;
	      setKnod(x+1,y,a);
		  printf ("\n");
	   }


	 }
   }

printf("\n");

for (y=0;y<=Ny;y=y+1)
   {
   for (x=0;x<=Nx;x=x+1)
     {
	 if (((x%3==0) && (y%2==0)) || ((x%3==2) && (y%2==1))  )
       {
		  setCon(x,y,x+1,y,a);
		  
	      if (y0)
		    {
   	        setCon(x+1,y,x+1+((y+1)%2),y-1,a);
		    }
		  printf ("\n");
	   }


	 }
   }

printf("\n");
}