### Navigation

- index
- modules |
- modules |
- next |
- previous |
- FNSS 0.6.0 documentation »
- API Reference »
- Functions »

# fnss.traffic.trafficmatrices.link_loads

`link_loads`(topology, traffic_matrix, routing_matrix=None)

  Calculate link utilization given a traffic matrix.

  Return a dictionary mapping for each link of a topology, the relative link utilization (i.e. traffic volume divided by link capacity) given a traffic matrix. The keys of the dictionary are (u, v) tuple where u and v are respectively the source and destination nodes of the link. The values are float values between 0 and 1. A zero value means that the link is not utilized, while a one value means that the link is saturated.

  Link utilizations are calculated assuming that all traffic is routed following the shortest path from origin to destination, calculated with the Dijkstra algorithm. If the topology is annotated with link weights, they are used for the shortest path calculation. Otherwise hop count is used.

  Parameters: | topology : topology The topology whose link utilization is calculated. This topology must be annotate with at least link capacity. If it also presents link weights, those are used for shortest paths calculation. tm : TrafficMatrix The traffic matrix associated to the topology. routing_matrix : dict of dicts The routing matrix used by the traffic. This matrix is a dictionary of dictionaries, where the keys of the root dictionary are the origin nodes, the keys of the nested dictionary are the destination nodes and the values of the nested dictionary are lists of nodes on the path from origin to destination (both included). For example, if the path from node 1 to node 4 is 1 -> 2 -> 3 -> 4, then routing_matrix[1][4] = [1, 2, 3, 4]. The networkx all_pairs_dijkstra_path function returns shortest paths in this format. If this parameter is None, then Dijkstra shortest paths are used.
  Returns: | link_loads : dict A dictionary of link loads keyed by link

### Navigation

- index
- modules |
- modules |
- next |
- previous |
- FNSS 0.6.0 documentation »
- API Reference »
- Functions »