Node Sampling

class RandomNodeSampler(number_of_nodes: int = 100, seed: int = 42)[source]

An implementation of random node sampling. Nodes are sampled with uniform probability. “For details about the algorithm see this paper.”

Parameters
  • number_of_nodes (int) – Number of nodes. Default is 100.

  • seed (int) – Random seed. Default is 42.

sample(graph: Union[networkx.classes.graph.Graph, networkit.graph.Graph])Union[networkx.classes.graph.Graph, networkit.graph.Graph][source]

Sampling nodes randomly.

Arg types:
  • graph (NetworkX or NetworKit graph) - The graph to be sampled from.

Return types:
  • new_graph (NetworkX or NetworKit graph) - The graph of sampled nodes.

class DegreeBasedSampler(number_of_nodes: int = 100, seed: int = 42)[source]

An implementation of degree based sampling. Nodes are sampled proportional to the degree centrality of nodes. “For details about the algorithm see this paper.”

Parameters
  • number_of_nodes (int) – Number of nodes. Default is 100.

  • seed (int) – Random seed. Default is 42.

sample(graph: Union[networkx.classes.graph.Graph, networkit.graph.Graph])Union[networkx.classes.graph.Graph, networkit.graph.Graph][source]

Sampling nodes proportional to the degree.

Arg types:
  • graph (NetworkX or NetworKit graph) - The graph to be sampled from.

Return types:
  • new_graph (NetworkX or NetworKit graph) - The graph of sampled nodes.

class PageRankBasedSampler(number_of_nodes: int = 100, seed: int = 42, alpha: float = 0.85)[source]

An implementation of PageRank based sampling. Nodes are sampled proportional to the PageRank score of nodes. “For details about the algorithm see this paper.”

Parameters
  • number_of_nodes (int) – Number of nodes. Default is 100.

  • seed (int) – Random seed. Default is 42.

sample(graph: Union[networkx.classes.graph.Graph, networkit.graph.Graph])Union[networkx.classes.graph.Graph, networkit.graph.Graph][source]

Sampling nodes randomly proportional to the normalized pagerank score.

Arg types:
  • graph (NetworkX or NetworKit graph) - The graph to be sampled from.

Return types:
  • new_graph (NetworkX or NetworKit graph) - The graph of sampled nodes.