【发布时间】:2013-11-04 10:34:17
【问题描述】:
我正在尝试计算和绘制维基百科投票网络 (contained into the SNAP collection of network datasets) 的出度和入度分布。这是一个有向图,表示为边列表。
读取和存储图形数据:
%Read the data file.
G = importdata('Wiki-Vote.txt', ' ', 4);
%G is a structure that contains:
% - data: a <num_of_edges,2> matrix filled with node (wiki users) ids
% - textdata: a cell matrix that contains the header strings (first 4
% lines).
% - colheaders: a cell matrix that contains the last descriptive string
% (fourth line).
%All the useful information is contained into data matrix.
%Split directed edge list into 'from' and 'to' nodes lists.
Nfrom = G.data(:,1); %Will be used to compute out-degree
Nto = G.data(:,2); % "..." in-degree
受this question的启发,我按照这种方式计算出度数
%Remove duplicate entries from Nfrom and Nto lists.
Nfrom = unique(Nfrom); %Will be used to compute the outdegree distribution.
Nto = unique(Nto); %Will be used to compute the indegree distribution.
%Out-degree: count the number of occurances of each element (node-user id)
%contained into Nfrom to G.data(:,1).
outdegNsG = histc(G.data(:,1), Nfrom);
odG = hist(outdegNsG, 1:size(Nfrom));
figure;
plot(odG)
title('linear-linear scale plot: outdegree distribution');
figure;
loglog(odG)
title('log-log scale plot: outdegree distribution');
计算入度的方法相同。但我采用的线性情节远非令人满意,让我怀疑我的方法是否不正确。
线性比例:
在对数刻度中:
以线性比例放大分布图可以清楚地看出它接近幂律:
我的问题是我计算度数分布的方法是否正确,因为我没有任何帮助来确保这一点。具体来说,我想知道histc 中的较少数量的垃圾箱是否会提供更清晰的图表而不会丢失任何有价值的信息。
【问题讨论】:
-
对于直方图,您总是需要权衡:更少的 bin 会降低 x 轴上的分辨率,但也会减少 y 轴上的噪声
-
当您向右移动时,也许使用更宽的垃圾箱?例如,使用
logspace而不是线性选择 bin 边缘。这样,您将减少图表右侧的噪音 -
我正在进行对数(指数?)分箱。我问这个问题的原因是为了确保我当前的方法是正确的,并且产生的噪音是所选数据集的问题。
-
好吧,你应该总是期望直方图中有噪声;而且你拥有的每个垃圾箱的元素越少
-
你也可以做一个库,比如python中的NetworkX或matlab中的this one from MIT。
标签: matlab social-networking distribution graph-theory