I have the same problem on pygraphviz 1.2, but I have a workaround.
If you specify the desired graph type as an empty graph using the DOT language (for example, graph foo {} ) and pass it to the constructor from AGraph , then pygraphviz respects the graph type, even if it can ignore it when given as a keyword argument (as in my environment).
>>> import pygraphviz as pgv >>> foo = pgv.AGraph('graph foo {}') >>> foo.is_directed() False >>> foo.add_edge('A', 'B') >>> print foo graph foo { A -- B; }
The workaround also works for the strict argument, which is also ignored in my environment.
Use the following function instead of pgv.AGraph to have the same API:
def AGraph(directed=False, strict=True, name='', **args): """Fixed AGraph constructor.""" graph = '{0} {1} {2} {{}}'.format( 'strict' if strict else '', 'digraph' if directed else 'graph', name ) return pgv.AGraph(graph, **args)
source share