How to use the pydot.graph_from_edges function in pydot

To help you get started, we’ve selected a few pydot examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github santoshphilip / eppy / diagrams / s_plantloop2.py View on Github external
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
github santoshphilip / eppy / diagrams / s_airloop1.py View on Github external
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')
github santoshphilip / eppy / eppy / airloop / s_airloop1.py View on Github external
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')
github anutron / mootools-depender / django / src / depender / core.py View on Github external
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)
github realXtend / tundra / src / Application / PythonScriptModule / pymodules_old / circuits / tools / __init__.py View on Github external
: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))
github santoshphilip / eppy / diagrams / s_branchdiagrams.py View on Github external
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
github santoshphilip / eppy / diagrams / s_airloop.py View on Github external
# 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')