Example #1
0
File: ops.py Project: balrok/snakes
def _glue(op, one, two):
    result = one.__class__("(%s%s%s)" % (one.name, op, two.name))

    def new(name):
        return "[%s%s]" % (name, op)

    for net in (one, two):
        result.clusters.add_child(Cluster())
        result._declare = list(set(result._declare) | set(net._declare))
        result.globals.update(net.globals)
        for place in net.place():
            result.add_place(place.copy(new(place.name)),
                             cluster=[-1] + net.clusters.get_path(place.name))
        for trans in net.transition():
            result.add_transition(trans.copy(new(trans.name)),
                                  cluster=[-1] +
                                  net.clusters.get_path(trans.name))
            for place, label in trans.input():
                result.add_input(new(place.name), new(trans.name),
                                 label.copy())
            for place, label in trans.output():
                result.add_output(new(place.name), new(trans.name),
                                  label.copy())

        def new(name):
            return "[%s%s]" % (op, name)

    for status in result.status:
        result.status.merge(status)
        new = result.status(status)
        if len(new) == 1:
            name = "[%s%s%s]" % (",".join(sorted(
                one.status(status))), op, ",".join(sorted(two.status(status))))
            if name != new[0]:
                result.rename_node(new[0], name)
    return result
Example #2
0
File: gv.py Project: devnone/snakes
 def add_node (self, node, attr) :
     self.attributes[node] = attr
     Cluster.add_node(self, node)
Example #3
0
File: gv.py Project: hectorpla/CBS
 def add_node (self, node, attr) :
     self.attributes[node] = attr
     Cluster.add_node(self, node)
Example #4
0
File: gv.py Project: devnone/snakes
 def __init__ (self, attr) :
     Cluster.__init__(self)
     self.attributes = {}
     self.attr = dict(style="invis")
     self.attr.update(attr)
     self.edges = collections.defaultdict(list)
Example #5
0
File: gv.py Project: hectorpla/CBS
 def __init__ (self, attr) :
     Cluster.__init__(self)
     self.attributes = {}
     self.attr = dict(style="invis")
     self.attr.update(attr)
     self.edges = collections.defaultdict(list)