The orngNetwork module provides the functionality to perform network analysis and layout optimization.
- Coordinates for all vertices. They are initialized to random positions. You can modify them manually or use one of the optimization algorithms. Usage:
coors[i]; 0 for x-axis, 1 for y-axis
- ExampleTable with information about vertices. Number of rows should match the number of vertices.
- 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".
- An instance of the NetworkOptimization class. Various network layout optimization methods can be applied to the network through this attribute.
- 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.
- 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.
- Reads the network from a Pajek (.net) or GML file. Usage:
- Holds the Network object.
- Default constrctor.
- Constructor that takes the Network object.
- 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 with
temperature(for example: 1000) and set list of hidden nodes with argument
- radialFruchtermanReingold(center, steps=100, temperature=1000)
- Radial Fruchterman-Reingold spring layout optimization. Set center node with attribute
center, number of iterations with argument
stepsand start temperature with
temperature(for example: 1000).
- Circular layout optimization based on original order.
- Circular layout optimization based on random order.
- Circular layout optimization (Michael Baur, Ulrik Brandes) with crossing reduction.
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:
- .fruchtermanReingold(steps, temperature, coolingFactor=Default, hiddenNodes=, weighted=False)
- .radialFruchtermanReingold(center, steps, temperature)
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.
Visualize a network in NetExplorer widget
This example demonstrates how to display a network in NetExplorer.
part of network_widget.py