1 import pygraphviz
as pgv
4 return string.replace(
"<",
"<").replace(
">",
">")
11 port_name = letter+
str(ind)
12 port_label = port_name.upper()
16 ports[port_name] = port_label
17 items = sorted(ports.items())
18 inner =
'|'.join([
"<%s>%s" % p
for p
in items ])
25 Return a GraphViz node label defined based on given NodeType <nt>. 29 lines.append(
"{%s (cat:%d con:%d)}" % (nt.type, nt.category, nt.concurrency))
31 label =
'|'.join([l
for l
in lines
if l])
32 return "{" + label +
"}" 37 '''Return a GraphViz graph made from the NX graph. The <nodetypes> is 38 a NodeType dictionary and will be used to define the nodes. 40 ag = pgv.AGraph(directed=
True, strict=
False)
41 ag.node_attr[
'shape'] =
'record' 43 for nn
in nxgraph.nodes():
46 typ = typ.split(
':',1)[0]
50 for nt,nh,nd
in nxgraph.edges(data=
True):
51 key =
' {tail_port}-{head_port} '.
format(**nd)
52 dt = nd.get(
'data_type')
55 ag.add_edge(nt,nh, key=key, label=key,
56 tailport=
'o'+
str(nd.get(
'tail_port',0)),
57 headport=
'i'+
str(nd.get(
'head_port',0)))
64 port_key =
"tail_port" 66 port_key =
"head_port" 70 port_num = dat[port_key]
71 port_name = letter+
str(port_num)
72 port_label = port_name.upper()
73 dt = dat.get(
'data_type')
75 port_label +=
"(%s)" % dt
76 ports[port_name] = port_label
78 items = sorted(ports.items())
79 inner =
'|'.join([
"<%s>%s" % p
for p
in items ])
84 Return a GraphViz node label defined based on its collection of input and output edges. 90 label =
'|'.join([l
for l
in lines
if l])
95 '''Return a GraphViz graph made from the NX graph.''' 97 ag = pgv.AGraph(directed=
True, strict=
False, overlap=
'false', splines=
'true')
98 ag.node_attr[
'shape'] =
'record' 100 for nn
in nxgraph.nodes():
101 nodestring =
edgetype_label(nn, nxgraph.in_edges(nn,data=
True), nxgraph.out_edges(nn,data=
True))
102 label =
"{" + nodestring +
"}" 103 ag.add_node(
str(nn), label=label)
104 for nt,nh,nd
in nxgraph.edges(data=
True):
105 key =
' {tail_port}-{head_port} '.
format(**nd)
106 dt = nd.get(
'data_type')
109 ag.add_edge(nt,nh, key=key, label=key,
110 tailport=
'o'+
str(nd.get(
'tail_port',0)),
111 headport=
'i'+
str(nd.get(
'head_port',0)))
static bool format(QChar::Decomposition tag, QString &str, int index, int len)
auto enumerate(Iterables &&...iterables)
Range-for loop helper tracking the number of iteration.
def edge_port_string(letter, edges)
def node_port_string(letter, types, addtypes=False)
def edgetype_label(nxnode, inedges, outedges)
def gvgraph_nodetypes(nxgraph, nodetypes)
def nodetype_label(nt, addtypes=False)