source: orange/orange/doc/Orange/rst/code/network-constructor.py @ 7771:ec73cd1b51a4

Revision 7771:ec73cd1b51a4, 584 bytes checked in by miha <miha.stajdohar@…>, 3 years ago (diff)

Call new underscore case functions.

Line 
1import Orange.network
2
3from matplotlib import pyplot as plt
4
5# vertices are placed randomly in Network constructor
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# read all edges and plot a line
14for u, v in net.get_edges():
15    x1, y1 = net.coors[0][u], net.coors[1][u]
16    x2, y2 = net.coors[0][v], net.coors[1][v]
17    plt.plot([x1, x2], [y1, y2], 'b-')
18
19# read x and y coordinates to Python list
20x = net.coors[0]
21y = net.coors[1]
22
23# plot vertices
24plt.plot(x, y, 'ro')
25plt.savefig("network-constructor.py.png")
Note: See TracBrowser for help on using the repository browser.