Advertisement
Guest User

Untitled

a guest
Nov 18th, 2019
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.10 KB | None | 0 0
  1. #https://github.com/PyCQA/mccabe/blob/master/mccabe.py
  2. #1. Helyesség ellenőrzés (elő utó(Exists, forAll) invariáns )
  3. #2. Statikus analízis (Fehér dobozos tesztelés) python tool (D)
  4. #3. Test doubles (Mókolás) Mock, Fake, Stub, Dummy, DI  TDD xUnit (nUnit) Moq#
  5. #4. Terheléses teszt
  6. #5. Használhatósági teszt
  7. #6. Szoftver verifikáció (SAT, SMT)
  8.  
  9.  
  10. import networkx as NX
  11. import math as MT
  12. import random as RD
  13. import matplotlib
  14.  
  15. N = 21 # Number of Vertices (sensors)
  16.  
  17. minScope = 20
  18. maxScope = 120
  19.  
  20. rangeX =(5,295)
  21. rangeY =(5,295)
  22.  
  23. scopeRad = (minScope, maxScope)
  24.  
  25. # Node-ok, Scope-ok, Pozíciók
  26. D = NX.DiGraph()
  27.  
  28. arrScope =[[]]
  29. for i in range(1,N):
  30. x = float(RD.randrange(*rangeX))
  31. y = float(RD.randrange(*rangeY))
  32. positions = (x,y)
  33. rndRad = RD.randrange(*scopeRad)
  34. D.add_node(i, pos=(x,y))
  35. arrScope.append([i,rndRad])
  36. pos = NX.get_node_attributes(D,'pos')
  37.  
  38. for i in range(1,N):
  39. for j in range(1,N):
  40. x1,y1 = pos[i]
  41. x2,y2 = pos[j]
  42. if i != j:
  43. if (MT.sqrt(MT.pow((x2-x1),2)+MT.pow((y2-y1),2)))<=arrScope[i][1]:
  44. D.add_edge(i,j)
  45.  
  46.  
  47.  
  48. print(D.number_of_edges())
  49. print(D.number_of_nodes())
  50. # D sűrűsége
  51. print("A gráf sűrűsége: " + str(D.number_of_edges()/(N*(N-1))))
  52.  
  53. # Összefüggőség
  54. print(NX.is_strongly_connected(D))
  55.  
  56. # Legnagyobb nyelő (Bemenő elemek száma)
  57. print(len(D.in_edges(1)))
  58.  
  59. # Legnagyobb forrás (Kimenő élek száma)
  60. print(len(D.out_edges(11)))
  61.  
  62. # Független utak száma
  63. print("Független utak"+str(list(NX.all_simple_paths(D,1,20))))
  64.  
  65. # Hamilton kör
  66. #print(list(NX.hamiltonian(D)))
  67.  
  68. # Euler kör
  69.  
  70. # Leghosszabb út
  71.  
  72. # Legrövidebb út
  73. #print(list(D.shortest_paths(D)))
  74.  
  75. # Átlagos úthossz (átmérő)
  76.  
  77. # Körök száma
  78. print("körök")
  79. print(len(list(NX.simple_cycles(D))))
  80. print(list(NX.simple_cycles(D)))
  81. # Ciklomatikus komplexitás
  82. E = D.number_of_edges()
  83. V = D.number_of_nodes()
  84. P = len(list(NX.strongly_connected_components(D)))
  85. print(str(E-V+2*P))
  86.  
  87. NX.draw(D, pos, with_labels=True)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement