Вы не можете выбрать более 25 тем
Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.
3.6 KiB
3.6 KiB
In [ ]:
from graphviz import Digraph
In [ ]:
dot = Digraph()
In [ ]:
# Add nodes 1 and 2 dot.node('1') dot.node('2') # Add edge between 1 and 2 dot.edges(['12'])
In [ ]:
dot
In [ ]:
text = """I have a tale to tell Sometimes it gets so hard to hide it well I was not ready for the fall Too blind to see the writing on the wall"""
In [ ]:
for word in text.split(): print (word)
In [ ]:
from itertools import tee def pairwise(iterable): "s -> (s0,s1), (s1,s2), (s2, s3), ..." a, b = tee(iterable) next(b, None) return zip(a, b)
In [ ]:
for w1, w2 in pairwise(text.split()): print (w1, w2)
In [ ]:
for w1, w2 in pairwise(text.split()): dot.edge(w1, w2)
In [ ]:
dot
In [ ]:
dot.render("tale")
In [ ]:
dot.render?
In [ ]:
# Example of using the graph as a generator ??
In [ ]:
dot.render("tale", format="png")
In [ ]: