void analyzeSimNetProps() {
	const char *eFName = "epidemicRoutingNetEdges.txt";
	const char *pFName = "prophetRoutingNetEdges.txt";

	PNGraph eGraph = TSnap::LoadEdgeListStr<PNGraph>(eFName, 0, 1);
        PNEGraph pGraph = TSnap::LoadEdgeListStr<PNEGraph>(pFName, 0, 1);
        PNGraph randGraph = TSnap::GenRndGnm<PNGraph>(eGraph->GetNodes(), eGraph->GetEdges(), true, TInt::Rnd);

	chdir("dot");

	for (int i=0; i<10; i++) {
		TIntV NIdV;
		for (int j = 0; j < 10; j++) {
			int randNode = eGraph->GetRndNId();
			NIdV.AddUnique(randNode);
		}

		// Plot the mesage propagtion in Endroy-Renyi graphs
		PNGraph randFlow = TSnap::GetSubGraph<PNGraph>(randGraph, NIdV);
		char randf[50]; sprintf(randf,"%d-erdos.dot",i);
                TSnap::SaveGViz(randFlow, randf, TStr("Edros-Renyi random graph"));

		// Now plot epidemic routing
		PNGraph epidemicFlow = TSnap::GetSubGraph<PNGraph>(eGraph, NIdV);
		char epf[50]; sprintf(epf,"%d-epidemic.dot",i);
  		TSnap::SaveGViz(epidemicFlow, epf, TStr("Epidemic routing"));
	}

}
TIntV GetEmailIds(const PXmlTok& QueryXml, const TStr& TagPath)
{
	TIntV EmailIdV;
	TXmlTokV Ids;
	QueryXml->GetTagTokV(TagPath, Ids);
	for (int EmlInd = 0; EmlInd < Ids.Len(); EmlInd++) 
	{
		TInt EmailIdInt = Ids[EmlInd]->GetIntArgVal("id", -1);
		if (EmailIdInt != -1)
			EmailIdV.AddUnique(EmailIdInt);
	}
	return EmailIdV;
}
Ejemplo n.º 3
0
void analyzeSimNetProps(TStr messGraph, TStr netGraph) {
	// Make graphs
	PNGraph eGraph = TSnap::LoadEdgeListStr<PNGraph>(netGraph, 0, 1);
	PNGraph mGraph = TSnap::LoadEdgeListStr<PNGraph>(messGraph, 0, 1);
        PNGraph randGraph = TSnap::GenRndGnm<PNGraph>(mGraph->GetNodes(), mGraph->GetEdges(), true, TInt::Rnd);

	// Induce network graph from the entire network based on message graph
	TIntV NIdV;
	for (TNGraph::TNodeI NI = mGraph->BegNI(); NI < mGraph->EndNI(); NI++)
		NIdV.AddUnique(NI.GetId());
	PNGraph indGraph = TSnap::GetSubGraph<PNGraph>(eGraph, NIdV);

	//printf("%s:: ", messGraph.CStr()); printf("nodes %d; ", indGraph->GetNodes());
	//printf("induced edges %d, random edges %d\n", indGraph->GetEdges(), randGraph->GetEdges());
	printf("%d\t%d\t%d\n", indGraph->GetNodes(), indGraph->GetEdges(), mGraph->GetEdges());
}