<commit_before>AGraph String, Read, Write, Layout and Drawing
==============================================

>>> from pygraphviz import *
>>> import os,tempfile

String representation
---------------------

>>> A=AGraph(name='')
>>> print A
<BLANKLINE>

>>> print A.string().expandtabs()
strict graph  {
}
<BLANKLINE>

>>> A.__repr__() # test __repr__
'strict graph  {\n}'


>>> A=AGraph(name='test')
>>> A.add_path([1,2])
>>> print A
test
>>> print A.string().expandtabs()
strict graph test {
        1 -- 2;
}
<BLANKLINE>

>>> A.__repr__() # test __repr__
'strict graph test {\n\t1 -- 2;\n}'

>>> A=AGraph(name='test graph')
>>> A.add_path([1,2,3,4,5,6,7,8,9,10])
>>> A.add_node(11)
>>> print A
test graph
>>> print A.string().expandtabs()
strict graph "test graph" {
        1 -- 2;
        2 -- 3;
        3 -- 4;
        4 -- 5;
        5 -- 6;
        6 -- 7;
        7 -- 8;
        8 -- 9;
        9 -- 10;
        11;
}
<BLANKLINE>

Read/Write
----------
>>> A=AGraph(name='test graph')
>>> A.add_path([1,2,3,4,5,6,7,8,9,10])

>>> import os,tempfile
>>> (fd,fname)=tempfile.mkstemp()
>>> A.write(fname)
>>> A.read(fname)
>>> B=AGraph(fname)
>>> B==A
True
>>> B is A
False
>>> os.close(fd)
>>> os.unlink(fname)


Layout
------
>>> A=AGraph(name='test graph')
>>> A.add_path([1,2,3,4])
>>> A.layout()
>>> ['pos' in n.attr for n in A.nodes()]==[True, True, True, True]
True


Drawing
-------

>>> d=A.draw()

>>> A=AGraph(name='test graph')
>>> A.add_path([1,2,3,4])
>>> d=A.draw()
Traceback (most recent call last):
...
AttributeError: graph has no layout information, see layout()

>>> d=A.draw(prog='neato')

>>> (fd,fname)=tempfile.mkstemp()
>>> A.draw(fname,format='ps',prog='neato')
>>> A.draw(fname,prog='neato')
>>> A.draw(fname,prog='foo')
Traceback (most recent call last):
...
ValueError: prog foo is not one of twopi, fdp, circo, neato, nop, dot


>>> os.close(fd)
>>> os.unlink(fname)<commit_msg>add pygraphviz layout test<commit_after>AGraph String, Read, Write, Layout and Drawing
==============================================

>>> from pygraphviz import *
>>> import os,tempfile

String representation
---------------------

>>> A=AGraph(name='')
>>> print A
<BLANKLINE>

>>> print A.string().expandtabs()
strict graph  {
}
<BLANKLINE>

>>> A.__repr__() # test __repr__
'strict graph  {\n}'


>>> A=AGraph(name='test')
>>> A.add_path([1,2])
>>> print A
test
>>> print A.string().expandtabs()
strict graph test {
        1 -- 2;
}
<BLANKLINE>

>>> A.__repr__() # test __repr__
'strict graph test {\n\t1 -- 2;\n}'

>>> A=AGraph(name='test graph')
>>> A.add_path([1,2,3,4,5,6,7,8,9,10])
>>> A.add_node(11)
>>> print A
test graph
>>> print A.string().expandtabs()
strict graph "test graph" {
        1 -- 2;
        2 -- 3;
        3 -- 4;
        4 -- 5;
        5 -- 6;
        6 -- 7;
        7 -- 8;
        8 -- 9;
        9 -- 10;
        11;
}
<BLANKLINE>

Read/Write
----------
>>> A=AGraph(name='test graph')
>>> A.add_path([1,2,3,4,5,6,7,8,9,10])

>>> import os,tempfile
>>> (fd,fname)=tempfile.mkstemp()
>>> A.write(fname)
>>> A.read(fname)
>>> B=AGraph(fname)
>>> B==A
True
>>> B is A
False
>>> os.close(fd)
>>> os.unlink(fname)


Layout
------
>>> A=AGraph(name='test graph')
>>> A.add_path([1,2,3,4])
>>> A.layout()
>>> ['pos' in n.attr for n in A.nodes()]==[True, True, True, True]
True


Drawing
-------

>>> d=A.draw()

>>> A=AGraph(name='test graph')
>>> A.add_path([1,2,3,4])
>>> d=A.draw()
Traceback (most recent call last):
...
AttributeError: graph has no layout information, see layout()
                or specify prog=neato|dot|twopi|circo|fdp|nop

>>> d=A.draw(prog='neato')
>>> len(d.splitlines())
11
>>> (fd,fname)=tempfile.mkstemp()
>>> A.draw(fname,format='ps',prog='neato')
>>> A.draw(fname,prog='neato')
>>> A.draw(fname,prog='foo')
Traceback (most recent call last):
...
ValueError: prog foo is not one of: twopi, fdp, circo, neato, nop, dot


>>> os.close(fd)
>>> os.unlink(fname)
{'fraction_non_alphanumeric': 0.26817488561260805, 'fraction_numerical': 0.030503304524656837, 'mean_word_length': 3.2586580086580086, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 266, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3200798', 'n_tokens_mistral': 1596, 'n_tokens_neox': 1542, 'n_words': 331}