5 if len(ig.get_vertices()) == 0:
10 def __init__(self, p):
14 return self.p.get_name()
16 def __call__(self, name):
17 return self.p.__call__(name)
19 for vi
in ig.get_vertices():
20 n = ig.get_vertex_name(vi)
21 g.add_node(NodeWrapper(n))
22 for vi
in ig.get_vertices():
23 n = ig.get_vertex_name(vi)
24 for ni
in ig.get_out_neighbors(vi):
25 nn = ig.get_vertex_name(ni)
26 g.add_edge(NodeWrapper(n), NodeWrapper(nn))
36 n1 = str(n0).replace(
'"',
'')
37 n2 = n1.replace(
"\n",
'')
40 from altgraph
import Graph, Dot
42 for i, v
in enumerate(g.get_vertices()):
44 for i, v
in enumerate(g.get_vertices()):
45 for n
in g.get_out_neighbors(v):
48 for i, v
in enumerate(g.get_vertices()):
49 dot.node_style(i, label=clean(g.get_vertex_name(v)))
57 st = g.get_graphviz_string()
58 open(tfn,
"w").write(st)
63 print >> sys.stderr,
"Cannot run dot on Python 2.3 systems."
67 sp = subprocess.Popen([
"dot",
"-Tpdf", tfn,
"-o" + tfon])
71 print >> sys.stderr,
"The dot command from the graphviz package was not found. Please make sure it is in the PATH passed to IMP."
74 if platform.system() ==
"Darwin":
77 cmd = [
"gv",
"acroread",
"xpdf"]
80 print "launching viewer", c
82 subprocess.check_call([c, tfon])
88 print "Could not display file. It is saved at", tfon
std::string create_temporary_file_name(std::string prefix="imp_temp", std::string suffix="")
See IMP.base for more information.
std::string show_graphviz(Graph g)
networkx::DiGraph get_networkx_graph(Graph g)
void show_altgraph(Graph g)