turicreate.SGraph.get_vertices

SGraph.get_vertices(self, ids=list(), fields={}, format='sframe')

Return a collection of vertices and their attributes.

Parameters:
ids : list [int | float | str] or SArray

List of vertex IDs to retrieve. Only vertices in this list will be returned. Also accepts a single vertex id.

fields : dict | pandas.DataFrame

Dictionary specifying equality constraint on field values. For example {'gender': 'M'}, returns only vertices whose ‘gender’ field is ‘M’. None can be used to designate a wild card. For example, {‘relationship’: None} will find all vertices with the field ‘relationship’ regardless of the value.

format : {‘sframe’, ‘list’}

Output format. The SFrame output (default) contains a column __src_id with vertex IDs and a column for each vertex attribute. List output returns a list of Vertex objects.

Returns:
out : SFrame or list [Vertex]

An SFrame or list of Vertex objects.

See also

Vertex, get_edges

Examples

Return all vertices in the graph.

>>> from turicreate import SGraph, Vertex
>>> g = SGraph().add_vertices([Vertex(0, attr={'gender': 'M'}),
                               Vertex(1, attr={'gender': 'F'}),
                               Vertex(2, attr={'gender': 'F'})])
>>> g.get_vertices()
+------+--------+
| __id | gender |
+------+--------+
|  0   |   M    |
|  2   |   F    |
|  1   |   F    |
+------+--------+

Return vertices 0 and 2.

>>> g.get_vertices(ids=[0, 2])
+------+--------+
| __id | gender |
+------+--------+
|  0   |   M    |
|  2   |   F    |
+------+--------+

Return vertices with the vertex attribute “gender” equal to “M”.

>>> g.get_vertices(fields={'gender': 'M'})
+------+--------+
| __id | gender |
+------+--------+
|  0   |   M    |
+------+--------+