PlotShortPathDistr

PlotShortPathDistr(FNmPref, DescStr, TestNodes=TInt.Mx)

A graph method that plots the distribution of the shortest path lengths in a graph. The implementation is based on BFS. The function creates three new files: 1) diam.<FNmPref>.plt (the commands used to create the plot), 2) diam.<FNPref>.png (the plot), and 3) diam.<FNmPref>.tab (the plotting data).

Parameters:

  • FNmPref: string

    A string representing the preferred output file name.

  • DescStr: string

    Description of the graph. The string should be non-empty.

  • TestNodes: int

    Number of nodes from which to start BFS to count shortest path lengths. If TestNodes is less than the total number of graph nodes, then the plot may only be an approximation of the distribution of the shortest path lengths.

Return value:

  • None

The following example shows how to generate plots of the distribution of shortest path lengths for TNGraph, TUNGraph, and TNEANet:

import snap

Graph = snap.GenRndGnm(snap.TNGraph, 100, 1000)
Graph.PlotShortPathDistr("example", "Directed graph - shortest path")

UGraph = snap.GenRndGnm(snap.TUNGraph, 100, 1000)
UGraph.PlotShortPathDistr("example", "Undirected graph - shortest path")

Network = snap.GenRndGnm(snap.TNEANet, 100, 1000)
Network.PlotShortPathDistr("example", "Network - shortest path")