void Cluster::add(const PointPtr &p)
	{
		if (points != NULL)
			assert(p->getDims() == points->p->getDims());				//make sure dimensions match
		
		if (find(p) != NULL) {											//make sure p is not already in cluster
			return;
		}
		size++;
		LNodePtr node = new LNode;										// Dynamically allocate new node
		LNodePtr ptr = points;
		node->p = p;

		if (points == NULL) {											//case: empty cluster
			points = node;
			node->next = nullptr;
			return;
		}

		if (*node->p < *points->p) {									//case: new point is smallest point
			node->next = points;
			points = node;
			return;
		}

		LNodePtr last = nullptr;			
			
		while ( *p > *ptr->p) {										//put in lexographic order
			last = ptr;
			if (ptr->next == NULL) {//if end of list
				node->next = nullptr;
				last->next = node;
				return;
			}
			ptr = ptr->next;		
		}

		while (*p == *ptr->p && p > ptr->p) {							//if points are equal sort by memory address 
			last = ptr;													//for reasons of comparison
			if (ptr->next == NULL) {
				node->next = nullptr;
				last->next = node;
				return;
			}
				ptr = ptr->next;				
		}

		node->next = ptr;
		if (last != nullptr)			
			last->next = node;
		else
			points = node;				
	}