Skip to content

get_weight

Syntax

get_weight(network, source_node_id, dest_node_id)

Parameters

network
The network in which to search for an edge.
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.

Returns

Returns the weight of the edge.

Description

Returns the weight of an edge that exists between two nodes in a network. If the weight is not set explicitly, it will default to 1.

If no edge is found, an error will occur.

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 {
        set_weight(my_network, 1, 2, 999)
        print("Weight is: ", get_weight(my_network, 1, 2))

        wait(0)
        default(Excluded)
    }
}

Prints:

Weight is: 999

See Also