/*
 * sideRETRO - A pipeline for detecting Somatic Insertion of DE novo RETROcopies
 * Copyright (C) 2019-2020 Thiago L. A. Miller <tmiller@mochsl.org.br
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

#ifndef DBSCAN_H
#define DBSCAN_H

#include "ibitree.h"
#include "list.h"

enum _Label
{
	UNDEFINED,
	NOISE,
	REACHABLE,
	CORE
};

typedef enum _Label Label;

struct _Point
{
	Label  label;
	int    id;
	int    neighbors;
	long   low;
	long   high;
	void  *data;
};

typedef struct _Point Point;

struct _DBSCAN
{
	List          *points;
	IBiTree       *index;
	DestroyNotify  destroy_data;
};

typedef struct _DBSCAN DBSCAN;

typedef void (*DFunc) (Point *p, void *user_data);

DBSCAN * dbscan_new          (DestroyNotify destroy_data);
void     dbscan_free         (DBSCAN *db);
void     dbscan_insert_point (DBSCAN *db, long low, long high, void *data);
int      dbscan_cluster      (DBSCAN *db, long eps, int min_pts, DFunc func, void *user_data);

#endif /* dbscan.h */
