import math


def calc_node_distance(graph, node_1, node_2):
    """
    Calculates distance between two nodes of graph,
    Requires node attribute 'position' as shapely Point, e.g. Point(10, 15.2)

    Parameters
    -----------
    graph : nx.graph
        Graph object of networkx
    node_1 : int
        Node id of node 1
    node_2 : int
        Node id of node 2

    Returns
    --------
    distance : float
        Distance between nodes
    """
    assert graph.has_node(node_1)
    assert graph.has_node(node_2)
    node_1_x = graph.nodes[node_1]['position'].x
    node_1_y = graph.nodes[node_1]['position'].y
    node_2_x = graph.nodes[node_2]['position'].x
    node_2_y = graph.nodes[node_2]['position'].y

    distance = math.sqrt((node_1_x - node_2_x) ** 2 +
                         (node_1_y - node_2_y) ** 2)
    return distance