8 for (
int i = 0; i < 10; i++) {
10 for (
int i = 0; i < 10; i++) {
15 Graph = TSnap::LoadEdgeList<PNGraph>(
"graph.txt", 0, 1);
18 printf(
"NodeId: %d, InDegree: %d, OutDegree: %d\n", NI.GetId(), NI.GetInDeg(), NI.GetOutDeg());
20 for (
int e = 0; e < NI.GetOutDeg(); e++) { printf(
" %d", NI.GetOutNId(e)); }
21 printf(
"\nInNodes: ");
22 for (
int e = 0; e < NI.GetInDeg(); e++) { printf(
" %d", NI.GetInNId(e)); }
30 PNGraph RndGraph = TSnap::GenRndGnm<PNGraph>(100, 1000);
32 GraphStat.PlotAll(
"RndGraph",
"Random graph on 1000 nodes");
34 {
TFfGGen ForestFire(
false, 1, 0.35, 0.30, 1.0, 0.0, 0.0);
35 ForestFire.GenGraph(100);
36 PNGraph FfGraph = ForestFire.GetGraph(); }
39 Net->AddNode(0,
"zero");
40 Net->AddNode(1,
"one");
41 Net->AddEdge(0, 1,
"zero to one");
44 for (
int i = 0; i < 10; i++) {
62 printf(
"Testing Betweenness Centrality Calculation \n");
63 TSnap::GetBetweennessCentr<PNGraph> (DirectedGraph, nodeBtwH, edgeBtwH,
true);
65 int node_id = It.GetKey();
66 double centr = It.GetDat();
67 printf(
"NodeId: %d, Centr: %f \n", node_id, centr);
TNodeI BegNI() const
Returns an iterator referring to the first node in the graph.
PGraph GetMxWcc(const PGraph &Graph)
Returns a graph representing the largest weakly connected component on an input Graph.
static PNGraph New()
Static constructor that returns a pointer to the graph. Call: PNGraph Graph = TNGraph::New().
int AddNode(int NId=-1)
Adds a node of ID NId to the graph.
static PNet New()
Static constructor that returns a pointer to the network. Call: TPt > Net = TNodeEDatNet::New().
Statistics of a Graph Snapshot.
int AddEdge(const int &SrcNId, const int &DstNId)
Adds an edge from node SrcNId to node DstNId to the graph.
void SaveEdgeList(const PGraph &Graph, const TStr &OutFNm, const TStr &Desc=TStr())
Saves a graph into a text file. Each line contains two columns and encodes a single edge:
TNodeI EndNI() const
Returns an iterator referring to the past-the-end node in the graph.
Node iterator. Only forward iteration (operator++) is supported.
void PrintInfo(const PGraph &Graph, const TStr &Desc="", const TStr &OutFNm="", const bool &Fast=true)
Prints basic graph statistics.