久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

<tfoot id='ncNY6'></tfoot>

    <small id='ncNY6'></small><noframes id='ncNY6'>

      <bdo id='ncNY6'></bdo><ul id='ncNY6'></ul>

    <legend id='ncNY6'><style id='ncNY6'><dir id='ncNY6'><q id='ncNY6'></q></dir></style></legend>

  1. <i id='ncNY6'><tr id='ncNY6'><dt id='ncNY6'><q id='ncNY6'><span id='ncNY6'><b id='ncNY6'><form id='ncNY6'><ins id='ncNY6'></ins><ul id='ncNY6'></ul><sub id='ncNY6'></sub></form><legend id='ncNY6'></legend><bdo id='ncNY6'><pre id='ncNY6'><center id='ncNY6'></center></pre></bdo></b><th id='ncNY6'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='ncNY6'><tfoot id='ncNY6'></tfoot><dl id='ncNY6'><fieldset id='ncNY6'></fieldset></dl></div>

    1. 如何向networkx中的邊緣添加新屬性?

      How do I add a new attribute to an edge in networkx?(如何向networkx中的邊緣添加新屬性?)
          <tbody id='yLXZ8'></tbody>

        <legend id='yLXZ8'><style id='yLXZ8'><dir id='yLXZ8'><q id='yLXZ8'></q></dir></style></legend>

            <bdo id='yLXZ8'></bdo><ul id='yLXZ8'></ul>
          • <i id='yLXZ8'><tr id='yLXZ8'><dt id='yLXZ8'><q id='yLXZ8'><span id='yLXZ8'><b id='yLXZ8'><form id='yLXZ8'><ins id='yLXZ8'></ins><ul id='yLXZ8'></ul><sub id='yLXZ8'></sub></form><legend id='yLXZ8'></legend><bdo id='yLXZ8'><pre id='yLXZ8'><center id='yLXZ8'></center></pre></bdo></b><th id='yLXZ8'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='yLXZ8'><tfoot id='yLXZ8'></tfoot><dl id='yLXZ8'><fieldset id='yLXZ8'></fieldset></dl></div>

              <small id='yLXZ8'></small><noframes id='yLXZ8'>

                <tfoot id='yLXZ8'></tfoot>
              1. 本文介紹了如何向networkx中的邊緣添加新屬性?的處理方法,對(duì)大家解決問題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

                問題描述

                我所擁有的: 在 networkx 中導(dǎo)入的圖 G,其節(jié)點(diǎn)和邊由 gml 文件加載.

                What I have: a graph G imported in networkx with nodes and edges loaded by gml file.

                問題:如何為選中的邊E添加新屬性.

                Problem: How to add a new attribute to a selected edge E.

                我想做什么:我想為我的圖表的特定邊 E 添加一個(gè)新屬性類型".注意:該邊 E 不存在類型"屬性.

                What I want to do: I want to add a new attribute 'type' for a particular edge E of my graph. Attention: the attribute 'type' doesn't exist for this edge E.

                我的代碼是:

                  G.edge[id_source][id_target]['type']= value
                

                但是如果我打印 G 的所有邊,現(xiàn)在我有 n+1 個(gè)邊;G 的所有舊邊,以及一條新邊 p= (id_source, id_target, {'type'= value}).此外,舊邊 E(我要修改的邊)沒有新屬性type".

                But if I print all the edges of G, now I have n+1 edges; all the old edges of G, and a new edge p= (id_source, id_target, {'type'= value}). Furthermore, the old edge E (the one that I want modify) doesn't have the new attribute 'type'.

                所以我的代碼添加了一個(gè)新的優(yōu)勢(我不想要).

                So my code have added a new edge (that I don't want).

                我想更新舊的添加一個(gè)不存在的新屬性.

                I want to update the old one adding a new attribute that doesn't exist.

                推薦答案

                你可能有一個(gè) networkx MultiGraph 而不是一個(gè)圖,在這種情況下,邊的屬性設(shè)置有點(diǎn)棘手.(您可以通過加載節(jié)點(diǎn)之間具有多條邊的圖來獲得多重圖).您可能會(huì)通過分配屬性來破壞數(shù)據(jù)結(jié)構(gòu)G.edge[id_source][id_target]['type']= value 當(dāng)您需要時(shí)G.edge[id_source][id_target][key]['type']= value.

                You may have a networkx MultiGraph instead of a graph and in that case the attribute setting for edges is a little tricker. (You can get a multigraph by loading a graph with more than one edge between nodes). You may be corrupting the data structure by assigning the attribute G.edge[id_source][id_target]['type']= value when you need G.edge[id_source][id_target][key]['type']= value.

                以下是 Graphs 和 MultiGraphs 的不同工作方式示例.

                Here are examples of how it works differently for Graphs and MultiGraphs.

                對(duì)于 Graph 案例屬性的工作方式如下:

                For the Graph case attributes work like this:

                In [1]: import networkx as nx
                
                In [2]: G = nx.Graph()
                
                In [3]: G.add_edge(1,2,color='red')
                
                In [4]: G.edges(data=True)
                Out[4]: [(1, 2, {'color': 'red'})]
                
                In [5]: G.add_edge(1,2,color='blue')
                
                In [6]: G.edges(data=True)
                Out[6]: [(1, 2, {'color': 'blue'})]
                
                In [7]: G[1][2]
                Out[7]: {'color': 'blue'}
                
                In [8]: G[1][2]['color']='green'
                
                In [9]: G.edges(data=True)
                Out[9]: [(1, 2, {'color': 'green'})]
                

                MultiGraphs 有一個(gè)額外級(jí)別的鍵來跟蹤平行邊,因此它的工作方式略有不同.如果您沒有明確設(shè)置鍵 MultiGraph.add_edge() 將使用內(nèi)部選擇的鍵(順序整數(shù))添加新邊.

                With MultiGraphs there is an additional level of keys to keep track of the parallel edges so it works a little differently. If you don't explicitly set a key MultiGraph.add_edge() will add a new edge with an internally chosen key (sequential integers).

                In [1]: import networkx as nx
                
                In [2]: G = nx.MultiGraph()
                
                In [3]: G.add_edge(1,2,color='red')
                
                In [4]: G.edges(data=True)
                Out[4]: [(1, 2, {'color': 'red'})]
                
                In [5]: G.add_edge(1,2,color='blue')
                
                In [6]: G.edges(data=True)
                Out[6]: [(1, 2, {'color': 'red'}), (1, 2, {'color': 'blue'})]
                
                In [7]: G.edges(data=True,keys=True)
                Out[7]: [(1, 2, 0, {'color': 'red'}), (1, 2, 1, {'color': 'blue'})]
                
                In [8]: G.add_edge(1,2,key=0,color='blue')
                
                In [9]: G.edges(data=True,keys=True)
                Out[9]: [(1, 2, 0, {'color': 'blue'}), (1, 2, 1, {'color': 'blue'})]
                
                In [10]: G[1][2]
                Out[10]: {0: {'color': 'blue'}, 1: {'color': 'blue'}}
                
                In [11]: G[1][2][0]['color']='green'
                
                In [12]: G.edges(data=True,keys=True)
                Out[12]: [(1, 2, 0, {'color': 'green'}), (1, 2, 1, {'color': 'blue'})]
                

                這篇關(guān)于如何向networkx中的邊緣添加新屬性?的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

                【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請(qǐng)聯(lián)系我們刪除處理,感謝您的支持!

                相關(guān)文檔推薦

                python: Two modules and classes with the same name under different packages(python:不同包下同名的兩個(gè)模塊和類)
                Configuring Python to use additional locations for site-packages(配置 Python 以使用站點(diǎn)包的其他位置)
                How to structure python packages without repeating top level name for import(如何在不重復(fù)導(dǎo)入頂級(jí)名稱的情況下構(gòu)造python包)
                Install python packages on OpenShift(在 OpenShift 上安裝 python 包)
                How to refresh sys.path?(如何刷新 sys.path?)
                Distribute a Python package with a compiled dynamic shared library(分發(fā)帶有已編譯動(dòng)態(tài)共享庫的 Python 包)
                  <tbody id='7VXNl'></tbody>
              2. <legend id='7VXNl'><style id='7VXNl'><dir id='7VXNl'><q id='7VXNl'></q></dir></style></legend>

                  <small id='7VXNl'></small><noframes id='7VXNl'>

                  1. <i id='7VXNl'><tr id='7VXNl'><dt id='7VXNl'><q id='7VXNl'><span id='7VXNl'><b id='7VXNl'><form id='7VXNl'><ins id='7VXNl'></ins><ul id='7VXNl'></ul><sub id='7VXNl'></sub></form><legend id='7VXNl'></legend><bdo id='7VXNl'><pre id='7VXNl'><center id='7VXNl'></center></pre></bdo></b><th id='7VXNl'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='7VXNl'><tfoot id='7VXNl'></tfoot><dl id='7VXNl'><fieldset id='7VXNl'></fieldset></dl></div>

                        <bdo id='7VXNl'></bdo><ul id='7VXNl'></ul>
                      • <tfoot id='7VXNl'></tfoot>

                          主站蜘蛛池模板: 亚洲97| 国产一区免费 | 日本免费在线看 | 日韩成人精品 | 国产91在线 | 亚洲 | 在线亚洲免费视频 | 亚洲欧美日韩在线一区二区 | 国产综合视频 | 成人久草 | 国产精品亚洲一区 | 日韩欧美视频网站 | 2022精品国偷自产免费观看 | 精品视频一区二区三区在线观看 | 免费国产精品久久久久久 | 亚洲精品中文字幕在线观看 | 欧美精品a∨在线观看不卡 国产精品久久国产精品 | 日韩精品在线观看网站 | 亚洲视频在线播放 | 色综合视频 | 久久91精品国产一区二区 | 久久久91精品国产一区二区三区 | 久草在线视频中文 | 国产成人精品免费 | 91精品国产综合久久香蕉麻豆 | 亚洲毛片在线 | 亚州综合一区 | 一区精品视频在线观看 | 成人精品系列 | 久久久久久综合 | 欧美一区二区三区视频在线 | 久久综合一区二区三区 | 成人高潮片免费视频欧美 | 一级片av| 91精品国产乱码久久久久久久久 | 国产91黄色 | 欧美最猛黑人xxxⅹ 粉嫩一区二区三区四区公司1 | 欧美日韩一卡 | 色婷婷综合久久久久中文一区二区 | 91久久精品日日躁夜夜躁欧美 | 亚洲人成人一区二区在线观看 | 天天弄|