在中间时间步骤测量网络属性

时间:2017-09-12 09:47:46

标签: r python-2.7 graph-theory networkx

我必须在网络增长的某些步骤(即N = 100,N = 1000,N = 10000等)测量Barabasi Albert图的某些性质,如度分布。我知道如何使用networkx生成这样的图表,但我真的不清楚如何在增长过程中访问这些属性。

没有代码可以显示给你,我需要提示算法本身,一些例子将非常感激。我使用的是Python 2.7,但如果有必要,我也很满意R.

2 个答案:

答案 0 :(得分:0)

我认为您正在寻找的功能是Barbabasi Albert Graph function netwrokx。在查看上述函数on this link的源代码(基于networkx文档)时,注释中给出了步骤。您可以在while source<n:循环的每次迭代中打印图表的属性,以获得所需的属性。

答案 1 :(得分:0)

根据@Mohammed Kashif的回答,这里是Barabasi Albert图的修改后的源代码,它返回一个字典数量的字典,其值为数组:

g,d = barabasi_albert_graph_modified(10,2)
#out:
#{3: array([1, 1, 2]),
# 4: array([1, 2, 2, 3]),
# 5: array([1, 2, 2, 3, 4]),
# 6: array([1, 2, 2, 2, 4, 5]),
# 7: array([1, 2, 2, 2, 3, 4, 6]),
# 8: array([2, 2, 2, 2, 2, 3, 4, 7]),
# 9: array([2, 2, 2, 2, 2, 2, 4, 5, 7]),
# 10: array([2, 2, 2, 2, 2, 2, 3, 4, 5, 8])}

让我们试一试:

{
"status": "true",
"statusCode": 200,
"response": [
    {
        "sort_order": 0,
        "control_name": "ion-select",
        "label": "Select master OLT",
        "type": "select",
        "placeholder": "Select master OLT",
        "name": "E0selectoption_master_olt",
        "readonly": "True",
        "required": "required",
        "maxlength": "",
        "minlength": ""           
    },
    {
        "sort_order": 1,
        "control_name": "ion-select",
        "label": "Select OLT port",
        "type": "select",
        "placeholder": "Select OLT port",
        "name": "E1selectoption_olt_port",
        "readonly": "True",
        "required": "required",
        "maxlength": "",
        "minlength": ""           
    },
    {
        "sort_order": 2,
        "control_name": "ion-select",
        "label": "Select Parent node",
        "type": "select",
        "placeholder": "Select parent node",
        "name": "E2selectoption_parent_node",
        "readonly": "True",
        "required": "required",
        "maxlength": "",
        "minlength": "",
        "is_dependent": "true",
        "masters": "gis_node",
        "value": ""           
    },
    {
        "sort_order": 3,
        "control_name": "ion-select",
        "label": "Select child node",
        "type": "select",
        "placeholder": "Select child node",
        "name": "E3selectoption_child_node",
        "readonly": "True",
        "required": "required",
        "maxlength": "",
        "minlength": "",
        "is_dependent": "true",
        "masters": "gis_node",
        "value": ""          
    },
    {
        "sort_order": 4,
        "control_name": "button",
        "label": "submit",
        "type": "submit",
        "placeholder": "",
        "name": "E4submit_btnsubmit",
        "readonly": "False",
        "required": "required",
        "maxlength": "",
        "minlength": "",
        "is_dependent": "false",
        "masters": "",
        "value": ""
    }
]
}