Function NetworKit::GraphTools::subgraphAndNeighborsFromNodes

Function Documentation

Graph NetworKit::GraphTools::subgraphAndNeighborsFromNodes(const Graph &G, const std::unordered_set<node> &nodes, bool includeOutNeighbors = false, bool includeInNeighbors = false)

Returns an induced subgraph of this graph (including potential edge weights/directions)

There a two relevant sets of nodes:

  • Nodes are such passed as arguments.

  • Neighbors are empty by default.

The subgraph contains all nodes in Nodes + Neighbors and all edges which have one end point in Nodes and the other in Nodes or Neighbors.

Parameters:
  • G – The input graph.

  • nodes – Nodes of the induced subgraph.

  • includeOutNeighbors – If set to true, all out-neighbors will also be included.

  • includeInNeighbors – If set to true, all in-neighbors will also be included (relevant only for directed graphs).

Returns:

Induced subgraph.