1107. Social Clusters (30)

本文详细介绍了并查集算法的基本概念、实现原理及应用案例。通过具体代码实例展示了如何利用并查集解决实际问题,包括初始化、查找、合并等核心操作。

考前训练之并查集:

#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
const int MAX = 1010;
vector<int> firsthob;
int father[MAX];
int root[MAX]={0};
void initfather(){
	for(int i=0;i<MAX;i++){
		father[i]=i;
	}
}
int findfather(int x){
	if(x==father[x]) return x;
	else{
		int F=findfather(father[x]);
		father[x]=F;
		return F;
	}
}
void Union(int a,int b){
	int Afa=findfather(a);
	int Bfa=findfather(b);
	if(Afa!=Bfa){
		father[Afa]=Bfa;
	}
}
bool compare(int a,int b){
	if(a>b) return true;
	else return false;
}
int main(){
	initfather();
	int n;
	cin>>n;
	for(int i=0;i<n;i++){
		int numhobs,tempfirsthob;
		scanf("%d",&numhobs);
		getchar();
		getchar();
		scanf("%d",&tempfirsthob);
		firsthob.push_back(tempfirsthob);
		for(int j=0;j<numhobs-1;j++){
			int temphob;
			scanf("%d",&temphob);
			Union(tempfirsthob,temphob);
		}
	}
	for(int i=0;i<n;i++){
		int temproot=findfather(firsthob[i]);
		root[temproot]++;
	}
	sort(root,root+MAX,compare);
	int count=0;
	while(root[count++]!=0);
	count--;
	cout<<count<<endl;
	for(int i=0;i<count;i++){
		if(i!=0) printf(" ");
		printf("%d",root[i]);
	}
}
 


HR-MS/MS raw data files were converted from .RAW to .mzXML file format using the Trans-Proteomic pipeline (Institute for Systems Biology, Seattle) [80], and clustered with MS-Cluster using Global Natural Products Social (GNPS) Molecular Networking [42,81,82,83]. A molecular network was created using the online workflow at GNPS. The data was filtered by removing all MS/MS peaks within ±17 Da of the precursor m/z. MS/MS spectra were window filtered by choosing only the top 6 peaks in the ±50 Da window throughout the spectrum. The data were then clustered with MS-Cluster with a parent mass tolerance of 2.0 Da and a MS/MS fragment ion tolerance of 0.5 Da to create consensus spectra. Further, consensus spectra that contained less than 1 spectra were discarded. A network was then created where edges were filtered to have a cosine score above 0.7 and more than 6 matched peaks. Further edges between two nodes were kept in the network if and only if each of the nodes appeared in each other’s respective top 10 most similar nodes. The spectra in the network were then searched against GNPS’s spectral libraries. The library spectra were filtered in the same manner as the input data. All matches kept between network spectra and library spectra were required to have a score above 0.7 and at least 6 matched peaks. To visualise the data, they were imported into Cytoscape suite (Version 3.0.2)[84] from this visualisation software, and nodes and edges were displayed (nodes correspond to a specific consensus spectrum; edges represent significant pairwise alignment between nodes). Cosine similarity scores, range from 0 to 1 (1 being identical spectra), were computationally combined as consensus spectra if more than six ion fragmentation spectra matched. A minimum cosine score of 0.7 was selected to subdue the clustering of different compound classes under the same molecular family when visualising the data as a network of nodes connected by edges [85]. Rarefaction curves portraying the diversity of MS/MS spectra were computed (with clusters affected equaling the number of clusters of which the file is a constituent) using GNPS [81].这一段使用了什么方法,详细说明该步骤
最新发布
08-31
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值