edge_count¶
Syntax¶
Parameters¶
network- The network to find the edge count for.
Returns¶
Returns the number of edges in a given graph.
Description¶
Returns the total number of edges in the network parameter.
Note
If the graph is directed, an edge from node A to node B is treated separately from an edge from node B to node A. If the graph is undirected, the edges are considered to be the same.
Examples¶
simulation {
start_date = 2020-Jan-01
end_date = 2020-Jan-01
locations = none
default_model = none
}
network my_directed_network {
is_directed = 1
}
network my_undirected_network {
is_directed = 0
}
condition TestCondition {
start_state = Excluded
meta_start_state = MetaStart
state MetaStart {
# Make complete triangular graph
add_edge(my_directed_network, 1, 2)
add_edge(my_directed_network, 2, 1)
add_edge(my_directed_network, 2, 3)
add_edge(my_directed_network, 3, 2)
add_edge(my_directed_network, 3, 1)
add_edge(my_directed_network, 1, 3)
print("edge_count is 6 == ", edge_count(my_directed_network))
#######################################################################
# Make complete triangular graph
add_edge(my_undirected_network, 1, 2)
add_edge(my_undirected_network, 2, 3)
add_edge(my_undirected_network, 3, 1)
# This line would have no effect since the graph is undirected and an
# edge between these nodes already exists.
add_edge(my_undirected_network, 1, 3)
print("edge_count is 3 == ", edge_count(my_undirected_network))
wait(0)
default(Excluded)
}
}