# Path: soap/context/default.py



import itertools
import math
import numpy
from soap.context import context
    """
    nodes = graph.nodes()
    len_nodes = len(nodes)
    dist_shape = [len_nodes] * 2

    dist = numpy.full(dist_shape, neg_inf)
    iterer = itertools.product(enumerate(nodes), repeat=2)
    for (from_idx, from_node), (to_idx, to_node) in iterer:
        try:
            edge = graph[from_node][to_node]
        except KeyError:
            continue
        dist[from_idx, to_idx] = edge['latency'] - ii * edge['distance']

    iterer = itertools.product(range(len_nodes), repeat=3)
    for mid_idx, from_idx, to_idx in iterer:
        dist_val = dist[from_idx, mid_idx] + dist[mid_idx, to_idx]
        if dist_val > dist[from_idx, to_idx]:
            if from_idx == to_idx and dist_val > 0:
                return False
            dist[from_idx, to_idx] = dist_val

    return True


def rec_init_int_search(graph, init_ii=1, prec=None, round_values=False):
    """
    Performs a binary search of the recurrence-based minimum initiation
    interval (RecMII).
    """

# Path: soap/context/default.py



# Path: soap/semantics/schedule/ii.py
import itertools
import math
import numpy
from soap.context import context

    """
    nodes = graph.nodes()
    len_nodes = len(nodes)
    dist_shape = [len_nodes] * 2

    dist = numpy.full(dist_shape, neg_inf)
    iterer = itertools.product(enumerate(nodes), repeat=2)
    for (from_idx, from_node), (to_idx, to_node) in iterer:
        try:
            edge = graph[from_node][to_node]
        except KeyError:
            continue
        dist[from_idx, to_idx] = edge['latency'] - ii * edge['distance']

    iterer = itertools.product(range(len_nodes), repeat=3)
    for mid_idx, from_idx, to_idx in iterer:
        dist_val = dist[from_idx, mid_idx] + dist[mid_idx, to_idx]
        if dist_val > dist[from_idx, to_idx]:
            if from_idx == to_idx and dist_val > 0:
                return False
            dist[from_idx, to_idx] = dist_val

    return True


def rec_init_int_search(graph, init_ii=1, prec=None, round_values=False):
    """
    Performs a binary search of the recurrence-based minimum initiation
    interval (RecMII).
    """

    prec = prec or context.ii_precision