source: orange/orange/doc/Orange/rst/code/network-constructor.py @ 7332:8dd3e886cd6d

Revision 7332:8dd3e886cd6d, 522 bytes checked in by miha <miha.stajdohar@…>, 3 years ago (diff)
Line 
1import Orange.network
2from pylab import *
3
4# vertices are placed randomly in Network constructor
5net = Orange.network.Network(5, 0)
6
7# set edges
8for i in range(4):
9    for j in range(i + 1, 5):
10        net[i,j] = 1
11
12# read all edges and plot a line
13for u, v in net.getEdges():
14    x1, y1 = net.coors[0][u], net.coors[1][u]
15    x2, y2 = net.coors[0][v], net.coors[1][v]
16    plot([x1, x2], [y1, y2], 'b-')
17
18# read x and y coordinates to Python list
19x = net.coors[0]
20y = net.coors[1]
21
22# plot vertices
23plot(x, y, 'ro')
24show()
Note: See TracBrowser for help on using the repository browser.