apgl is a fast Python graph library based on numpy and scipy with some machine learning features
I have written some Python code for working with graphs. The project is currently hosted at SourceForge under the name Another Python Graph Library. The aim of the project is to develop a simple, fast and easy to use graph library. Currently, one can create and modify user defined and random graphs, find shortest paths, and write to Pajek files for visualisation, among other things.
Here is a small example which creates a graph (using the SparseGraph class) and adds edges to it:
from graph.SparseGraph import SparseGraph
from graph.VertexList import VertexList
numVertices = 10
numFeatures = 3
vList = VertexList(numVertices, numFeatures)
#Set the 1st vertex to [0.1, 0.5, 0.1]. All other vertices are initialised to zero vectors.
vList.setVertex(0, numpy.array([0.1, 0.5, 0.1]))
#Create a SparseGraph object and add two edges with weights 2 and 5 respectively.
sGraph = SparseGraph(vList)
sGraph.addEdge(0, 1, 2)
sGraph.addEdge(1, 2, 5)
More details are given on the homepage of this project http://www.somethingaboutme.net/code2.php.