Return a new instance of type MultiGraph, initialized with the given
        data if provided.

        :arg name: a name for the graph
        :arg data: dictionary or NetworkX graph object providing initial state
516128
def new_multigraph(self, name, data=None, **attr):
        
        self._init_graph(name, 'MultiGraph')
        mg = MultiGraph(self, name, data, **attr)
        self._graph_objs[name] = mg
        return mg
819910
def from_dict(cls, d):
        
        m = Molecule.from_dict(d['molecule'])
        return cls(m, d['graphs'])
1284217
def create_model(cls, data: dict, fields=None):
        '''
        
        '''
        if fields is None:
            fields = set(cls._fields.keys())
        else:
            if not isinstance(fields, set):
                fields = set(fields)
        new_keys = set(data.keys()) - fields
        if new_keys:
            for new_key in new_keys:
                del data[new_key]
        return cls(data)
1272891
def createNode(self, cls, name, *args, **kw):
        
        m = self.findNode(name)
        if m is None:
            m = cls(name, *args, **kw)
            self.addNode(m)
        return m
115060
def get_graph_metadata(self, graph):
        
        _params = set()
        for tensor_vals in graph.initializer:
            _params.add(tensor_vals.name)

        input_data = []
        for graph_input in graph.input:
            if graph_input.name not in _params:
                shape = [val.dim_value for val in graph_input.type.tensor_type.shape.dim]
                input_data.append((graph_input.name, tuple(shape)))

        output_data = []
        for graph_out in graph.output:
            shape = [val.dim_value for val in graph_out.type.tensor_type.shape.dim]
            output_data.append((graph_out.name, tuple(shape)))
        metadata = {'input_tensor_data' : input_data,
                    'output_tensor_data' : output_data
                   }
        return metadata
896316
def init_target_object(self, target, data):
        
        target_object = self.init_single_object(target, data.pop(target, data))
        for key, item in data.items():
            key_alias = MANAGER_ALIASES.get(key, key)
            if item:
                # Item is an OrderedDict with 4 possible structure patterns:
                #   - Just an OrderedDict with (key - value)'s
                #   - OrderedDict with single (key - OrderedDict)
                #   - OrderedDict with multiple (key - OrderedDict)'s
                #   - String (like CreativeCode model)
                if isinstance(item, str):
                    children = item
                else:
                    first_key = list(item.keys())[0]
                    if isinstance(item[first_key], OrderedDict):
                        instances = item.values()
                        if len(instances) > 1:
                            children = [self.init_single_object(key_alias, instance) for instance in instances]
                        else:
                            children = self.init_single_object(key_alias, list(instances)[0])
                    else:
                        children = self.init_single_object(key_alias, item)
                setattr(target_object, key.lower(), children)
            else:
                setattr(target_object, key.lower(), None)
        return target_object
1064019
def _get_model_instance(model_cls, data):
        
        if not isinstance(data, (model_cls, dict)):
            raise TypeError('{0} is not valid type, instance of '
                            '{1} or dict required'.format(data, model_cls))
        return model_cls(**data) if isinstance(data, dict) else data
1281951
def create_from_name_and_dictionary(self, name, datas):
        
        category = ObjectCategory(name)
        self.set_common_datas(category, name, datas)

        if "order" in datas:
            category.order = int(datas["order"])

        return category
11637
def new_product(self, name):
        
        n = self._product_cls(self, name, summary_cls=self._summary_cls)
        self.graph.add_node(n)
        self.products.append(n)
        return n
1119269
def new_chart_graphicFrame(cls, id_, name, rId, x, y, cx, cy):
        
        graphicFrame = CT_GraphicalObjectFrame.new_graphicFrame(
            id_, name, x, y, cx, cy
        )
        graphicData = graphicFrame.graphic.graphicData
        graphicData.uri = GRAPHIC_DATA_URI_CHART
        graphicData.append(CT_Chart.new_chart(rId))
        return graphicFrame
