Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
inlts = loops.extractfields(data, commdct,
objkey, [inletfields] * numobjects)
cmps = loops.extractfields(data, commdct,
objkey, [cnamefields] * numobjects)
otlts = loops.extractfields(data, commdct,
objkey, [outletfields] * numobjects)
zipped = zip(inlts, cmps, otlts)
tzipped = [transpose2d(item) for item in zipped]
for i in range(len(data.dt[objkey])):
tt = tzipped[i]
# branchname = data.dt[objkey][i][1]
edges = []
for t0 in tt:
edges = edges + [(t0[0], t0[1]), (t0[1], t0[2])]
g=pydot.graph_from_edges(edges, directed=True)
allgraphs.append(g)
return allgraphs
if type(a1) == tuple:
a1 = list(a1)
a1.pop(a1.index('epnode'))
a1 = a1[0]
if type(a2) == tuple:
a2 = list(a2)
a2.pop(a2.index('epnode'))
a2 = a2[0]
cleanmoreedges.append((a1, a2))
edges = edges + cleanmoreedges
#---------
# make graph
g=pydot.graph_from_edges(edges, directed=True)
g.write('a.dot')
g.write_png('a.png')
if type(a1) == tuple:
a1 = list(a1)
a1.pop(a1.index('epnode'))
a1 = a1[0]
if type(a2) == tuple:
a2 = list(a2)
a2.pop(a2.index('epnode'))
a2 = a2[0]
cleanmoreedges.append((a1, a2))
edges = edges + cleanmoreedges
#---------
# make graph
g=pydot.graph_from_edges(edges, directed=True)
g.write('a.dot')
g.write_png('a.png')
def graph(self):
"""
Returns a pydot.Dot object representing the dependency graph.
Requires pydot to be available.
"""
import pydot
edges = set()
for p in self.packages.values():
for f in p.files:
for id in f.requires:
f2 = self.get(id)
edges.add( ("--".join([p.key, f.shortname]), "--".join([f2.package.key, f2.shortname])) )
return pydot.graph_from_edges(edges, directed=True)
:param name: A name for the graph (defaults to x's name)
:type name: str
@return: A directed graph representing x's Component sturcture.
@rtype: str
"""
def getname(c):
return "%s-%s" % (c.name, md5(str(hash(c))).hexdigest()[-4:])
if HAS_PYDOT:
graph_edges = []
for (u, v) in edges(x):
graph_edges.append(("\"%s\"" % getname(u), "\"%s\"" % getname(v)))
g = pydot.graph_from_edges(graph_edges, directed=True)
g.write("%s.dot" % (name or x.name))
g.write("%s.png" % (name or x.name), format="png")
def printer(d, x):
return "%s* %s" % (" " * d, x)
return "\n".join(walk(x, printer))
inlts = loops.extractfields(data, commdct,
objkey, [inletfields] * numobjects)
cmps = loops.extractfields(data, commdct,
objkey, [cnamefields] * numobjects)
otlts = loops.extractfields(data, commdct,
objkey, [outletfields] * numobjects)
zipped = zip(inlts, cmps, otlts)
tzipped = [transpose2d(item) for item in zipped]
for i in range(len(data.dt[objkey])):
tt = tzipped[i]
# branchname = data.dt[objkey][i][1]
edges = []
for t0 in tt:
edges = edges + [(t0[0], t0[1]), (t0[1], t0[2])]
g=pydot.graph_from_edges(edges, directed=True)
allgraphs.append(g)
return allgraphs
# get all branches
branchkey = "branch".upper()
branches = data.dt[branchkey]
branch_i_o = {}
for br in branches:
br_name = br[1]
in_out = loops.branch_inlet_outlet(data, commdct, br_name)
branch_i_o[br_name] = dict(zip(["inlet", "outlet"], in_out))
for br_name, in_out in branch_i_o.items():
edges.append((in_out["inlet"], br_name))
edges.append((br_name, in_out["outlet"]))
#---------
# make graph
g=pydot.graph_from_edges(edges, directed=True)
g.write('a.dot')
g.write_png('a.png')