# Networkx for feedback networks

back to Realistic modeling of complex interactive systems#Assignments/exercises see the
Kejzar slides for introduction to the simulations. See related: Python for networks. What is Networkx?. What are "feedback networks"?

## Installing networkx for Python

http://cheeseshop.python.org/pypi/networkx/0.34 Networkx (v.99) including windows installation (that is the recommended download). IDLE is the Python GUI.

**This problem went away in my 2009 installation**: In my windows installation, Nataša Kejžar's two programs for the feedback networks simulation, feedback.py and to_Pajek.py, didnt recognize networkx to be a valid module until I renamed C:\python25\share\doc\networkx-0.34 to networkx-x.xx. Then they ran, and left to_Pajek.pyc, a compiled file that Python uses to speed execution. Doug 30 June 2007 (PDT) to_Pajek.pyc is on my directory c:/Python.

- Use the python shell to open and run feedback.py don't just click on it or you won't see any error messages.

## Starting from Python feedback networks

back to Python for networks

The function to_Pajek.Graph_to_Pajek(G,"feedback1120.net")

The feedback.py calls a function to_Pajek (from the feedback.py file, last few lines, uncommented) and outputs a file in which network G (in networkx format) is saved as a Pajek file. So it can be read in Pajek and analyzed or drawn (if a suitable number of vertices, of course--Nataša June 2007).

- In the interactive window ("Python shell"), you have the G (network in

networkx format) saved and you can analyze it further with networkx commands (such as to get degree "histogram"; the commands are:

import networkx hist = networkx.degree_histogram(G)

(is this a compound operation? i.e. deg = networkx.degree prior to histogram; histogram is a function in Python) You may want to go back to http://www.awaretek.com/tutorials.html or http://www.limsi.fr/Individu/pointal/python/pqrc/versions/PQRC-2.4-USLetter-latest.pdf or http://rgruet.free.fr/PQR25/PQR2.5_modern_B&W_letter.pdf for commands in Python and https://networkx.lanl.gov/Reference/ or https://networkx.lanl.gov/wiki/QuickReference for commands in networkx.

Natasa -- how do I make these modules callable?

cent = networkx.centrality(G) comp = networkx.components(G)

## Pajek drawings

G = simulate_feedback(1,1.2,0,5000,1) alpha=1 beta=1.2 gamma=0 The average links per node is 1.4, and colors in the center are for k-core levels by out degree.

See Triad Census. For this network, where numbers 1-2-3 are for symmetric, asymmetric and null ties, the triads that occur more than expected are 102 (3 transitive arcs), 300 (2 outgoing arcs) and 201 (2-chain). Similarly but more strongly for G = simulate_feedback(1,1.1,1,5000,1) alpha=1 beta=1.1 gamma=1. In addition to transitivity the other prominent feature is that the degree distributions asymptote to a power law with exponent 1.8 in the first case, and 2.16 in the second (rsq>.98 in each), and are better approximated by a *q*-exponential. This is expected because alpha=1.

THESE RESULTS HOWEVER USE ONLY THE FIRST DIRECTED TIE, AND DO NOT INCLUDE RECIPROCALS!!! AM ASKING NATASA to change the feedback.py to output the arcs, including reciprocal.