'Transforms a cursor of triplets of (node, edge, node) to a graph of
hosts and flows. All the elements are of the form
{elt: <neo4j element-like>, meta: [<list of metadata>]}
This is an internal API that is very likely to change.'

@classmethod
def cursor2json_graph(cls, cursor):

    random.seed(0)
    g = {'nodes': [], 'edges': []}
    done = set()
    for row in cls.cursor2json_iter(cursor):
        for (node, typ) in ((row['src'], 'nodes'), (row['flow'], 'edges'), (row['dst'], 'nodes')):
            if (node['id'] not in done):
                g[typ].append(node)
                done.add(node['id'])
    return g
