turicreate.kcore.create(graph, kmin=0, kmax=10, verbose=True)

Compute the K-core decomposition of the graph. Return a model object with total number of cores as well as the core id for each vertex in the graph.

graph : SGraph

The graph on which to compute the k-core decomposition.

kmin : int, optional

Minimum core id. Vertices having smaller core id than kmin will be assigned with core_id = kmin.

kmax : int, optional

Maximum core id. Vertices having larger core id than kmax will be assigned with core_id=`kmax`.

verbose : bool, optional

If True, print progress updates.

out : KcoreModel

See also




If given an SGraph g, we can create a KcoreModel as follows:

>>> g = turicreate.load_sgraph('http://snap.stanford.edu/data/email-Enron.txt.gz', format='snap')
>>> kc = turicreate.kcore.create(g)

We can obtain the core id corresponding to each vertex in the graph g using:

>>> kcore_id = kc['core_id']     # SFrame

We can add the new core id field to the original graph g using:

>>> g.vertices['core_id'] = kc['graph'].vertices['core_id']

Note that the task above does not require a join because the vertex ordering is preserved through create().