godot/ui/graph_view.py
def edge_factory(**row_factory_kw):
    """ Give new edges a unique ID. """

    if "__table_editor__" in row_factory_kw:
        table_editor = row_factory_kw["__table_editor__"]
        graph = table_editor.object
        ID = make_unique_name("node", [node.ID for node in graph.nodes])

        n_nodes = len(graph.nodes)
        IDs = [v.ID for v in graph.nodes]

        if n_nodes == 0:
            tail_node = godot.Node(ID=make_unique_name("n", IDs))
            head_node = godot.Node(ID=make_unique_name("n", IDs))
        elif n_nodes == 1:
            tail_node = graph.nodes[0]
            head_node = godot.Node(ID=make_unique_name("n", IDs))
        else:
            tail_node = graph.nodes[0]
            head_node = graph.nodes[1]

        return godot.edge.Edge(tail_node, head_node, _nodes=graph.nodes)
    else:
        return None
def edge_factory(**row_factory_kw):
    """ Give new edges a unique ID. """

    if "__table_editor__" in row_factory_kw:
        table_editor = row_factory_kw["__table_editor__"]
        graph = table_editor.object
        ID = make_unique_name("node", [node.ID for node in graph.nodes])

        n_nodes = len(graph.nodes)
        IDs = [v.ID for v in graph.nodes]

        if n_nodes == 0:
            tail_node = godot.Node(ID=make_unique_name("n", IDs))
            head_node = godot.Node(ID=make_unique_name("n", IDs))
        elif n_nodes == 1:
            tail_node = graph.nodes[0]
            head_node = godot.Node(ID=make_unique_name("n", IDs))
        else:
            tail_node = graph.nodes[0]
            head_node = graph.nodes[1]

        return godot.edge.Edge(tail_node, head_node, _nodes=graph.nodes)
    else:
        return None
Give new edges a unique ID.