source: orange/Orange/doc/reference/pathfinder.py @ 11012:19029caa4a32

Revision 11012:19029caa4a32, 1017 bytes checked in by Miha Stajdohar <miha.stajdohar@…>, 18 months ago (diff)

Fixed more network references.

Line 
1import Orange
2from orangeom import Pathfinder
3from pylab import *
4
5def myPlot(net, titleTxt=''):
6    """
7    Displays the given network.
8    """
9    figure()
10    title(titleTxt)
11    # Plot the edges
12    for u, v in net.getEdges():
13        x1, y1 = net.coors[0][u], net.coors[1][u]
14        x2, y2 = net.coors[0][v], net.coors[1][v]
15        plot([x1, x2], [y1, y2], 'b-')
16    # Plot the nodes
17    for u in range(net.nVertices):
18        x, y = net.coors[0][u], net.coors[1][u]
19        plot(x, y, 'ro')
20        # Label
21        text(x, y + 100, net.items[u][1])
22       
23# Read a demo network from a file
24net = Orange.core.Network.read('demo.net')
25
26# Compute a layout for plotting
27netOp = Orange.core.NetworkOptimization(net)
28netOp.fruchtermanReingold(100, 1000)
29
30# Plot the original
31myPlot(net, 'Original network')
32
33# Choose some parameters
34r, q = 1, 6
35
36# Create a pathfinder instance
37pf = Pathfinder()
38
39# Simplify the network
40pf.simplify(r, q, net)
41
42# Plot the simplified network
43myPlot(net, 'Simplified network')
44show()
Note: See TracBrowser for help on using the repository browser.