我有节点和边缘的数据库,我需要绘制这个数据的度分布(每个度数的出现频率)。我是新手阅读分隔数据文件,无法弄清楚如何切割文件。
该文件如下所示:
# list of nodes (# x y z coordinates, irrelevant data)
1 x= 0.0 y= 0.0 z= 0.0 M = 0.01 MU = 0.1 Ixx = 0.001 Iyy = 0.001 Izz = 0.001
2 x= -1.0 y= 1.732 z= 0.0 M = 0.01 MU = 0.1 Ixx = 0.001 Iyy = 0.001 Izz = 0.001
3 x= -1.0 y= -1.732 z= 0.0 M = 0.01 MU = 0.1 Ixx = 0.001 Iyy = 0.001 Izz = 0.001
4 x= 2.0 y= -0.0 z= 0.0 M = 0.01 MU = 0.1 Ixx = 0.001 Iyy = 0.001 Izz = 0.001
5 x= -2.0 y= 3.464 z= 0.0 M = 0.01 MU = 0.1 Ixx = 0.001 Iyy = 0.001 Izz = 0.001
6 x= -2.0 y= -3.464 z= 0.0 M = 0.01 MU = 0.1 Ixx = 0.001 Iyy = 0.001 Izz = 0.001
7 x= 4.0 y= -0.0 z= 0.0 M = 0.01 MU = 0.1 Ixx = 0.001 Iyy = 0.001 Izz = 0.001
8 x= 0.0 y= 0.0 z= 20.0 M = 0.01 MU = 0.1 Ixx = 0.001 Iyy = 0.001 Izz = 0.001
9 x= -1.0 y= 1.732 z= 20.0 M = 0.01 MU = 0.1 Ixx = 0.001 Iyy = 0.001 Izz = 0.001
...
# list of edges: (# of edge = [ two connected nodes ] #irrelevant information)
1 nodes = [ 1, 8 ] material = Material1
2 nodes = [ 1, 2 ] material = Material1
3 nodes = [ 1, 3 ] material = Material1
4 nodes = [ 1, 4 ] material = Material1
5 nodes = [ 2, 3 ] material = Material1
6 nodes = [ 2, 4 ] material = Material1
7 nodes = [ 2, 5 ] material = Material1
8 nodes = [ 2, 9 ] material = Material1
9 nodes = [ 3, 4 ] material = Material1
10 nodes = [ 3, 10 ] material = Material1
...
我想出了如何在一列here中给出所有度数时绘制直方图,但我无法弄清楚如何从给定的数据集中提取这些信息。
我需要的是两个阵列 - 一个具有所有可能的度数,第二个是相应度数的频率。