source: orange/Orange/testing/regression/tests_20/reference_graph_analyses.py @ 9952:986e9cd806f4

Revision 9952:986e9cd806f4, 1.4 KB checked in by Miha Stajdohar <miha.stajdohar@…>, 2 years ago (diff)

Tests moved and renamed from orange 20.

Line 
1import orange
2from orngNetwork import Network
3from orngNetwork import NetworkOptimization
4from pylab import *
5
6       
7# vertices are placed randomly in NetworkOptimization constructor
8network = NetworkOptimization()
9
10# read network from file
11net = Network.read("combination.net")
12
13components = net.getConnectedComponents()
14print "Connected components"
15print components
16print
17
18distribution = net.getDegreeDistribution()
19print "Degree distribution"
20print distribution
21print
22
23degrees = net.getDegrees()
24print "Degrees"
25print degrees
26print
27
28hubs = net.getHubs(3)
29print "Hubs"
30print hubs
31print
32
33path = net.getShortestPaths(0, 2)
34print "Shortest path"
35print path
36print
37
38distance = net.getDistance(0, 2)
39print "Distance"
40print distance
41print
42
43diameter = net.getDiameter()
44print "Diameter"
45print diameter
46print
47
48subnet = Network(net.getSubGraph([0, 1, 2, 3]))
49subNetOptimization = NetworkOptimization(subnet)
50subNetOptimization.fruchtermanReingold(100, 1000)
51
52# read all edges in subnetwork and plot a line
53for u, v in subnet.getEdges():
54    x1, y1 = subnet.coors[0][u], subnet.coors[1][u]
55    x2, y2 = subnet.coors[0][v], subnet.coors[1][v]
56    plot([x1, x2], [y1, y2], 'b-')       
57       
58# read x and y coordinates to Python list
59x = [coordinate for coordinate in subnet.coors[0]]
60y = [coordinate for coordinate in subnet.coors[1]]
61
62# plot vertices of subnetwork
63plot(x, y, 'ro')
64show()
Note: See TracBrowser for help on using the repository browser.