Rename AMR graph nodes to prefix + node_index to avoid nodes with the same name in two different AMRs.
187403
def rename_node(self, prefix):
        
        node_map_dict = {}
        # map each node to its new name (e.g. "a1")
        for i in range(0, len(self.nodes)):
            node_map_dict[self.nodes[i]] = prefix + str(i)
        # update node name
        for i, v in enumerate(self.nodes):
            self.nodes[i] = node_map_dict[v]
        # update node name in relations
        for node_relations in self.relations:
            for i, l in enumerate(node_relations):
                node_relations[i][1] = node_map_dict[l[1]]
730390
def rename(self, node):
        

        source = node.path
        base_name, state = QInputDialog.getText(self, "Rename", "Enter your new name:", text=os.path.basename(source))
        if not state:
            return False

        base_name = foundations.strings.to_string(base_name)
        if base_name == os.path.basename(source):
            return False

        parent_directory = os.path.dirname(source)
        target = os.path.join(parent_directory, base_name)

        if self.__script_editor.model.is_authoring_node(node):
            if not foundations.common.path_exists(source):
                LOGGER.info("{0} | Renaming '{1}' untitled file to '{2}'!".format(
                    self.__class__.__name__, source, target))
                self.__set_authoring_nodes(source, target)
                return True

        if not base_name in os.listdir(parent_directory):
            if node.family == "File":
                LOGGER.info("{0} | Renaming '{1}' file to '{2}'!".format(self.__class__.__name__, source, target))
                self.__rename_file(source, target)
            elif node.family == "Directory":
                LOGGER.info("{0} | Renaming '{1}' directory to '{2}'!".format(self.__class__.__name__, source, target))
                self.__rename_directory(source, target)
            elif node.family == "Project":
                LOGGER.info("{0} | Renaming '{1}' project to '{2}'!".format(self.__class__.__name__, source, target))
                self.__rename_project(source, target)
        else:
            self.__raise_file_system_exception(base_name, parent_directory)

        return True
385374
def remove_duplicate_edges_directed(dg):
    """"""
    # With directed edges, we can just hash the to and from node id tuples and if
    # a node happens to conflict with one that already exists, we delete it

    # --For aesthetic, we sort the edge ids so that lower edge ids are kept
    lookup = {}
    edges = sorted(dg.get_all_edge_ids())
    for edge_id in edges:
        e = dg.get_edge(edge_id)
        tpl = e['vertices']
        if tpl in lookup:
            dg.delete_edge_by_id(edge_id)
        else:
            lookup[tpl] = edge_id
867418
private Node renameProperty(Node propertyName) {
    checkArgument(propertyName.isString());
    if (!renameProperties) {
      return propertyName;
    }
    Node call = IR.call(
        IR.name(NodeUtil.JSC_PROPERTY_NAME_FN).srcref(propertyName),
        propertyName);
    call.srcref(propertyName);
    call.putBooleanProp(Node.FREE_CALL, true);
    call.putBooleanProp(Node.IS_CONSTANT_NAME, true);
    return call;
  }
335762
def change_path_prefix(self, path, old_prefix, new_prefix, app_name):
        """"""
        relative_path = os.path.relpath(path, old_prefix)
        return os.path.join(new_prefix, app_name, relative_path)
72706
def delete_node(self, node_name, graph=None):
        
        if not graph:
            graph = self.graph
        if node_name not in graph:
            raise KeyError('node %s does not exist' % node_name)
        graph.pop(node_name)

        for node, edges in six.iteritems(graph):
            if node_name in edges:
                edges.remove(node_name)
982573
function renameRemoteNode(node, name, callback) {
  var rActions = node.remoteActions || {};

  var newLocalName = utility.renameConflictNodeRemote(name);
  var oldLocalName = node.name;

  var newLocalPath = utility.joinPath(node.parent, newLocalName);
  var oldLocalPath = utility.joinPath(node.parent, oldLocalName);

  if(!rActions.create && fsWrap.existsSync(oldLocalPath)) {
    try {
      fsWrap.renameSync(oldLocalPath, newLocalPath);
    } catch(err) {
      logger.warning('rename local node failed', {category: 'sync-delta', oldLocalPath, newLocalPath, err})
      throw new BlnDeltaError(err.message);

      return;
    }
  }

  node.name = newLocalName;
  node.localActions = node.localActions || {};

  var remoteId = node.remoteId || node.remoteActions.create.remoteId;

  return blnApi.renameNode({remoteId, name: node.name}, (err) => {
    if(err) {
      logger.warning('rename remote node failed', {category: 'sync-delta', params: {remoteId, name: node.name}, err});
      throw new BlnDeltaError(err.message);

      return;
    }

    if(rActions.rename) {
      delete node.remoteActions.rename;
    }

    syncDb.update(node._id, node, callback);
  });
}
808254
def _addrs2nodes(addrs, G):
    
    for i, n in enumerate(G.nodes()):
        G.node[n]['addr'] = addrs[i]
