[GB.DATA]

* BUG: GraphMatrix.Add() does not add identical vertices multiple times
  anymore.



git-svn-id: svn://localhost/gambas/trunk@6752 867c0c6c-44f3-4631-809d-bfa615b0a4ec
This commit is contained in:
Tobias Boege 2014-12-19 17:57:18 +00:00
parent 09aa29fb9b
commit 4c704fd2d5

View file

@ -380,20 +380,24 @@ static void update_gsl_matrix(CMATRIX *mat, unsigned i, unsigned j)
BEGIN_METHOD(Matrix_Add, GB_STRING name)
unsigned int count = GB.Count(THIS->matrix), i;
unsigned int vert = get_vertex(THIS, STRING(name), LENGTH(name)), i;
VERT *new;
if (vert != -1)
goto end;
vert = GB.Count(THIS->matrix);
new = GB.Add(&THIS->matrix);
/* Add edge buffers to all other vertices */
for (i = 0; i < count; i++) {
for (i = 0; i < vert; i++) {
EDGE *e = GB.Add(&THIS->matrix[i].edges);
e->set = 0;
e->weight = 0;
}
GB.NewArray(&new->edges, sizeof(*new->edges), count + 1);
GB.NewArray(&new->edges, sizeof(*new->edges), vert + 1);
/* No outgoing edges */
memset(new->edges, 0, (count + 1) * sizeof(*new->edges));
memset(new->edges, 0, (vert + 1) * sizeof(*new->edges));
new->val.type = GB_T_NULL;
GB.StoreVariant(NULL, &new->val);
@ -401,11 +405,12 @@ BEGIN_METHOD(Matrix_Add, GB_STRING name)
new->name = GB.NewString(STRING(name), LENGTH(name));
GB.HashTable.Add(THIS->names, STRING(name), LENGTH(name),
(void *) (intptr_t) count);
THIS->v.vertex = count;
(void *) (intptr_t) vert);
invalidate_gsl_matrix(THIS);
end:
THIS->v.vertex = vert;
GB.ReturnSelf(THIS);
END_METHOD