Converts a OpenVPN JSON to a NetworkX Graph object
        which is then returned.
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
1353880
def graph(bare=False, json=False, json_tree=False, reverse=False):
    """"""
    from ..core import do_graph

    do_graph(bare=bare, json=json, json_tree=json_tree, reverse=reverse)
833130
def parse(self, data):
        
        graph = self._init_graph()
        if 'topology' not in data:
            raise ParserError('Parse error, "topology" key not found')
        elif 'mid' not in data:
            raise ParserError('Parse error, "mid" key not found')

        # determine version and revision
        if 'config' in data:
            version_info = data['config']['olsrdVersion'].replace(' ', '').split('-')
            self.version = version_info[1]
            # try to get only the git hash
            if 'hash_' in version_info[-1]:
                version_info[-1] = version_info[-1].split('hash_')[-1]
            self.revision = version_info[-1]

        # process alias list
        alias_dict = {}
        for node in data['mid']:
            local_addresses = [alias['ipAddress'] for alias in node['aliases']]
            alias_dict[node['ipAddress']] = local_addresses

        # loop over topology section and create networkx graph
        for link in data['topology']:
            try:
                source = link['lastHopIP']
                target = link['destinationIP']
                cost = link['tcEdgeCost']
                properties = {
                    'link_quality': link['linkQuality'],
                    'neighbor_link_quality': link['neighborLinkQuality']
                }
            except KeyError as e:
                raise ParserError('Parse error, "%s" key not found' % e)
            # add nodes with their local_addresses
            for node in [source, target]:
                if node not in alias_dict:
                    continue
                graph.add_node(node, local_addresses=alias_dict[node])
            # skip links with infinite cost
            if cost == float('inf'):
                continue
            # original olsrd cost (jsoninfo multiplies by 1024)
            cost = float(cost) / 1024.0
            # add link to Graph
            graph.add_edge(source, target, weight=cost, **properties)
        return graph
226646
def _to_json(self):
        
        return dict(( (k, v) for k, v in self.__dict__.iteritems() if k != 'server'))
158167
def _neighbors_graph(self, **params) -> Dict:
        
        response = self._get_response("graph/neighbors", format="json", **params)
        return response.json()
358773
private static String toJson(Object x) {
    try {
      if (x == null || x instanceof String || x instanceof Number || x instanceof Character
          || x.getClass().isArray() || x instanceof Iterable<?>) {
        return new JSONObject().put("JSON", x).toString(2);
      } else if (x instanceof Map<?, ?>) {
        return (new JSONObject((Map<?, ?>) x)).toString(2);
      } else if (x instanceof JSONObject) {
        return ((JSONObject) x).toString(2);
      } else {
        return (new JSONObject(x)).toString(2);
      }
    } catch (Exception e) {
      throw new RuntimeException("x=" + x, e);
    }
  }
120704
def to_json_file(graph: BELGraph, file: TextIO, **kwargs) -> None:
    """"""
    graph_json_dict = to_json(graph)
    json.dump(graph_json_dict, file, ensure_ascii=False, **kwargs)
238925
def dict_to_nx(graph, oriented=False):
    """"""
    nxg = nx.DiGraph() if oriented else nx.Graph()
    for node, succs in graph.items():
        for succ in succs:
            nxg.add_edge(node, succ)
    return nxg
1285157
private JsonNode toJson(){
    	ObjectNode result = new ObjectNode(Topology.OBJECT_MAPPER.getNodeFactory());
        ArrayNode propertyArrayNode = new ArrayNode(Topology.OBJECT_MAPPER.getNodeFactory());
        for (PropertyColumn property : this.properties) {
            ObjectNode objectNode = property.toNotifyJson();
            objectNode.put("schemaName", property.getParentLabel().getSchema().getName());
            objectNode.put("abstractLabelLabel", property.getParentLabel().getLabel());
            propertyArrayNode.add(objectNode);
        }
        result.put("name", getName());
        result.set("properties", propertyArrayNode);
        return result;
    }
653670
def json(self):
        """"""
        return {
            "id": self.ID,
            "steps": self.steps,
            "graph_source": self.source,
            "errored": self.errored
        }
