networkx2 adjlist_inner_dict_factory 和 adjlist_outter_dict_factory 有什么区别

what is the difference between networkx2 adjlist_inner_dict_factory and adjlist_outter_dict_factory

在networkx 1中,graph有一个叫做adjlist_dict_factory的方法,可以用来创建邻接表。在networkx 2中,有两种方法

这里的inner和outer指的是什么?

具体来说,对于subgraph extraction code in 1.10,我应该用哪一个来代替adjlist_dict_factory

我都试过了,好像都有效...

在IPython笔记本中,来自??的信息对他们来说也是一样的。

In [4]: g.adjlist_outer_dict_factory??
Init signature: g.adjlist_outer_dict_factory(self, /, *args, **kwargs)
Docstring:
dict() -> new empty dictionary
dict(mapping) -> new dictionary initialized from a mapping object's
    (key, value) pairs
dict(iterable) -> new dictionary initialized as if via:
    d = {}
    for k, v in iterable:
        d[k] = v
dict(**kwargs) -> new dictionary initialized with the name=value pairs
    in the keyword argument list.  For example:  dict(one=1, two=2)
Type:           type

In [5]: nx.__version__
Out[5]: '2.2'

来自official documentation

Subclasses (Advanced):

The Graph class uses a dict-of-dict-of-dict data structure. The outer dict (node_dict) holds adjacency information keyed by node. The next dict (adjlist_dict) represents the adjacency information and holds edge data keyed by neighbor. The inner dict (edge_attr_dict) represents the edge data and holds edge attribute values keyed by attribute names.

Each of these three dicts can be replaced in a subclass by a user defined dict-like object. In general, the dict-like features should be maintained but extra features can be added. To replace one of the dicts create a new graph class by changing the class(!) variable holding the factory for that dict-like structure. The variable names are node_dict_factory, node_attr_dict_factory, adjlist_inner_dict_factory, adjlist_outer_dict_factory, edge_attr_dict_factory and graph_attr_dict_factory.

因此这些函数在 networkx2 图的子类中用于:

  • adjlist_outer_dict_factory:节点邻接(是否存在边)
  • adjlist_inner_dict_factory: 边缘数据