Exemplo n.º 1
0
/* constrainX:
 * Create the X constrains and solve. We use a linear objective function
 * (absolute values rather than squares), so we can reuse network simplex.
 * The constraints are encoded as a dag with edges having a minimum length.
 */
static void constrainX(graph_t* g, nitem* nlist, int nnodes, intersectfn ifn,
                       int ortho)
{
    Dt_t *list = dtopen(&constr, Dtobag);
    nitem *p = nlist;
    graph_t *cg;
    int i;

    for (i = 0; i < nnodes; i++) {
	p->val = p->pos.x;
	dtinsert(list, p);
	p++;
    }
    if (ortho)
	cg = mkConstraintG(g, list, ifn, distX);
    else
	cg = mkNConstraintG(g, list, ifn, distX);
    rank(cg, 2, INT_MAX);

    p = nlist;
    for (i = 0; i < nnodes; i++) {
	int newpos, oldpos, delta;
	oldpos = p->pos.x;
	newpos = ND_rank(p->cnode);
	delta = newpos - oldpos;
	p->pos.x = newpos;
	p->bb.LL.x += delta;
	p->bb.UR.x += delta;
	p++;
    }

    closeGraph(cg);
    dtclose(list);
}
Exemplo n.º 2
0
int main(int argc,char * argv[])
{
	int rc;
	GLMDB_env *genv;
	printf("opening graph!\n");
	rc = openGraph(&genv, "/home/pieter/Downloads/glmdb-blueprints/src/main/native/testdb");
	if (rc != 0) {
		printf("opening graph failure  = %i!\n", rc);
		goto fail;
	}

	rc = addVertexAnd2Properties(genv);
	if (rc != 0) {
		goto fail;
	}

	printf("before traverseEdgeDb\n");
	MDB_txn *txn;
	rc = mdb_txn_begin(genv->env, NULL, 1, &txn);
	if (rc != 0) {
		printf("begin transaction failure  = %i!\n", rc);
		goto fail;
	}

	traverseEdgeDb(genv, txn);

	mdb_txn_commit(txn);

	fail:
	printf("closing graph!\n");
	closeGraph(genv);
	return 0;
}
Exemplo n.º 3
0
main()
{
	int goukei,ninzuu[8],heikin,i;

	goukei = 0;

	for (i=0;i<8;i++)
	{
		printf("%d時の来店者数を入力してください : ",i);
		scanf("%d",&ninzuu[i]);
	}

	for (i=0;i<8;i++)
	{
		goukei += ninzuu[i];
	}

	heikin = goukei / i;

	printf("一日の平均は%d人です。\n",heikin);

        initGraph();

        for(i=0;i<8;i++)
        {
                fillRectangle(i*10,479,i*10+40,479-ninzuu[i],BLACK);
        }

        waitButtonPress();

        closeGraph();

}	
Exemplo n.º 4
0
void MainWindow::drawGraphSlot(QModelIndex ind)
{
    int netAddr = proxyMdl->data(proxyMdl->index(ind.row(), 0)).toInt();
    if((graph[netAddr].size() > 0) && (ind.column() == 2)) {
        graphView = new Form(graph[netAddr]);
        QPoint pos = graphView->mapFromGlobal(QCursor::pos());
        graphView->move(pos.x() - 5, pos.y() - 65);
        graphView->show();
        connect(graphView, SIGNAL(closeGraph()), SLOT(closeSignalGraph()));
    }
}
Exemplo n.º 5
0
/* constrainY:
 * See constrainX.
 */