833181
def ToJson(self):
        
        jsn = {
            'name': self.name,
            'symbol': self.symbol,
            'decimals': self.decimals,
            'script_hash': self.ScriptHash.To0xString(),
            'contract_address': self.Address
        }
        return jsn
391194
def get_graph_by_id(self, network_id: int) -> BELGraph:
        """"""
        network = self.get_network_by_id(network_id)
        log.debug('converting network [id=%d] %s to bel graph', network_id, network)
        return network.as_bel()
369082
def to_string(self):
        

        graph = list()

        if self.obj_dict.get('strict', None) is not None:
            if self == self.get_parent_graph() and self.obj_dict['strict']:
                graph.append('strict ')

        if self.obj_dict['name'] == '':
            if ('show_keyword' in self.obj_dict and
                    self.obj_dict['show_keyword']):
                graph.append('subgraph {\n')
            else:
                graph.append('{\n')
        else:
            graph.append('%s %s {\n' % (self.obj_dict['type'],
                                        self.obj_dict['name']))

        for attr, value in sorted(self.obj_dict['attributes'].items(),
                                  key=itemgetter(0)):
            if value is not None:
                graph.append('%s=%s' % (attr, quote_if_necessary(value)))
            else:
                graph.append(attr)

            graph.append(';\n')

        edges_done = set()

        edge_obj_dicts = list()
        for e in self.obj_dict['edges'].values():
            edge_obj_dicts.extend(e)

        if edge_obj_dicts:
            edge_src_set, edge_dst_set = list(
                zip(*[obj['points'] for obj in edge_obj_dicts]))
            edge_src_set, edge_dst_set = set(edge_src_set), set(edge_dst_set)
        else:
            edge_src_set, edge_dst_set = set(), set()

        node_obj_dicts = list()
        for e in self.obj_dict['nodes'].values():
            node_obj_dicts.extend(e)

        sgraph_obj_dicts = list()
        for sg in self.obj_dict['subgraphs'].values():
            sgraph_obj_dicts.extend(sg)

        obj_list = sorted([
            (obj['sequence'], obj)
            for obj
            in (edge_obj_dicts + node_obj_dicts + sgraph_obj_dicts)])

        for _idx, obj in obj_list:
            if obj['type'] == 'node':
                node = Node(obj_dict=obj)

                if self.obj_dict.get('suppress_disconnected', False):
                    if (node.get_name() not in edge_src_set and
                            node.get_name() not in edge_dst_set):
                        continue

                graph.append(node.to_string() + '\n')

            elif obj['type'] == 'edge':
                edge = Edge(obj_dict=obj)

                if self.obj_dict.get('simplify', False) and edge in edges_done:
                    continue

                graph.append(edge.to_string() + '\n')
                edges_done.add(edge)
            else:
                sgraph = Subgraph(obj_dict=obj)
                graph.append(sgraph.to_string() + '\n')

        graph.append('}\n')

        return ''.join(graph)
339379
def load_json_network(json_dict):
    """"""
    network = pyphi.Network.from_json(json_dict['network'])
    state = json_dict['state']
    return (network, state)
602662
def to_json(self) -> Mapping:
        
        return {str(x): str(y) for x, y in self.items()}
154939
def createNetwork(self, data, headers=None, query_params=None, content_type="application/json"):
        
        uri = self.client.base_url + "/network"
        return self.client.post(uri, data, headers, query_params, content_type)
307721
def to_networkx(self, labels=None, edge_labels=False):
        
        import networkx as nx
        graph = nx.DiGraph()
        for node in self._traverse_nodes():
            u = node.key
            graph.add_node(u)  # Minor redundancy
            # Set node properties
            graph.nodes[u]['value'] = node.value
            if labels is not None:
                label = ','.join([str(getattr(node, k)) for k in labels])
                graph.nodes[u]['label'] = label
            if node.left is not None:
                v = node.left.key
                graph.add_node(v)
                graph.add_edge(u, v)
                if edge_labels:
                    graph.edge[u][v]['label'] = 'L'
            if node.right is not None:
                v = node.right.key
                graph.add_node(v)
                graph.add_edge(u, v)
                if edge_labels:
                    graph.edge[u][v]['label'] = 'R'
        return graph