admin管理员组文章数量:1297053
A TypeError: MyNetwork.__init__() missing 1 required positional argument: 'some_parameter'
is thrown on the last line of the following code snippet:
class MyNetwork(nx.DiGraph):
def __init__(self, some_parameter: str, **attr):
super().__init__(**attr)
self.some_parameter = some_parameter
network = MyNetwork("some_parameter")
network.add_nodes_from([1,2,3])
network.add_edges_from([(1, 2), (2, 3), (3, 1)])
sub_network = network.subgraph([2,3])
How can this be fixed? The issue seems to be that the subgraph()
method which MyNetwork
inherited from nx.DiGraph
wants to create a new instance of MyNetwork
where the constructor (in this example) requires a single parameter.
本文标签: python 3xInherited networkx subgraph method failsStack Overflow
版权声明:本文标题:python 3.x - Inherited networkx subgraph method fails - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741642755a2390012.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论