1145943
def rename_with_num(self, prefix="", new_path=None, remove_desc=True):
        """"""
        # Temporary path #
        if new_path is None: numbered = self.__class__(new_temp_path())
        else:                numbered = self.__class__(new_path)
        # Generator #
        def numbered_iterator():
            for i,read in enumerate(self):
                read.id  = prefix + str(i)
                read.seq = read.seq.upper()
                if remove_desc: read.description = ""
                yield read
        # Do it #
        numbered.write(numbered_iterator())
        numbered.close()
        # Replace it #
        if new_path is None:
            os.remove(self.path)
            shutil.move(numbered, self.path)
        return numbered
1228169
function renameNodes(nodes, sourcePath, opts, mappings) {
  return nodes.map(function(node) {
    // Process CSS node
    if (node.type === 'class') {
      // Process "class" node
      var orgValue = node.value,
          newValue = renameClassNode(node.value, sourcePath, opts);
      // Edit node and store mapping of classname renaming
      node.value = mappings[orgValue] = newValue;
    } else if (node.type === 'pseudo' && node.value === ':not') {
      // Process ":not([selector])" pseudo node
      renameNodes(node.nodes, sourcePath, opts, mappings);
    } else if (node.type === 'selector') {
      // Rename selector nodes
      renameNodes(node.nodes, sourcePath, opts, mappings)
    }
  });
}
1087118
def cleanup(graph, subgraphs):
    
    for subgraph in subgraphs.values():
        update_node_helper(graph, subgraph)
        update_metadata(graph, subgraph)
924045
def common_prefix(s1, s2):
		
		index = min(len(s1), len(s2))
		while s1[:index] != s2[:index]:
			index -= 1
		return s1[:index]
1308509
def copy_from(self, g):
        
        renamed = {}
        for k, v in g.node.items():
            ok = k
            if k in self.place:
                n = 0
                while k in self.place:
                    k = ok + (n,) if isinstance(ok, tuple) else (ok, n)
                    n += 1
            renamed[ok] = k
            self.place[k] = v
        if type(g) is nx.MultiDiGraph:
            g = nx.DiGraph(g)
        elif type(g) is nx.MultiGraph:
            g = nx.Graph(g)
        if type(g) is nx.DiGraph:
            for u, v in g.edges:
                self.edge[renamed[u]][renamed[v]] = g.adj[u][v]
        else:
            assert type(g) is nx.Graph
            for u, v, d in g.edges.data():
                self.add_portal(renamed[u], renamed[v], symmetrical=True, **d)
        return self
581166
function resolveNodeSkel(index, nodeName) {
    var idx = +graph.nameToIndex[nodeName];
    argh = [idx, +index]
    if(Number.isNaN(idx)) {
      throw "Unable to get index for node '" + nodeName + "'. (Is the node name misspelled?)";
    }
    if(index !== undefined && idx > +index) {
      throw "Unable to get index for node '" + nodeName + "'. (Are the nodes out of order?)";
    }
    if(index !== undefined && idx == +index) {
      throw "Unable to get index for node '" + nodeName + "'. (Is the node trying to reference itself?)";
    }
    return (dataContext) => dataContext.values[idx];
  }
1242161
def normalize_node(node, headers=None):
    """"""
    headers = {} if headers is None else headers
    if isinstance(node, str):
        url = normalize_url(node)
        return {'endpoint': url, 'headers': headers}

    url = normalize_url(node['endpoint'])
    node_headers = node.get('headers', {})
    return {'endpoint': url, 'headers': {**headers, **node_headers}}
209878
def createManualIndex(self, indexName, indexClass):
        """"""
        indexClass = str(indexClass).lower()
        if indexClass == "vertex":
            index = self.neograph.nodes.indexes.create(indexName)
        elif indexClass == "edge":
            index = self.neograph.relationships.indexes.create(indexName)
        else:
            NameError("Unknown Index Class %s" % indexClass)
        return Index(indexName, indexClass, "manual", index)
1113475
def rename_dimension(x, old_name, new_name):
  
  return reshape(x, x.shape.rename_dimension(old_name, new_name))