コード例 #1
0
/*
	Function to create graph and return
	an instance
*/
Graph * createGraph( User * userList, int numUsers, float delta1 )
{
	Graph * graph = NULL;
	int i, j;

	//	Allocate memory
	graph = malloc( sizeof( Graph ) );
	graph -> relationMatrix = malloc( sizeof( Relation * ) * numUsers );
	for( i = 0; i < numUsers; i++ )
	{
		graph -> relationMatrix[i] = malloc( sizeof( Relation ) * numUsers );
	}

	graph -> userList = userList;
	graph -> numUsers = numUsers;
	graph -> Lmax = 0;
	graph -> friendshipThreshold = delta1;

	//	Create relation matrix
	for( i = 0; i < numUsers; i++ )
	{
		for( j = 0; j < numUsers; j++ )
		{
			createRelationMatrix( &( graph -> relationMatrix[i][j] ),
					graph -> userList[i], graph -> userList[j] );

			if( graph -> relationMatrix[i][j].Uab > graph -> Lmax )
			{
				graph -> Lmax = graph -> relationMatrix[i][j].Uab;
			}
		}
	}

	//	Create friendships based on
	for( i = 0; i < numUsers; i++ )
	{
		for( j = 0; j < numUsers; j++ )
		{
			if ( i != j )
			{
				createFriendship( &(graph -> relationMatrix[i][j] ),
					graph -> friendshipThreshold, graph -> Lmax );
			}
		}
	}

	return graph;
}
コード例 #2
0
ファイル: UserMgmtWidget.cpp プロジェクト: artikz/qwit
void UserMgmtWidget::follow(QString screenName, UserMgmtWidgetItem *item)
{
    emit createFriendship(screenName, item);
}