title: Dijkstra Program
body: <p>I am having trouble with functions that I have used before in different programs and I have come to a brick wall with converting them to be used in this new program. Dijkstra.cpp reads information about a weighted graph from the standard input
  and prints the description of the input graph, the shortest path from the 
  start vertex and the end vertex, and the distance of that path to the 
  standard ouput. </p>
  
  <p>Here are the <strong>ALL</strong> errors I receive (given, it is an incomplete program as is):</p>
  
  <p><a href="https://i.stack.imgur.com/8VgpP.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/8VgpP.png" alt="attach1"></a>
  <a href="https://i.stack.imgur.com/6R6Mq.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/6R6Mq.png" alt="attach2"></a></p>
  
  <pre><code>#include &lt;cstdio&gt;
  #include &lt;cstdlib&gt;
  #include &lt;cstring&gt;
  using namespace std;
  
  int trace = 0;
  
  //An object of type Edge is a cell in an adjacency list and represents an edge
  //of the graph.
  
  struct Edge 
  {
      int from;           //The 'from' direction of the edge.
      int to;         //The 'to' direction of the edge.
      double weight;      //The weight of the edge from u to v.
      Edge* next;     //A pointer to the next edge in the linked list.
  
      Edge(int u, int v, double w, Edge* nextEdge)
      {
          from = u;
          to = v;         
          weight = w;     
          next = nextEdge;
      }
  };
  
  
  //An object of type Vertex represents information about one vertex in a graph.
  
  struct Vertex       
  {
      Edge* edgeList;     //A pointer to a linked list of all edges 
                      //from v to another vertex.
  
      double time;        //A real number representing the shortest
                      //distance from the start vertex.
  
      int sender;     //Used with the above real number, it begins 
                  //finding the shortest path starting from v to
                  //the sender. 
  
      Vertex()
      {
          edgeList = NULL;
          time = -1;
          sender = -1;
      }
  };
  
  
  //An object of type graph represents a weighted graph.
  
  struct Graph
  {
      int numVertices;    //The number of verticies in the graph.
      int numEdges;       //The number of edges in the graph.
  
      Vertex* vertices;   //An array for verticies utilizing a Vertex
                          //structure that gives information about a
                          //specific vertex.
  
      Graph(int nV)
      {
          numVertices = nV;
          vertices = new Vertex[nV+1];
          numEdges = 0;
      }
  };
  
  
  
  //insertEdge inserts an edge into the graph g.
  
  void insertEdge(int u, int v, int w, Graph* g)
  {
      Edge newEdge;
      newEdge.from = u;
      newEdge.to = v;
      newEdge.weight = w;
  
      if(g-&gt;numVertices &gt; g-&gt;numEdges)
      {   
          g-&gt;[g-&gt;numEdges] = newEdge;
          g-&gt;numEdges++;
      }
  }
  
  //insertOpposite inserts an edge going the opposite way
  //as insertEdge does into graph g.
  
  void insertOpposite(int u, int v, int w, Graph* g)
  {
      Edge newEdge;
      newEdge.from = v;
      newEdge.to = u;
      newEdge.weight = w;
  
      if(g-&gt;numVertices &gt; g-&gt;numEdges)
      {       
          g-&gt;vertices[g-&gt;numEdges] = newEdge;
          g-&gt;numEdges++;
      }
  }
  
  
  //readGraph reads a graph and is also able to insert edges into a graph.
  
  Graph* readGraph()
  {
      int nV, u,v,w, edges = 0;
  
      scanf("%i", &amp;nV);
  
      Graph* g = new Graph(nV);
  
      while(true)
      {
          scanf("%i", &amp;u);
          if(u == 0)
          {
                  break;
          }
  
          scanf("%i", &amp;v);
          scanf("%i", &amp;w);
  
          insertEdge(u, v, w, g);
          insertOpposite(u, v, w, g);
  
          edges++;
      }
  
      g-&gt;totalEdges = edges;  
  
      return g;
  }
  
  
  //writeGraph prints a formatted chart from graph g 
  //that includes the amount of vertices and edges along with 
  //the weight that corresponds to each edge.
  
  void writeGraph(Graph* g)
  {
      printf("\nThere are %i vertices and %i edges\n", g-&gt;numVertices,
          g-&gt;numEdges);
  
      printf("\n The edges are as follows.");
  
      for(int n = 0; n &lt; g-&gt;totalEdges; n++)
      {
          printf("(%i,", g-&gt;vertices[n].vertex1);
          printf("%i)  ", g-&gt;vertices[n].vertex2);
          printf("weight %3i\n", g-&gt;vertices[n].weight);
      }
  }
  </code></pre>