#ifndef MAP_H_INCLUDED
#define MAP_H_INCLUDED

#include <stdio.h> // Because we need FILE types
#include <limits.h> // For the maximum values of distance types

// The "official" index type - 32 bits should be enough for anyone
typedef unsigned long int Index_t;
// How should distances be stored?
typedef long int Distance_t; // Ints are for speed
#define DISTANCE_MAX ((Distance_t) LONG_MAX)

// Structure to hold one edge of the map
typedef struct
{
  Index_t From, To; /* These will be indices into whatever array you're
		       storing the nodes in */
  Distance_t Distance;
}
Edge_t;

// Structure to hold information on a single node
typedef struct Node
{
  Distance_t X, Y;

  // Routing-related fields
  Distance_t Cost; /* This stores the cost (distance from start, in this case)
		      of the minimum path found so far between
		      this node and the source node */

  Index_t Previous_ID; // Points to Node before current one in the path
}
Node_t;

/* An entire map.
   Create these things using Load_Map
   Delete them using Delete_Map
   (yes, we're getting OOPy)
*/
typedef struct
{
  Index_t Num_Nodes;
  Node_t * Node_List_Ptr;
  Index_t Num_Edges;
  Edge_t * Edge_List_Ptr;
}
Map_t;


/*A query structure very similar to Map_t but
  holds the query file data.  I also used Edge_t
  structure because it has From, To which this will
  use as the start node and goal node*/

typedef struct
{
  Index_t Num_Paths;     // Number of paths that need to be computed
  Edge_t* Path_List_Ptr; /* Array of edges representing each path that needs
			    to be computed */
}
Query_t;


/* Load a map into memory (calculating all the distances and such) from a 
   FILE stream */
Map_t * Load_Map(FILE * Input_Stream_Ptr);

/* Delete a Map_t. Think "free(Map_Ptr)" */
void Delete_Map(Map_t * Target_Ptr);

//Loads the query file into memory from FILE stream
Query_t* Load_Query(FILE* Input_Stream_Ptr);

/* Delete a Query_t */
void Delete_Query(Query_t * Target_Ptr);

#endif
