def active_graph_node(conn, graph_node_pkey, forward):
    """ Returns true if an edge in the specified direction exists. """
    cur = conn.cursor()

    if forward:
        cur.execute(
            """
SELECT count(*) FROM graph_edge WHERE src_graph_node_pkey = ? LIMIT 1
            """, (graph_node_pkey, )
        )
    else:
        cur.execute(
            """
SELECT count(*) FROM graph_edge WHERE dest_graph_node_pkey = ? LIMIT 1
            """, (graph_node_pkey, )
        )

    return cur.fetchone()[0] > 0