Skip to content

delete_edge

Syntax

delete_edge(network, source_node_id, dest_node_id)

Parameters

network
The name of a network.
source_node_id
The ID of the source node to find an edge on.
dest_node_id
The ID of the destination node to find an edge on.

Description

Deletes an edge from a network between the specified source and destination nodes. If no edge is found between the source and destination nodes, then the action is ignored.

Note

In a directed network, deleting an edge from node A to node B is not the same as deleting an edge from node B to node A. In an undirected network however, they are the same.

Examples

simulation {
    start_date = 2020-Jan-01
    end_date = 2020-Jan-01
    locations = none
    default_model = none
}

network my_network {
    is_directed = 1
}

condition TestCondition {
    start_state = Excluded
    meta_start_state = MetaStart

    state MetaStart {
        add_edge(my_network, 1, 2)
        print("Expect 1 == ", has_edge_from(my_network, 1, 2))
        print("Expect 0 == ", has_edge_from(my_network, 2, 1))

        add_edge(my_network, 2, 1)
        print("Expect 1 == ", has_edge_from(my_network, 1, 2))
        print("Expect 1 == ", has_edge_from(my_network, 2, 1))

        delete_edge(my_network, 1, 2)
        print("Expect 0 == ", has_edge_from(my_network, 1, 2))
        print("Expect 1 == ", has_edge_from(my_network, 2, 1))

        wait(0)
        default(Excluded)
    }
}

See Also