Node

class Node[source]

Bases: supervisely.io.json.JsonSerializable

Node for a single GraphNodes.

Parameters
location : PointLocation

PointLocation object.

disabled : bool, optional

Determines whether to display the Node when drawing or not.

label : Optional[str]

str

row : Optional[int]

int

col : Optional[int]

int

Usage example
import supervisely as sly
from supervisely.geometry.graph import Node

vertex = Node(sly.PointLocation(5, 5))

Methods

from_json

Convert a json dict to Node.

to_json

Convert the Node to a json dict.

transform_location

param transform_fn

function to convert location

Attributes

disabled

Display the Node when drawing or not.

location

Location of Node.

classmethod from_json(data)[source]

Convert a json dict to Node. Read more about Supervisely format.

Parameters
data : dict

Node in json format as a dict.

Returns

Node object

Return type

Node

Usage example
vertex_json = {
    "loc": [5, 5]
}
vertex = Node.from_json(vertex_json)
to_json()[source]

Convert the Node to a json dict. Read more about Supervisely format.

Returns

Json format as a dict

Return type

dict

Usage example
import supervisely as sly
from supervisely.geometry.graph import Node

vertex = Node(sly.PointLocation(5, 5))
vertex_json = vertex.to_json()
print(vertex_json)
# Output: {
#    "loc": [5, 5]
# }
transform_location(transform_fn)[source]
Parameters
transform_fn

function to convert location

Returns

Node class object with the changed location attribute using the given function

property disabled

Display the Node when drawing or not.

Returns

Boolean

Return type

bool

property location

Location of Node.

Returns

PointLocation object

Return type

PointLocation