static void constrainY(graph_t* g, nitem* nlist, int nnodes, intersectfn ifn,
                       int ortho)
{
    Dt_t *list = dtopen(&constr, Dtobag);
    nitem *p = nlist;
    graph_t *cg;
    int i;

    for (i = 0; i < nnodes; i++) {
	p->val = p->pos.y;
	dtinsert(list, p);
	p++;
    }
    if (ortho)
	cg = mkConstraintG(g, list, ifn, distY);
    else
	cg = mkNConstraintG(g, list, ifn, distY);
    rank(cg, 2, INT_MAX);
#ifdef DEBUG
    {
	Agsym_t *mlsym = agedgeattr(cg, "minlen", "");
	Agsym_t *rksym = agnodeattr(cg, "rank", "");
	char buf[100];
	node_t *n;
	edge_t *e;
	for (n = agfstnode(cg); n; n = agnxtnode(cg, n)) {
	    sprintf(buf, "%d", ND_rank(n));
	    agxset(n, rksym->index, buf);
	    for (e = agfstedge(cg, n); e; e = agnxtedge(cg, e, n)) {
		sprintf(buf, "%d", ED_minlen(e));
		agxset(e, mlsym->index, buf);
	    }
	}
    }
#endif

    p = nlist;
    for (i = 0; i < nnodes; i++) {
	int newpos, oldpos, delta;
	oldpos = p->pos.y;
	newpos = ND_rank(p->cnode);
	delta = newpos - oldpos;
	p->pos.y = newpos;
	p->bb.LL.y += delta;
	p->bb.UR.y += delta;
	p++;
    }

    closeGraph(cg);
    dtclose(list);
}
Exemplo n.º 6
0
main(void)
{
	int i;
	int array[10] = {10,102,20,50,64,0,85,50,12,10};

	initGraph();

	for(i=0;i<10;i++)
	{
		fillRectangle(i*10,479,i*10+40,479-array[i],BLACK);
	}

	waitButtonPress();

	closeGraph();
}
Exemplo n.º 7
0
main (void)
{
  initGraph ();

  /* 背景 */
  floodFill (320, 240, BLACK, LIGHTBLUE);
  waitButtonPress ();

  /* 頭 */
  fillEllipse (320, 250, 230, 160, WHITE);

  /* 耳 */
  fillTriangle (130, 40, 90, 250, 250, 92, WHITE);
  fillTriangle (530, 40, 530, 250, 390, 92, WHITE);
  waitButtonPress ();

  /* 目 */
  fillEllipse (200, 290, 15, 20, BLACK);
  fillEllipse (195, 282, 8, 6, WHITE);
  fillEllipse (440, 290, 15, 20, BLACK);
  fillEllipse (435, 282, 8, 6, WHITE);
  waitButtonPress ();

  /* 鼻 */
  fillEllipse (320, 330, 24, 15, YELLOW);
  fillEllipse (315, 322, 9, 6, WHITE);
  waitButtonPress ();

  /* ひげ */
  drawLine (125, 280, 40, 275, BLACK);
  drawLine (130, 300, 50, 305, BLACK);
  drawLine (140, 320, 40, 335, BLACK);

  drawLine (515, 280, 600, 275, BLACK);
  drawLine (510, 300, 590, 305, BLACK);
  drawLine (500, 320, 600, 335, BLACK);
  waitButtonPress ();

  /* リボン */
  fillTriangle (465, 160, 415, 70, 365, 160, RED);
  fillTriangle (465, 160, 515, 250, 565, 160, RED);
  fillCircle (465, 160, 20, RED);
  waitButtonPress ();

  closeGraph ();
}
Exemplo n.º 8
0
main (void)
{
  initGraph ();

  /* 背景 */
  floodFill (320, 240, BLACK, LIGHTBLUE);
  waitButtonPress ();

  /* 頭 */
  fillEllipse (320, 240, 240, 180, WHITE);

  /* 耳 */
  fillEllipse (480, 140, 60, 80, WHITE);
  fillEllipse (160, 140, 60, 80, WHITE);
  waitButtonPress ();

  /* 目 */
  fillEllipse (200, 300, 15, 20, BLACK);
  fillEllipse (440, 300, 15, 20, BLACK);
  waitButtonPress ();

  /* 鼻 */
  fillEllipse (320, 340, 10, 14, YELLOW);
  setLineWidth (2);
  waitButtonPress ();

  /* ひげ */
  drawLine (125, 300, 40, 305, BLACK);
  drawLine (130, 320, 50, 330, BLACK);
  drawLine (140, 340, 40, 355, BLACK);

  drawLine (515, 300, 600, 305, BLACK);
  drawLine (510, 320, 590, 330, BLACK);
  drawLine (500, 340, 600, 355, BLACK);
  waitButtonPress ();

  /* リボン */
  fillTriangle (480, 160, 430, 70, 380, 160, RED);
  fillTriangle (480, 160, 530, 250, 580, 160, RED);
  fillCircle (480, 160, 20, RED);
  waitButtonPress ();

  closeGraph ();
}
Exemplo n.º 9
0
//Do zrobienia(?): przerzuciæ obs³ugê slotów (open, close) do engine'u?
MWindow::MWindow(){
	#ifdef MYDEBUG
		qDebug() << "Startuje konstruktor MWindow()";
	#endif
	//Tworzenie silnika
	engine = new MEngine;
	//Akcje do menu File
	openAction = new QAction(tr("&Otworz graf"), this);
	closeAction = new QAction(tr("&Zamknij graf"), this);
	saveOneAction = new QAction(tr("&Zapisz rezultat"), this);
	//saveAllAction = new QAction(tr("Sa&ve all"), this);
	newWindowAction = new QAction(tr("&Rysuj!"), this); //Tworzy nowe okienko
	exitAction = new QAction(tr("Wyjscie"), this);
	//Akcje do menu Algorithm
	BFSAction = new QAction(tr("BFS"), this);
	DFSAction = new QAction(tr("DFS"), this);
	transposeAction = new QAction(tr("Transponuj"), this);
	toUdirectedAction = new QAction(tr("Symetryzuj"), this);
	stronglyConnectedAction = new QAction(tr("Silnie spojne skladowe"), this);
	graphColoringAction = new QAction(tr("Kolorowanie wierzcholkowe"), this);
	//Akcje do menu About
	displayHelpAction = new QAction(tr("&Pomoc"), this);
	displayAuthorsAction = new QAction(tr("Autorzy"), this);
	displayAboutQtAction = new QAction(tr("Info o Qt"), this);
	//
	closeAction->setEnabled(false);
	saveOneAction->setEnabled(false);
	//saveAllAction->setEnabled(false);
	newWindowAction->setEnabled(false);
	BFSAction->setEnabled(false);
	DFSAction->setEnabled(false);
	transposeAction->setEnabled(false);
	toUdirectedAction->setEnabled(false);
	displayHelpAction->setEnabled(false);
	stronglyConnectedAction->setEnabled(false);
	graphColoringAction->setEnabled(false);
	//
	connect(openAction, SIGNAL(triggered()), this, SLOT(open()));
	connect(closeAction, SIGNAL(triggered()), this , SLOT(closeGraph()));
	connect(saveOneAction, SIGNAL(triggered()), this, SLOT(save()));
	connect(newWindowAction, SIGNAL(triggered()), this, SLOT(openNewWindow()));
	connect(exitAction, SIGNAL(triggered()), this, SLOT(quit()));
	//
	connect(BFSAction, SIGNAL(triggered()), this, SLOT(BFS()));
	connect(DFSAction, SIGNAL(triggered()), this, SLOT(DFS()));
	connect(transposeAction, SIGNAL(triggered()), this, SLOT(transpose()));
	connect(toUdirectedAction, SIGNAL(triggered()), this, SLOT(toUndirected()));
	connect(stronglyConnectedAction, SIGNAL(triggered()), this, SLOT(stronglyConnected()));
	connect(graphColoringAction, SIGNAL(triggered()), this, SLOT(graphColoring()));
	//countOrderAction = new QAction(tr("Count order"), this);
	//checkAdjacencyAction = new QAction(tr("Check adjacency"), this);
	//isSubgraphAction = new QAction(tr("Is subgraph"), this);
	connect(displayAuthorsAction, SIGNAL(triggered()), this, SLOT(authors()));
	connect(displayAboutQtAction, SIGNAL(triggered()), qApp, SLOT(aboutQt()));
	//
	//Dodawanie akcji do MenuBar
	fileMenu = menuBar()->addMenu(tr("&Plik")); 
	fileMenu->addAction(openAction);
	fileMenu->addAction(saveOneAction);
	fileMenu->addAction(newWindowAction);
	fileMenu->addAction(closeAction);
	//fileMenu->addAction(saveAllAction);
	fileMenu->addSeparator();
	fileMenu->addAction(exitAction);
	algorithmMenu = menuBar()->addMenu(tr("Algorytmy"));
	//algorithmMenu->addAction(countOrderAction);
	algorithmMenu->addAction(BFSAction);
	algorithmMenu->addAction(DFSAction);
	algorithmMenu->addSeparator();
	algorithmMenu->addAction(transposeAction);
	algorithmMenu->addAction(toUdirectedAction);
	//algorithmMenu->addAction(stronglyConnectedAction);
	algorithmMenu->addSeparator();
	algorithmMenu->addAction(graphColoringAction);
	//algorithmMenu->addAction(checkAdjacencyAction);
	//algorithmMenu->addAction(isSubgraphAction);
	aboutMenu = menuBar()->addMenu(tr("O programie"));
	aboutMenu->addAction(displayHelpAction);
	aboutMenu->addAction(displayAuthorsAction);
	aboutMenu->addAction(displayAboutQtAction);
	//
	statusBarPtr = statusBar();// Ustawia pasek stanu
	statusBarPtr->showMessage(tr("Gotowy")); //POPRACOWAÆ NAD TYM NP DODAÆ WID¯ET QPROGRESSBAR LUB QLABEL
	//
	centralWidgetPtr = new MCentral;
	setCentralWidget(centralWidgetPtr);	
	//
	secondWindow = NULL; //Inicjalizacja wskaŸnika na nowe okno
	//
	msgBox.setWindowTitle("Autor");
	msgBox.setText(tr("Autor: \nKamil Burzynski.\nAlgorytmy na Grafach 2012\nUKSW"));
	//
	applicationName = tr("AGR v 0.4");
	setWindowTitle(applicationName);
	setMinimumSize(400, 400);
	//
	opened = 0;
	//
	options = NULL;
	#ifdef MYDEBUG
		qDebug() << "Konczy konstruktor MWindow()";
	#endif
}
int main(int argc,char * argv[])
{
	int rc;
	GLMDB_env *genv;
	MDB_txn *txn;
	MDB_cursor *cursor;
	printf("opening graph!\n");
	rc = openGraph(&genv, "/home/pieter/Downloads/thundergraph/src/main/native/testdb");
	if (rc != 0) {
		printf("opening graph failure  = %i!\n", rc);
		goto fail;
	}
	rc = mdb_txn_begin(genv->env, NULL, 1, &txn);
	if (rc != 0) {
		printf("begin transaction failure  = %i!\n", rc);
		goto fail;
	}
	rc = mdb_cursor_open(txn, genv->vertexDb, &cursor);
	if (rc != 0) {
		printf("open cursor failure  = %i!\n", rc);
		goto fail;
	}

	//Add a vertex
	MDB_val vertexKey;
	long long vertexId1 = genv->vertexIdSequence++;
	rc = addVertex(cursor, genv->vertexDb, vertexId1, &vertexKey);
	if (rc != 0) {
		printf("addVertex failure  = %i!\n", rc);
		goto fail;
	}

//	int *vertexPropertyKeyIdSequence = malloc(sizeof(int));
//	char key1[5] = "";
//	sprintf(key1, "%.*s", 4, "key1");
//	rc = setPropertyKey(genv, (MDB_txn *) (long) txn, STRING, vertexPropertyKeyIdSequence, 5, key1, 1, 0, 0);
//	if (rc != 0) {
//		printf("setPropertyKey failure  = %i!\n", rc);
//		goto fail;
//	}
//
//	rc = addOrUpdateStringIndexedProperty(genv, txn, cursor, vertexId1, *vertexPropertyKeyIdSequence, 5, key1, 1);
//
//	//Add a vertex
//	long long vertexId2 = genv->vertexIdSequence++;
//	rc = addVertex(cursor, genv->vertexDb, vertexId2, &vertexKey);
//	if (rc != 0) {
//		printf("addVertex failure  = %i!\n", rc);
//		goto fail;
//	}
//
//	rc = addOrUpdateStringIndexedProperty(genv, txn, cursor, vertexId2, *vertexPropertyKeyIdSequence, 5, key1, 1);
//
//	mdb_cursor_close(cursor);
//	thundergraph_commit(genv, txn);
//
//	printf("traverseVertexPropertyKeyDb\n");
//
//	rc = mdb_txn_begin(genv->env, NULL, 1, &txn);
//	if (rc != 0) {
//		printf("begin transaction failure  = %i!\n", rc);
//		goto fail;
//	}
//
//	rc = traverseVertexPropertyKeyDb(genv, txn);
//
//	if (rc == MDB_NOTFOUND) {
//		printf("traverseVertexDb\n");
//		rc = traverseVertexDb(genv, txn);
//		if (rc == MDB_NOTFOUND) {
//			rc = traverseStringIndexDb(genv, txn, genv->vertexStringIndexDb);
//		}
//	}
//	thundergraph_commit(genv, txn);
//
//	rc = mdb_txn_begin(genv->env, NULL, 1, &txn);
//	if (rc != 0) {
//		printf("begin transaction failure  = %i!\n", rc);
//		goto fail;
//	}
//	rc = mdb_cursor_open(txn, genv->vertexStringIndexDb, &cursor);
//	if (rc != 0) {
//		printf("open cursor failure  = %i!\n", rc);
//		goto fail;
//	}
//
//	rc = deleteStringIndex(genv, txn, *vertexPropertyKeyIdSequence, 1);
//	if (rc != 0) {
//		printf("deleteStringIndex failure  = %i!\n", rc);
//		goto fail;
//	}
//
//	free(vertexPropertyKeyIdSequence);
//
//	//MDB_cursor *cursor, int propertyKeyId, int propertyValueLength, char *value, long long int *vertexIdResultC
//	long long int *vertexIdResultC = malloc(sizeof(long long int));
//	rc = getFirstElementForKeyValueFromStringIndex(cursor, 0, 5, "key1", vertexIdResultC);
//	if (rc == 0) {
//		printf("getFirstVertexForKeyValueFromStringIndex vertexid = %lld\n", *vertexIdResultC);
//
//		rc = getNextElementForKeyValueFromStringIndex(cursor, 0, 5, "key1", vertexIdResultC);
//		if (rc == 0) {
//			printf("getFirstVertexForKeyValueFromStringIndex vertexid = %lld\n", *vertexIdResultC);
//		} else {
//			printf("getNextVertexForKeyValueFromStringIndex %i\n", rc);
//		}
//
//	}


	mdb_cursor_close(cursor);
	thundergraph_commit(genv, txn);
//	free(vertexIdResultC);

	fail:


	printf("closing graph! %i\n", rc);
	closeGraph(genv);
	return 0;
}
int main(int argc,char * argv[])
{
	int rc;
	GLMDB_env *genv;
	MDB_txn *txn;
	MDB_cursor *cursor;
	printf("opening graph!\n");
	rc = openGraph(&genv, "/home/pieter/Downloads/thundergraph/src/main/native/testdb");
	if (rc != 0) {
		printf("opening graph failure  = %i!\n", rc);
		goto fail;
	}
	rc = mdb_txn_begin(genv->env, NULL, 1, &txn);
	if (rc != 0) {
		printf("begin transaction failure  = %i!\n", rc);
		goto fail;
	}
	rc = mdb_cursor_open(txn, genv->vertexDb, &cursor);
	if (rc != 0) {
		printf("open cursor failure  = %i!\n", rc);
		goto fail;
	}

	int vertexPropertyKeyIdSequence = genv->vertexPropertyKeyIdSequence;
	char key1[5] = "";

	sprintf(key1, "%.*s", 4, "key1");
	rc = setPropertyKey(genv, (MDB_txn *) (long) txn, STRING, &vertexPropertyKeyIdSequence, 5, key1, 1, 0, 0);

	sprintf(key1, "%.*s", 4, "key2");
	rc = setPropertyKey(genv, (MDB_txn *) (long) txn, STRING, &vertexPropertyKeyIdSequence, 5, key1, 1, 0, 0);

	sprintf(key1, "%.*s", 4, "key3");
	rc = setPropertyKey(genv, (MDB_txn *) (long) txn, STRING, &vertexPropertyKeyIdSequence, 5, key1, 1, 0, 0);

	sprintf(key1, "%.*s", 4, "key4");
	rc = setPropertyKey(genv, (MDB_txn *) (long) txn, STRING, &vertexPropertyKeyIdSequence, 5, key1, 1, 0, 0);

	sprintf(key1, "%.*s", 4, "key5");
	rc = setPropertyKey(genv, (MDB_txn *) (long) txn, STRING, &vertexPropertyKeyIdSequence, 5, key1, 1, 0, 0);

	sprintf(key1, "%.*s", 4, "key6");
	rc = setPropertyKey(genv, (MDB_txn *) (long) txn, STRING, &vertexPropertyKeyIdSequence, 5, key1, 1, 0, 0);

	sprintf(key1, "%.*s", 4, "key7");
	rc = setPropertyKey(genv, (MDB_txn *) (long) txn, STRING, &vertexPropertyKeyIdSequence, 5, key1, 1, 0, 0);

	sprintf(key1, "%.*s", 4, "key8");
	rc = setPropertyKey(genv, (MDB_txn *) (long) txn, STRING, &vertexPropertyKeyIdSequence, 5, key1, 1, 0, 0);

	sprintf(key1, "%.*s", 4, "key9");
	rc = setPropertyKey(genv, (MDB_txn *) (long) txn, STRING, &vertexPropertyKeyIdSequence, 5, key1, 1, 0, 0);

	sprintf(key1, "%.*s", 4, "key0");
	rc = setPropertyKey(genv, (MDB_txn *) (long) txn, STRING, &vertexPropertyKeyIdSequence, 5, key1, 1, 0, 0);

	mdb_cursor_close(cursor);
	thundergraph_commit(genv, txn);

	printf("traverseVertexPropertyKeyDb\n");

	rc = mdb_txn_begin(genv->env, NULL, 1, &txn);
	if (rc != 0) {
		printf("begin transaction failure  = %i!\n", rc);
		goto fail;
	}

	rc = traverseVertexPropertyKeyDb(genv, txn);

	if (rc == MDB_NOTFOUND) {
		printf("traverseVertexDb\n");
		rc = traverseVertexDb(genv, txn);
	}
	thundergraph_commit(genv, txn);

	fail:
	printf("closing graph! %i\n", rc);
	closeGraph(genv);
	return 0;
}
Exemplo n.º 12
0
int main(int argc,char * argv[])
{
	int rc;
	GLMDB_env *genv;
	printf("opening graph!\n");
	rc = openGraph(&genv, "/home/pieter/Downloads/glmdb-blueprints/src/main/native/testdb");
	if (rc != 0) {
		printf("opening graph failure  = %i!\n", rc);
		goto fail;
	}

	MDB_txn *txn;
	MDB_cursor *cursor;
	rc = mdb_txn_begin(genv->env, NULL, 1, &txn);
	if (rc != 0) {
		printf("begin transaction failure  = %i!\n", rc);
		goto fail;
	}
	rc = mdb_cursor_open(txn, genv->vertexDb, &cursor);
	if (rc != 0) {
		printf("open cursor failure  = %i!\n", rc);
		goto fail;
	}
	MDB_val vertexKey;
	rc = addVertex(cursor, genv->vertexDb, genv->vertexIdSequence++, &vertexKey);
	if (rc != 0) {
		printf("add out vertex failure  = %i!\n", rc);
		goto fail;
	}
	VertexDbId outVertexDbId = (*((VertexDbId *) (vertexKey.mv_data)));
	signed long long outVertexId = outVertexDbId.vertexId;

	char *propertyValue1 = malloc(5);
	char v1[] = "12345";
	memcpy(propertyValue1, v1, 5);
	rc = setVertexPropertyString(cursor, 0, 0, 5, propertyValue1);
	if (rc != 0) {
		printf("setVertexPropertyChar failure  = %i!\n", rc);
		goto fail;
	}

	char *propertyValue2 = malloc(5);
	char v2[] = "12345";
	memcpy(propertyValue2, v2, 5);
	rc = setVertexPropertyString(cursor, 0, 1, 5, propertyValue2);
	if (rc != 0) {
		printf("setVertexPropertyChar failure  = %i!\n", rc);
		goto fail;
	}


	jint *propertyKeyIdSize = (jint *)malloc(sizeof(int));
	jint **propertyKeyId = malloc(sizeof(void *));
	rc = getVertexPropertyKeys(cursor, 0, propertyKeyIdSize, propertyKeyId);
	if (rc != 0 && rc != MDB_NOTFOUND) {
		goto fail;
	}

	int i = 0;
	for (i = 0; i < 10; i = i + 1) {
		rc = addVertex(cursor, genv->vertexDb, genv->vertexIdSequence++, &vertexKey);
		if (rc != 0) {
			printf("add in vertex failure  = %i!\n", rc);
			goto fail;
		}
		VertexDbId inVertexDbId = (*((VertexDbId *) (vertexKey.mv_data)));
		signed long long inVertexId = inVertexDbId.vertexId;
		rc = addEdge(txn, genv->vertexDb, genv->edgeDb, genv->edgeIdSequence++, 0, outVertexId, inVertexId);
		if (rc != 0) {
			printf("add edge failure  = %i!\n", rc);
			goto fail;
		}
		MDB_cursor *edgeCursor;
		rc = mdb_cursor_open(txn, genv->edgeDb, &edgeCursor);
		if (rc != 0) {
			printf("open cursor failure  = %i!\n", rc);
			goto fail;
		}

		char *edgePropertyValue2 = malloc(5);
		char v2[] = "12345";
		memcpy(edgePropertyValue2, v2, 5);

		rc = setEdgePropertyString(edgeCursor, genv->edgeIdSequence - 1, 0, 5, edgePropertyValue2);

		mdb_cursor_close(edgeCursor);

		if (rc != 0) {
			printf("setEdgePropertyChar failure  = %i!\n", rc);
			goto fail;
		}
	}
	mdb_cursor_close(cursor);
	mdb_txn_commit(txn);

	rc = mdb_txn_begin(genv->env, NULL, 1, &txn);
	if (rc != 0) {
		printf("transaction begin = %i!\n", rc);
		goto fail;
	}
	rc = mdb_cursor_open(txn, genv->vertexDb, &cursor);
	if (rc != 0) {
		printf("open cursor failure  = %i!\n", rc);
		goto fail;
	}
	rc = getVertex(cursor, 0LL, &vertexKey);
	if (rc != 0) {
		printf("get vertex failure  = %i!\n", rc);
		goto fail;
	}

	jlong *edgeIdResultC = (jlong *)malloc(sizeof(signed long long));
	jlong *outVertexIdC = (jlong *)malloc(sizeof(signed long long));
	jlong *inVertexIdC = (jlong *)malloc(sizeof(signed long long));

	rc = getFirstEdgefromVertex(cursor, 0, 0, 0LL, edgeIdResultC, outVertexIdC, inVertexIdC);
	if (rc != 0) {
		printf("getFirstEdgefromVertex failure  = %i!\n", rc);
		goto fail;
	}

	rc = getNextEdgefromVertex(cursor, 0, 0, 0LL, edgeIdResultC, outVertexIdC, inVertexIdC);
	if (rc != 0) {
		printf("getNextEdgefromVertex failure  = %i!\n", rc);
		goto fail;
	}

	mdb_cursor_close(cursor);
	mdb_txn_commit(txn);

	rc = mdb_txn_begin(genv->env, NULL, 1, &txn);
	if (rc != 0) {
		printf("transaction begin = %i!\n", rc);
		goto fail;
	}

	printf("before remove traverseVertexDb\n");
	traverseVertexDb(genv, txn);

	printf("before remove traverseEdgeDb\n");
	traverseEdgeDb(genv, txn);

	mdb_txn_commit(txn);

	rc = mdb_txn_begin(genv->env, NULL, 1, &txn);
	if (rc != 0) {
		printf("transaction begin failure = %i!\n", rc);
		goto fail;
	}
	rc = mdb_cursor_open(txn, genv->vertexDb, &cursor);
	if (rc != 0) {
		printf("open cursor failure  = %i!\n", rc);
		goto fail;
	}

//	rc = removeEdge(txn, genv, 9LL);
//	printf("rc = %i\n", rc);
//	rc = removeEdge(txn, genv, 8LL);
//	printf("rc = %i\n", rc);
//	rc = removeEdge(txn, genv, 7LL);
//	printf("rc = %i\n", rc);
//	rc = removeEdge(txn, genv, 6LL);
//	printf("rc = %i\n", rc);
//	rc = removeEdge(txn, genv, 5LL);
//	printf("rc = %i\n", rc);
//	rc = removeEdge(txn, genv, 4LL);
//	printf("rc = %i\n", rc);
//	rc = removeEdge(txn, genv, 3LL);
//	printf("rc = %i\n", rc);
//	rc = removeEdge(txn, genv, 2LL);
//	printf("rc = %i\n", rc);
//	rc = removeEdge(txn, genv, 1LL);
//	printf("rc = %i\n", rc);
//	rc = removeEdge(txn, genv, 0LL);
//	printf("rc = %i\n", rc);

	rc = removeVertex(txn, genv, 10LL);
	rc = removeVertex(txn, genv, 9LL);
	rc = removeVertex(txn, genv, 8LL);
	rc = removeVertex(txn, genv, 7LL);
	rc = removeVertex(txn, genv, 6LL);
	rc = removeVertex(txn, genv, 5LL);
	rc = removeVertex(txn, genv, 4LL);
	rc = removeVertex(txn, genv, 3LL);
	rc = removeVertex(txn, genv, 2LL);
	rc = removeVertex(txn, genv, 1LL);
	rc = removeVertex(txn, genv, 0LL);

//	rc = removeVertex(txn, genv, 0LL);
//	rc = removeVertex(txn, genv, 1LL);
//	rc = removeVertex(txn, genv, 2LL);
//	rc = removeVertex(txn, genv, 3LL);
//	rc = removeVertex(txn, genv, 4LL);
//	rc = removeVertex(txn, genv, 5LL);
//	rc = removeVertex(txn, genv, 6LL);
//	rc = removeVertex(txn, genv, 7LL);
//	rc = removeVertex(txn, genv, 8LL);
//	rc = removeVertex(txn, genv, 9LL);
//	rc = removeVertex(txn, genv, 10LL);


	printf("before traverseVertexDb\n");
	traverseVertexDb(genv, txn);

	printf("before traverseEdgeDb\n");
	traverseEdgeDb(genv, txn);

	mdb_txn_commit(txn);

	fail:
	printf("closing graph!\n");
	closeGraph(genv);
	return 0;
}
Exemplo n.º 13
0
void MainWindow::closeSignalGraph()
{
    disconnect(graphView, SIGNAL(closeGraph()), this, SLOT(closeSignalGraph()));
    delete graphView;
}