1

I have database with nodes and edges, I need to plot degree distribution for this data (frequency of occurrences of each degree). I'm new to reading delimited data files and can't figure out how to cut into pieces the file.

The file looks like this:

# 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 
...

I figured out how to plot the histogram when all degrees were given in one column here, but I can't figure out how should I extract this information from the given data set.

What I need is two arrays - one with all possible degrees and second one is frequencies of corresponding degree.

Community
  • 1
  • 1
user40
  • 1,361
  • 5
  • 19
  • 34
  • Do you understand what the degree of a node is? Do you understand how to calculate it when given the list of all edges connecting the nodes? – Lev Levitsky Mar 03 '14 at 08:37
  • Degree of a nodes is a number of edges adjacent to this node. From my point of view, I need only second block of data with list of edges. I'm trying to come up with an algorithm but can't think about anything usefull. – user40 Mar 03 '14 at 15:34
  • I agree that you only need the second part. The algorithm seems to be to simply count the number of times each node is mentioned, or am I missing something? The rest is implementation. – Lev Levitsky Mar 03 '14 at 15:36
  • I was not sure if the database can have repeated edges like [1,2] and [2,1]. I was told it can't so looks like counting number of times each node is mentioned is what i need. Thank you. – user40 Mar 04 '14 at 00:09

0 Answers0