turicreate.degree_counting.create¶
-
turicreate.degree_counting.
create
(graph, verbose=True)¶ Compute the in degree, out degree and total degree of each vertex.
Parameters: - graph : SGraph
The graph on which to compute degree counts.
- verbose : bool, optional
If True, print progress updates.
Returns: - out : DegreeCountingModel
See also
Examples
If given an
SGraph
g
, we can create aDegreeCountingModel
as follows:>>> g = turicreate.load_sgraph('http://snap.stanford.edu/data/web-Google.txt.gz', ... format='snap') >>> m = turicreate.degree_counting.create(g) >>> g2 = m['graph'] >>> g2 SGraph({'num_edges': 5105039, 'num_vertices': 875713}) Vertex Fields:['__id', 'in_degree', 'out_degree', 'total_degree'] Edge Fields:['__src_id', '__dst_id']
>>> g2.vertices.head(5) Columns: __id int in_degree int out_degree int total_degree int Rows: 5 Data: +------+-----------+------------+--------------+ | __id | in_degree | out_degree | total_degree | +------+-----------+------------+--------------+ | 5 | 15 | 7 | 22 | | 7 | 3 | 16 | 19 | | 8 | 1 | 2 | 3 | | 10 | 13 | 11 | 24 | | 27 | 19 | 16 | 35 | +------+-----------+------------+--------------+