![]() ![]() TE_UCMP_UNLIM ) # Place demand using the flow policy demand. ![]() add_edge ( "C", "A", metric = 1, capacity = 5, label = "3" ) # Initialize a flow graph r = init_flow_graph ( g ) # Create traffic demands demands = # Place traffic demands onto the flow graph for demand in demands : # Create a flow policy with required parameters or # use one of the predefined policies from FlowPolic圜onfig flow_policy = get_flow_policy ( FlowPolic圜onfig. Place traffic demands leveraging all possible paths in a graph.EQUAL_BALANCED ) # We can verify that the result is as expected assert max_flow = 2.0 add_edge ( "D", "C", metric = 2, capacity = 3 ) # Calculate MaxFlow between the source and destination nodes # Flows will be equally balanced across the shortest paths max_flow = calc_max_flow ( g, "A", "C", shortest_path = True, flow_placement = FlowPlacement. add_edge ( "A", "D", metric = 2, capacity = 3 ) g. add_edge ( "B", "C", metric = 1, capacity = 2 ) g. add_edge ( "A", "B", metric = 1, capacity = 2 ) g. add_edge ( "B", "C", metric = 1, capacity = 1 ) g. add_edge ( "A", "B", metric = 1, capacity = 1 ) g. Calculate MaxFlow balancing flows equally across the shortest paths between the source and destination nodes.add_edge ( "D", "C", metric = 2, capacity = 3 ) # Calculate MaxFlow between the source and destination nodes # Flows will be placed only on the shortest paths max_flow = calc_max_flow ( g, "A", "C", shortest_path = True ) # We can verify that the result is as expected assert max_flow = 3.0 Calculate MaxFlow leveraging only the shortest paths between the source and destination nodes.add_edge ( "D", "C", metric = 2, capacity = 3 ) # Calculate MaxFlow between the source and destination nodes max_flow = calc_max_flow ( g, "A", "C" ) # We can verify that the result is as expected assert max_flow = 6.0 Calculate MaxFlow across all possible paths between the source and destination nodes.Use Case Examples Calculate MaxFlow in a graph The lib provides the following main primitives:īesides, it provides a number of path finding and capacity calculation functions that can be used independently. Making edges explicitly addressable is important in traffic engineering applications. The graph implementation in this library is largely compatible with NetworkX while making edges first-class entities. This library is developed to help with network modeling and capacity analysis use-cases. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |