source: orange/docs/reference/rst/code/network-constructor.py @ 9823:7f9c3f3c6474

Revision 9823:7f9c3f3c6474, 581 bytes checked in by lanumek, 2 years ago (diff)

Changed names of data sets (table replaced with data or name of the data set).

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.png")
Note: See TracBrowser for help on using the repository browser.