How to use the dynetx.utils.make_str function in dynetx

To help you get started, we’ve selected a few dynetx examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github GiulioRossetti / dynetx / dynetx / readwrite / edgelist.py View on Github external
def generate_snapshots(G, delimiter=' '):
    for u, v, d in G.interactions():
        if 't' not in d:
            raise NotImplemented
        for t in d['t']:
            e = [u, v, t[0]]
            if t[1] is not None:
                if t[0] != t[1]:
                    for s in range(t[0], t[1] + 1):
                        e = [u, v, s]
                        yield delimiter.join(map(make_str, e))
                else:
                    yield delimiter.join(map(make_str, e))
            else:
                yield delimiter.join(map(make_str, e))
github GiulioRossetti / dynetx / dynetx / readwrite / json_graph / node_link.py View on Github external
node_link_data
    """

    directed = data.get('directed', directed)
    graph = dn.DynGraph()
    if directed:
        graph = graph.to_directed()

    id_ = attrs['id']
    mapping = []
    graph.graph = data.get('graph', {})
    c = count()
    for d in data['nodes']:
        node = d.get(id_, next(c))
        mapping.append(node)
        nodedata = dict((make_str(k), v) for k, v in d.items() if k != id_)
        graph.add_node(node, **nodedata)
    for d in data['links']:
        graph.add_interaction(d['source'], d["target"], d['time'])

    return graph
github GiulioRossetti / dynetx / dynetx / readwrite / edgelist.py View on Github external
def generate_snapshots(G, delimiter=' '):
    for u, v, d in G.interactions():
        if 't' not in d:
            raise NotImplemented
        for t in d['t']:
            e = [u, v, t[0]]
            if t[1] is not None:
                if t[0] != t[1]:
                    for s in range(t[0], t[1] + 1):
                        e = [u, v, s]
                        yield delimiter.join(map(make_str, e))
                else:
                    yield delimiter.join(map(make_str, e))
            else:
                yield delimiter.join(map(make_str, e))