title: Euler Tour in C#
body: <p>I am wondering what is wrong in the below C# code to produce an Euler Tour of vertex indices through Hierholzer's Algorithm, assuming all vertices have even degrees so the tour can start anywhere:</p>
  
  <p>(and where pt_id is a list of list of integers representing the start and end point indices that made up of the edges)</p>
  
  <p>ps. the GraphMatrix comprises of the following items initially, in case it is of any help due to the lack of information on pt_id:</p>
  
  <pre><code>n y y n y y n n n n n
  
  y n n n y n n n n n n
  
  y n n y y y n n n n n
  
  n n y n n y n y y n n
  
  y y y n n y n n n n n
  
  y n y y y n n n n n n
  
  n n n n n n n y y y y
  
  n n n y n n y n y n y
  
  n n n y n n y y n n y
  
  n n n n n n y n n n y
  
  n n n n n n y y y y n
  </code></pre>
  
  <hr>
  
  <p>code:</p>
  
  <pre><code>Stack tempPath = new Stack();
  ArrayList finalPath = new ArrayList();
  
  int total = 11;//total number of nodes
  
  string[] nodeList = new string [total];//to store the nodes
  string[,] GraphMatrix = new string [total, total];//to store the edge representation of graph
  
  //node/vertice to nodeList array
  for(int i = 0; i &lt; total; ++i) {
    nodeList[i] = i.ToString();
  }
  
  
  //edge details in the graph(connectivity boolean matrix)
  //matrix first filled with "n"
  for(int i = 0; i &lt; total; ++i) {
    for(int j = 0; j &lt; total; ++j) {
      GraphMatrix[i, j] = "n";
    }
  }
  //if connection exists, matrix item is changed to "y"
  for(int i = 0; i &lt; pt_id.Count; ++i) {
    GraphMatrix[pt_id[i][0], pt_id[i][1]] = "y";
    GraphMatrix[pt_id[i][1], pt_id[i][0]] = "y";
  }
  
  
  //start tour
  
  int s = 0;
  int ind = 0;
  tempPath.Clear();
  
  tempPath.Push(nodeList[0]);
  
  while(tempPath.Count != 0 &amp;&amp; s &lt; 100) {
  
    int index = 0;
    while (tempPath.Peek().ToString() != nodeList[index] &amp;&amp; s &lt; 100) {
      index++;
      s++;
    }
  
    ind = index;
    for(int i = 0; i &lt; total; ++i) {
      if(GraphMatrix[ind, i] != "y") {
        finalPath.Add(tempPath.Pop());
      }
      else{
        GraphMatrix[ind, i] = "n";
        GraphMatrix[i, ind] = "n";
        tempPath.Push(nodeList[i]);
      }
    }
    s++;
  }
  </code></pre>
  
  <p>I am getting the error saying that the Stack is empty.</p>
  
  <p>Thank you very much,</p>
  
  <p>Tim</p>