source: orange/docs/reference/rst/code/network-optimization.py @ 9828:2a856c5429d0

Revision 9828:2a856c5429d0, 703 bytes checked in by Miha Stajdohar <miha.stajdohar@…>, 2 years ago (diff)

Removed fr_radial. Not implemented yet.

Line 
1import Orange.network
2
3from matplotlib import pyplot as plt
4
5# create graph object of type GraphAsList
6net = Orange.network.Network(5, 0)
7
8# set edges
9for i in range(4):
10    for j in range(i + 1, 5):
11        net[i, j] = 1
12
13# vertices are placed randomly in NetworkOptimization constructor
14networkOptimization = Orange.network.NetworkOptimization(net)
15
16# read all edges and plot a line
17for u, v in net.get_edges():
18    x1, y1 = net.coors[0][u], net.coors[1][u]
19    x2, y2 = net.coors[0][v], net.coors[1][v]
20    plt.plot([x1, x2], [y1, y2], 'b-')
21
22# read x and y coordinates to Python list
23x = net.coors[0]
24y = net.coors[1]
25
26# plot vertices
27plt.plot(x, y, 'ro')
28plt.savefig("network-optimization.py.png")
Note: See TracBrowser for help on using the repository browser.