title: How to check if a Graph is a Planar Graph or not?
body: <p>I'm learning about the Planar Graph and coloring in c++. But i don't know install the algorithm to do this work. Someone please help me?</p>
  
  <p>Here i have some information for you! This is my code! And it still has a function does not finish. If someone know what is a "Planar Graph", please fix the Planar_Graph function below! :D thanks so much! :x</p>
  
  <pre><code># define MAX 100
  
  int kt[MAX];
  int tk=0;
  
  int my_array[MAX][MAX];      // Graph
  FILE *f;
  int n,m;            //m: Edge, n: Vertex
  int index[MAX];            
  int ke[MAX];      
  int Color[MAX]   ;      //Color Array
  int colors_max;      
  char filename[MAX];
  
  int input(char filename[MAX])   
  {
      int i,j;
  
      f = fopen(filename,"r");
      if (f== NULL)
      {
          printf("\n Error \n");
          return 1;
      }
      else
      {
          printf("File mane: %s \n",filename);
          printf("Content   :\n");
          fscanf(f,"%d",&amp;n);
          fscanf(f,"%d",&amp;m);
  
          for(i=0;i&lt;n;i++)
          {
              for(j=0;j&lt;n;j++)
              {
                  fscanf(f,"%d",&amp;my_array[i][j]);
                  printf("%d   ",my_array[i][j]);
              }
              printf("\n");
          }      
          return 0;
      }   
  }
  
  void Default()   
  
  {
      for(int i=0;i&lt;colors_max;i++)
      Color[i]= i;
  }
  
  void Init()             
  {
      filename[0]=NULL;
      n = 0;
  }
  
  
  int Planar_Graph(int my_array[MAX][MAX],int n, int m) // This is my problem
  {
  
      /* for(int i=0;i&lt;n;i++)
  
          if(n&gt;=2 &amp;&amp; (int)(n+1)*(n-2)/(n-1)&gt;=m)
          return 1;
      }
      else
      {
          return 0;
      } */
  
  }
  
  int max()
  {
      int max;
      int count=0;
      for(int i=0;i&lt;n;i++)
      {       
          count = 0;
          for(int j=0;j&lt;n;j++)   
              if (my_array[i][j] &gt; 0)   
                  count++ ;
          if (max &lt; count)      
              max = count;
      }
      return max+1;
  }
  
  void Check(int x,int y)      // Check around
  {
      int i;
      Default();         
      for(i=0;i&lt;n;i++)
      {
          if (my_array[x][i] != -1)   // if edge [x,ke[i]] is color t
              Color[my_array[x][i]] = -1;   // then Color[t] = 0
      }
  
      for(i=0;i&lt;n;i++)
      {
          if (my_array[y][i] != -1)
              Color[my_array[y][i]] = -1;
  
      }
  }
  
  void Coloring()
  {
      int t;
      for(int i=0;i&lt;n;i++)
        for(int j=0;j&lt;n;j++)
           if (my_array[i][j] &gt; 0)
           {
              Check(i,j) ;
              for(t=0;t &lt; colors_max;t++)
                 if (Color[t] == t)
                 {
                    my_array[i][j] = t;
                    my_array[j][i] = t;
                    break;
                 }
           }
  }
  
  void main()
  {
  
      if(input("input.txt")!=1)
      {
           Default();
           colors_max =  max()    ;
           Coloring();
           printf("\n Result:\n\n");
           Planar_Graph(my_array,n,m);
           for(int i=0;i&lt;n;i++)
           {
                for(int j=0;j&lt;n;j++)
                  if (my_array[i][j]&gt;0)
                  {
                      printf(" %c,%c] coloring %d \n",i + 'A',j + 'A',my_array[i][j]) ;
                      my_array[i][j] = -1;
                      my_array[j][i] = -1; 
                  }
                  printf("\n") ;
           }
  
      }
  
  }
  </code></pre>
  
  <p>The input file example:</p>
  
  <pre><code>10 18
  0 1 0 1 1 1 0 0 0 0
  1 0 1 0 0 0 0 0 0 0
  0 1 0 0 1 0 0 0 0 0
  1 0 0 0 1 0 1 1 0 0
  1 0 1 1 0 1 1 0 1 0
  1 0 0 0 1 0 1 0 1 0
  0 0 0 1 1 1 0 1 0 0
  0 0 0 1 0 0 1 0 1 1
  0 0 0 0 1 1 0 1 0 1
  0 0 0 0 0 0 0 1 1 0
  </code></pre>