File: subgraph.py

package info (click to toggle)
python-pygraphviz 1.3.1-1~bpo8%2B1
  • links: PTS, VCS
  • area: main
  • in suites: jessie-backports
  • size: 664 kB
  • sloc: ansic: 4,970; python: 2,523; makefile: 152
file content (22 lines) | stat: -rw-r--r-- 508 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#!/usr/bin/env python

from __future__ import absolute_import
from __future__ import unicode_literals
from __future__ import print_function
from __future__ import division

import pygraphviz as pgv

A=pgv.AGraph()
# add some edges
A.add_edge(1,2)
A.add_edge(2,3)
A.add_edge(1,3)
A.add_edge(3,4)
A.add_edge(3,5)
A.add_edge(3,6)
A.add_edge(4,6)
# make a subgraph with rank='same'
B=A.add_subgraph([4,5,6],name='s1',rank='same')
B.graph_attr['rank']='same'
print(A.string()) # print dot file to standard output