# Path: regraph/utils.py
# def keys_by_value(dictionary, val):
#     """Get keys of a dictionary by a value."""
#     res = []
#     for key, value in dictionary.items():
#         if value == val:
#             res.append(key)
#     return res


import copy
import networkx as nx
import numpy as np
from regraph.utils import keys_by_value
from matplotlib import pyplot as plt
        else:
            lhs_colors.append(np.random.rand(3,))

    rhs_colors = []
    for node in rule.rhs.nodes():
        p_keys = keys_by_value(rule.p_rhs, node)
        if len(p_keys) > 0:
            rhs_colors.append(p_colors_dict[p_keys[0]])
        else:
            rhs_colors.append(np.random.rand(3,))

    # generate positions
    p_pos = nx.spring_layout(rule.p._graph, k=0.8, scale=1.0)

    lhs_pos = dict()
    lhs_fixed = []
    for node in rule.lhs.nodes():
        p_keys = keys_by_value(rule.p_lhs, node)
        if len(p_keys) > 0:
            lhs_pos[node] = p_pos[p_keys[0]]
            lhs_fixed.append(node)
    if len(lhs_pos) == 0:
        lhs_fixed = None
        lhs_pos = None
    lhs_pos = nx.spring_layout(
        rule.lhs._graph, pos=lhs_pos, fixed=lhs_fixed, k=0.05, scale=1.0, iterations=10)

    rhs_pos = dict()
    rhs_fixed = []
    for node in rule.rhs.nodes():

# Path: regraph/utils.py
# def keys_by_value(dictionary, val):
#     """Get keys of a dictionary by a value."""
#     res = []
#     for key, value in dictionary.items():
#         if value == val:
#             res.append(key)
#     return res


# Path: regraph/backends/networkx/plotting.py
import copy
import networkx as nx
import numpy as np
from regraph.utils import keys_by_value
from matplotlib import pyplot as plt

        else:
            lhs_colors.append(np.random.rand(3,))

    rhs_colors = []
    for node in rule.rhs.nodes():
        p_keys = keys_by_value(rule.p_rhs, node)
        if len(p_keys) > 0:
            rhs_colors.append(p_colors_dict[p_keys[0]])
        else:
            rhs_colors.append(np.random.rand(3,))

    # generate positions
    p_pos = nx.spring_layout(rule.p._graph, k=0.8, scale=1.0)

    lhs_pos = dict()
    lhs_fixed = []
    for node in rule.lhs.nodes():
        p_keys = keys_by_value(rule.p_lhs, node)
        if len(p_keys) > 0:
            lhs_pos[node] = p_pos[p_keys[0]]
            lhs_fixed.append(node)
    if len(lhs_pos) == 0:
        lhs_fixed = None
        lhs_pos = None
    lhs_pos = nx.spring_layout(
        rule.lhs._graph, pos=lhs_pos, fixed=lhs_fixed, k=0.05, scale=1.0, iterations=10)

    rhs_pos = dict()
    rhs_fixed = []
    for node in rule.rhs.nodes():

        p_keys = keys_by_value(rule.p_rhs, node)