8 for (
int i = 0; i < 10; i++) {
10 for (
int i = 0; i < 10; i++) {
11 Graph->AddEdge(i,
TInt::Rnd.GetUniDevInt(10)); }
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++) {
45 DirectedGraph->AddNode(i);
48 DirectedGraph->AddEdge(0, 1);
49 DirectedGraph->AddEdge(1, 2);
50 DirectedGraph->AddEdge(2, 3);
51 DirectedGraph->AddEdge(3, 4);
52 DirectedGraph->AddEdge(4, 5);
53 DirectedGraph->AddEdge(5, 6);
54 DirectedGraph->AddEdge(6, 7);
55 DirectedGraph->AddEdge(7, 2);
56 DirectedGraph->AddEdge(8, 9);
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);
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().
static PNet New()
Static constructor that returns a pointer to the network. Call: TPt > Net = TNodeEDatNet::New().
Statistics of a Graph Snapshot.
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:
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.