GraphVertex

Inherits: Object

A data structure used to represent a vertex in a Graph.

Description

A vertex holds a data and information about all neighbor vertices that are connected to it. To traverse all neighbors, use get_neighbors:

for n in v.get_neighbors():
    print(n)

You can also use a built-in (GDScript) iterator to traverse all neighbors (may be slower):

for n in v:
    print(n)

For enumerating edges instead of vertices, use get_edges:

for e in v.get_edges():
    print(e.a, " ", e.b)

If you need to traverse the graph without producing duplicates, you may also consider using graph’s default Graph.iterator.

You can call Object.free to remove this vertex from the Graph it belongs to.

Properties

Variant value

Property Descriptions

Setter set_value(value)
Getter get_value()

Vertex data (could a label, a list of attributes etc).

Method Descriptions

  • Array get_edges ( ) const

Returns all GraphEdges associated with this vertex, including incoming and outgoing edges, see get_incoming_edges and get_outgoing_edges methods.


  • Graph get_graph ( ) const

Returns the master Graph that instantiated and manages this vertex.


  • Array get_incoming_edges ( ) const

Returns all GraphEdges that point from predecessor vertices.


  • int get_neighbor_count ( ) const

Returns the total number of neighbor vertices.


  • Array get_neighbors ( ) const

Returns a list of all GraphVertex neighbors.


  • Array get_outgoing_edges ( ) const

Returns all GraphEdges that point to successor vertices.


  • int get_predecessor_count ( ) const

Returns the total number of predecessor vertices.


  • Array get_predecessors ( ) const

Returns a list of all GraphVertex predecessors (vertices that point to this one).


  • int get_successor_count ( ) const

Returns the total number of successor vertices.


  • Array get_successors ( ) const

Returns a list of all GraphVertex successors (vertices that point away from this one).