Graph graphx_triangle_count¶
-
graphx_triangle_count
(self, output_property, input_edge_labels=None)¶ Number of triangles among vertices of current graph.
Parameters: output_property : unicode
The name of output property to be added to vertex/edge upon completion.
input_edge_labels : list (default=None)
The name of edge labels to be considered for triangle count. Default is all edges are considered.
Returns: : dict
dict(label, Frame).
Dictionary containing the vertex type as the key and the corresponding vertex’s frame with a triangle_count column. Call dictionary_name[‘label’] to get the handle to frame whose vertex type is label.
** Experimental Feature **
Counts the number of triangles among vertices in an undirected graph. If an edge is marked bidirectional, the implementation opts for canonical orientation of edges hence counting it only once (similar to an undirected graph).
Examples
>>> graph = ta.Graph()
>>> graph.define_vertex_type('source') [===Job Progress===] >>> graph.vertices['source'].add_vertices(vertex_frame, 'source', 'label') [===Job Progress===] >>> graph.define_edge_type('edges','source', 'source', directed=False) [===Job Progress===] >>> graph.edges['edges'].add_edges(edge_frame, 'source', 'dest', ['weight']) [===Job Progress===] >>> result = graph.graphx_triangle_count(output_property = "triangle_count") [===Job Progress===] >>> result['source'].inspect() [#] _vid _label source label triangle_count ================================================ [0] 5 source 5 5.0 0 [1] 1 source 1 1.0 1 [2] 2 source 2 1.0 1 [3] 3 source 3 5.0 1 [4] 4 source 4 5.0 0
>>> graph.edges['edges'].inspect() [#] _eid _src_vid _dest_vid _label weight ============================================== [0] 6 1 2 edges 1 [1] 7 1 3 edges 1 [2] 9 1 4 edges 1 [3] 8 2 3 edges 1 [4] 10 4 5 edges 1