Graphviz 12.0.1~dev.20240716.0800
Loading...
Searching...
No Matches
call_tri.c
Go to the documentation of this file.
1/*************************************************************************
2 * Copyright (c) 2011 AT&T Intellectual Property
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Eclipse Public License v1.0
5 * which accompanies this distribution, and is available at
6 * https://www.eclipse.org/legal/epl-v10.html
7 *
8 * Contributors: Details at https://graphviz.org
9 *************************************************************************/
10
11#include "config.h"
12#include <cgraph/alloc.h>
13#include <sparse/SparseMatrix.h>
14#include <neatogen/call_tri.h>
15#include <neatogen/delaunay.h>
16#include <stddef.h>
17#include <stdbool.h>
18
19SparseMatrix call_tri(int n, double *x) {
20 double one = 1;
21 int i, ii, jj;
24 int* edgelist = NULL;
25 double* xv = gv_calloc(n, sizeof(double));
26 double* yv = gv_calloc(n, sizeof(double));
27 int numberofedges = 0;
28
29 for (i = 0; i < n; i++) {
30 xv[i] = x[i * 2];
31 yv[i] = x[i * 2 + 1];
32 }
33
34 if (n > 2) {
35 edgelist = delaunay_tri (xv, yv, n, &numberofedges);
36 }
37
39 for (i = 0; i < numberofedges; i++) {
40 ii = edgelist[i * 2];
41 jj = edgelist[i * 2 + 1];
43 }
44 if (n == 2) { /* if two points, add edge i->j */
45 ii = 0;
46 jj = 1;
48 }
49 for (i = 0; i < n; i++) {
51 }
54 A = SparseMatrix_symmetrize(B, false);
56 B = A;
57
58 free (edgelist);
59 free (xv);
60 free (yv);
61 return B;
62}
63
64SparseMatrix call_tri2(int n, int dim, double * xx)
65{
66 v_data *delaunay;
67 int i, j;
70 double one = 1;
71 double *x = gv_calloc(n, sizeof(double));
72 double *y = gv_calloc(n, sizeof(double));
73
74 for (i = 0; i < n; i++) {
75 x[i] = xx[dim * i];
76 y[i] = xx[dim * i + 1];
77 }
78
79 delaunay = UG_graph(x, y, n);
80
82
83 for (i = 0; i < n; i++) {
84 for (j = 1; j < delaunay[i].nedges; j++) {
85 SparseMatrix_coordinate_form_add_entry(A, i, delaunay[i].edges[j], &one);
86 }
87 }
88 for (i = 0; i < n; i++) {
90 }
92 {
95 B = tmp;
96 }
98
99 free (x);
100 free (y);
101 freeGraph (delaunay);
102
103 return B;
104
105}
106
SparseMatrix SparseMatrix_from_coordinate_format(SparseMatrix A)
SparseMatrix SparseMatrix_symmetrize(SparseMatrix A, bool pattern_symmetric_only)
SparseMatrix SparseMatrix_coordinate_form_add_entry(SparseMatrix A, int irn, int jcn, const void *val)
void SparseMatrix_delete(SparseMatrix A)
SparseMatrix SparseMatrix_new(int m, int n, int nz, int type, int format)
@ FORMAT_COORD
@ MATRIX_TYPE_REAL
Memory allocation wrappers that exit on failure.
static void * gv_calloc(size_t nmemb, size_t size)
Definition alloc.h:26
SparseMatrix call_tri2(int n, int dim, double *xx)
Definition call_tri.c:64
SparseMatrix call_tri(int n, double *x)
Definition call_tri.c:19
void freeGraph(v_data *graph)
Definition delaunay.c:852
v_data * UG_graph(double *x, double *y, int n)
Definition delaunay.c:785
int * delaunay_tri(double *x, double *y, int n, int *nedges)
Definition delaunay.c:756
#define A(n, t)
Definition expr.h:76
void free(void *)
node NULL
Definition grammar.y:149
#define B
Definition hierarchy.c:117
Definition cdt.h:104
int nedges
Definition sparsegraph.h:22