174163
def parse(self, data):
        
        # initialize graph and list of aggregated nodes
        graph = self._init_graph()
        server = self._server_common_name
        # add server (central node) to graph
        graph.add_node(server)
        # data may be empty
        if data is None:
            clients = []
            links = []
        else:
            clients = data.client_list.values()
            links = data.routing_table.values()
        # add clients in graph as nodes
        for client in clients:
            if client.common_name == 'UNDEF':
                continue
            client_properties = {
                'label': client.common_name,
                'real_address': str(client.real_address.host),
                'port': int(client.real_address.port),
                'connected_since': client.connected_since.strftime('%Y-%m-%dT%H:%M:%SZ'),
                'bytes_received': int(client.bytes_received),
                'bytes_sent': int(client.bytes_sent)
            }
            local_addresses = [
                str(route.virtual_address)
                for route in data.routing_table.values()
                if route.real_address == client.real_address
            ]
            if local_addresses:
                client_properties['local_addresses'] = local_addresses
            graph.add_node(str(client.real_address.host), **client_properties)
        # add links in routing table to graph
        for link in links:
            if link.common_name == 'UNDEF':
                continue
            graph.add_edge(server, str(link.real_address.host), weight=1)
        return graph
436730
def new_digraph(self, name, data=None, **attr):
        
        self._init_graph(name, 'DiGraph')
        dg = DiGraph(self, name, data, **attr)
        self._graph_objs[name] = dg
        return dg
487246
def add_chain(self, *nodes, _input=BEGIN, _output=None, _name=None):
        
        if len(nodes):
            _input = self._resolve_index(_input)
            _output = self._resolve_index(_output)
            _first = None
            _last = None

            for i, node in enumerate(nodes):
                _last = self.add_node(node)
                if not i and _name:
                    if _name in self.named:
                        raise KeyError("Duplicate name {!r} in graph.".format(_name))
                    self.named[_name] = _last
                if _first is None:
                    _first = _last
                self.outputs_of(_input, create=True).add(_last)
                _input = _last

            if _output is not None:
                self.outputs_of(_input, create=True).add(_output)

            if hasattr(self, "_topologcally_sorted_indexes_cache"):
                del self._topologcally_sorted_indexes_cache

            return GraphRange(self, _first, _last)
        return GraphRange(self, None, None)
388428
def from_dict(cls, d):
        
        s = Structure.from_dict(d['structure'])
        return cls(s, d['graphs'])
518295
def _get_name(self, graph, group=None):
        
        if group is not None:
            graph = graph.get_subgraph(group, normalize=True)

        fingerprint = graph.fingerprint.tobytes()
        name = self.name_cache.get(fingerprint)
        if name is None:
            name = "NM%02i" % len(self.name_cache)
            self.name_cache[fingerprint] = name
        return name
421265
def new(cls, shapes, start_x, start_y, x_scale, y_scale):
        
        return cls(
            shapes, int(round(start_x)), int(round(start_y)),
            x_scale, y_scale
        )
387725
def _graphviz_default_namer(thing, is_edge=True, is_to_splitmerge=False):
    
    if is_edge:
        if (thing.name is None or
                thing.name.startswith('tmp') or
                isinstance(thing, (Input, Output, Const, Register))):
            name = ''
        else:
            name = '/'.join([thing.name, str(len(thing))])
        penwidth = 2 if len(thing) == 1 else 6
        arrowhead = 'none' if is_to_splitmerge else 'normal'
        return '[label="%s", penwidth="%d", arrowhead="%s"]' % (name, penwidth, arrowhead)

    elif isinstance(thing, Const):
        return '[label="%d", shape=circle, fillcolor=lightgrey]' % thing.val
    elif isinstance(thing, (Input, Output)):
        return '[label="%s", shape=circle, fillcolor=none]' % thing.name
    elif isinstance(thing, Register):
        return '[label="%s", shape=square, fillcolor=gold]' % thing.name
    elif isinstance(thing, WireVector):
        return '[label="", shape=circle, fillcolor=none]'
    else:
        try:
            if thing.op == '&':
                return '[label="and"]'
            elif thing.op == '|':
                return '[label="or"]'
            elif thing.op == '^':
                return '[label="xor"]'
            elif thing.op == '~':
                return '[label="not"]'
            elif thing.op == 'x':
                return '[label="mux"]'
            elif thing.op in 'sc':
                return '[label="", height=.1, width=.1]'
            elif thing.op == 'r':
                name = thing.dests[0].name or ''
                return '[label="%s.next", shape=square, fillcolor=gold]' % name
            elif thing.op == 'w':
                return '[label="buf"]'
            else:
                return '[label="%s"]' % (thing.op + str(thing.op_param or ''))
        except AttributeError:
            raise PyrtlError('no naming rule for "%s"' % str(thing))