Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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))
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
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))