SGraph.get_neighborhood(self, ids, radius=1, full_subgraph=True)

Retrieve the graph neighborhood around a set of vertices, ignoring edge directions. Note that setting radius greater than two often results in a time-consuming query for a very large subgraph.

ids : list [int | float | str]

List of target vertex IDs.

radius : int, optional

Radius of the neighborhood. Every vertex in the returned subgraph is reachable from at least one of the target vertices on a path of length no longer than radius. Setting radius larger than 2 may result in a very large subgraph.

full_subgraph : bool, optional

If True, return all edges between vertices in the returned neighborhood. The result is also known as the subgraph induced by the target nodes’ neighbors, or the egocentric network for the target nodes. If False, return only edges on paths of length <= radius from the target node, also known as the reachability graph.

out : Graph

The subgraph with the neighborhoods around the target vertices.



>>> sf_edge = turicreate.SFrame({'source': range(9), 'dest': range(1, 10)})
>>> g = turicreate.SGraph()
>>> g = g.add_edges(sf_edge, src_field='source', dst_field='dest')
>>> subgraph = g.get_neighborhood(ids=[1, 7], radius=2,