# Graph attributes¶

 Edge length of the given graph. Vertex area of the given graph. attribute_vertex_coordinates(graph, shape) Coordinates of the vertices of the given grid graph. List of leaf nodes inside the sub-tree rooted in a node. attribute_vertex_perimeter(graph[, edge_length]) Vertex perimeter of the given graph.
attribute_edge_length(graph)[source]

Edge length of the given graph.

In general the length of an edge if simply equal to 1. But, if the graph is a region adjacency graph then the length of an edge is equal to the sum of length of the corresponding edges in the original graph (obtained with a recursive call to attribute_edge_length on the original graph).

Parameters

graph – input graph

Returns

a nd array

Auto-cache: This function is decorated with the auto_cache() decorator.

attribute_vertex_area(graph)[source]

Vertex area of the given graph.

In general the area of a vertex if simply equal to 1. But, if the graph is a region adjacency graph then the area of a region is equal to the sum of the area of the vertices inside the region (obtained with a recursive call to attribute_vertex_area on the original graph).

Parameters

graph – input graph

Returns

a 1d array

Auto-cache: This function is decorated with the auto_cache() decorator.

attribute_vertex_coordinates(graph, shape)[source]

Coordinates of the vertices of the given grid graph.

Example

>>> g = hg.get_4_adjacency_graph((2, 3))
>>> c = hg.attribute_vertex_coordinates(g)
(((0, 0), (0, 1), (0, 2)),
((1, 0), (1, 1), (1, 2)))

Parameters
Returns

a nd array

Auto-cache: This function is decorated with the auto_cache() decorator.

attribute_vertex_list(tree)[source]

List of leaf nodes inside the sub-tree rooted in a node.

WARNING: This function is slow and will use O(n²) space, with n the number of leaf nodes !

SHOULD ONLY BE USED FOR DEBUGGING AND TESTING

Parameters

tree – input tree

Returns

a list of lists

Auto-cache: This function is decorated with the auto_cache() decorator.

attribute_vertex_perimeter(graph, edge_length=None)[source]

Vertex perimeter of the given graph. The perimeter of a vertex is defined as the sum of the length of out-edges of the vertex.

If the input graph has an attribute value no_border_vertex_out_degree, then each vertex perimeter is assumed to be equal to this attribute value. This is a convenient method to handle image type graphs where an outer border has to be considered.

Parameters
Returns

a nd array

Auto-cache: This function is decorated with the auto_cache() decorator.