#ifndef EB_GRAPH2D_H
#define EB_GRAPH2D_H 1
// The graph class contains the methods necessary to draw the
// graph.  It calls on the density server class to obtain
// position and density information

#include "ebDensityGrid2d.h"

// layout schedule information
struct layout_schedule2d {
	int iterations;
	float temperature;
	float attraction;
	float damping_mult;
	time_t time_elapsed;
};

class eb_graph2d {

public:

    // Methods
	void init_parms ( int rand_seed, float edge_cut, float real_parm );
	void scan_wel ( char *filename );
	void read_wel ( char *file_name );
	void draw_graph ( int int_out, char *gvl_file );
	void write_gvl( const char *file_name, const char *wel_file_name, float thresh, int absValFlag, int attractFlag, float grav, int springAlgo);
	float get_tot_energy ( );

	// WES - map to hold vertex ids
	map<string, int> vertex_ids;
	map<int, string> vertex_labels;
	int current_id;
	
	// Con/Decon
	eb_graph2d( char *int_file );
		~eb_graph2d( ) { }
	
private:

	// Methods
	int ReCompute ( );
	void update_nodes ( );
	double Compute_Node_Energy ( int node_ind );
	void Solve_Analytic ( int node_ind, float &pos_x, float &pos_y );
	void get_positions ( vector<int> &node_indices, float return_positions[3] );
	void update_density ( vector<int> &node_indices, float old_positions[3],
			      float new_positions[3] );
	void update_node_pos ( int node_ind,
			       float old_positions[3],
			       float new_positions[3] );
								  
	// MPI information
	int myid, num_procs;
	
	// graph decomposition information
	int num_nodes;					// number of nodes in graph
	float highest_sim;				// highest sim for normalization
	map <int, int> id_catalog;		// id_catalog[file id] = internal id
	map <int, map <int, float> > neighbors;		// neighbors of nodes on this proc.
	
	// graph layout information
	vector<Node2d> positions;  
	DensityGrid2d density_server;
  
	// original VxOrd information
	int STAGE, iterations;
	float temperature, attraction, damping_mult;
	float min_edges, CUT_END, cut_length_end, cut_off_length, cut_rate;
	bool first_add, fine_first_add, fineDensity;  
	
	// scheduling variables
	layout_schedule2d liquid;
	layout_schedule2d expansion;
	layout_schedule2d cooldown;
	layout_schedule2d crunch;
	layout_schedule2d simmer;
	
	// timing statistics
        time_t start_time, stop_time;
	
	// online clustering information
	int real_iterations;    // number of iterations to hold .real input fixed
	int tot_iterations;
	bool real_fixed;

	// num vertices and edges
	int num_vertices; 
	int num_edges;
};
#endif
