orngNetwork
The orngNetwork module provides the functionality to perform network analysis and layout optimization.
Network
Attributes
- coors
- Coordinates for all vertices. They are initialized to random positions. You can modify them manually or use one of the optimization algorithms. Usage:
coors[0][i],coors[1][i]; 0 for x-axis, 1 for y-axis - items
- ExampleTable with information about vertices. Number of rows should match the number of vertices.
- links
- ExampleTable with information about edges. Number of rows should match the number of edges. Two float attributes named "u" and "v" must be in links table domain to relate the data of an example to an edge. Here, egde is defined by two vertices "u" and "v".
- optimization
- An instance of the NetworkOptimization class. Various network layout optimization methods can be applied to the network through this attribute.
Methods
- Network()
- Default constrctor. Creates a network with one vertex.
- Network(nVertices, nEdges, directedGraph=False)
- Creates a network with n vertices. The nEdges attribute is used to set the number of edge types. It should always be 0, except in some special cases.
- fromDistanceMatrix(matrix, lower, upper, kNN=0)
- Creates edges between vertices with the distance within given threshold. Matrix should be of orange.SymMatrix type. The number ob objects in a matrix must match the number of vertices in a network. The kNN parameter can be used to specify the minimum number of closest vertices to be connected.
- save(file)
- Saves the network to a Pajek (.net) or GML file format. ExampleTables items and links are saved automatically if the value is not None. They are saved to "file_items.tab" and "file_links.tab" files.
Static Methods
- read(file)
- Reads the network from a Pajek (.net) or GML file. Usage:
orngNetwork.Network.read(filename)
NetworkOptimization
Attributes
- graph
- Holds the Network object.
Methods
- NetworkOptimization()
- Default constrctor.
- NetworkOptimization(network)
- Constructor that takes the Network object.
- random()
- Random layout optimization.
- fruchtermanReingold(steps=100, temperature=1000, coolFactor=default, hiddenNodes=[], weighted=False)
- Fruchterman-Reingold spring layout optimization. Set number of iterations with argument
steps, start temperature withtemperature(for example: 1000) and set list of hidden nodes with argumenthidden_nodes. - radialFruchtermanReingold(center, steps=100, temperature=1000)
- Radial Fruchterman-Reingold spring layout optimization. Set center node with attribute
center, number of iterations with argumentstepsand start temperature withtemperature(for example: 1000). - circularOriginal()
- Circular layout optimization based on original order.
- circularRandom()
- Circular layout optimization based on random order.
- circularCrossingReduction()
- Circular layout optimization (Michael Baur, Ulrik Brandes) with crossing reduction.
Examples
Network constructor and random layout
In our first example we create a Network object with a simple full graph (K5). Vertices are initially placed randomly. Graph is visualized using pylabs matplotlib. NetworkOptimization class is not needed since we do not apply any layout optimization method in this example.
Executing the above script pops-up a pylab window with the following graph drawing:
Network layout optimization
This example demonstrates how to optimize network layout using one of included algorithms.
part of network_optimization.py
You can use one of the following optimization algorithms:
- .random()
- .fruchtermanReingold(steps, temperature, coolingFactor=Default, hiddenNodes=[], weighted=False)
- .radialFruchtermanReingold(center, steps, temperature)
- .circularOriginal()
- .circularRandom()
- .circularCrossingReduction()
Spring forces layout optimization is the result of the above script:
Reading and saving a network
This example demonstrates reading a network. Network class can read or write Pajek (.net) or GML file format.
network_read.py (uses K5.net)
Visualize a network in NetExplorer widget
This example demonstrates how to display a network in NetExplorer.
part of network_widget.py
